9257a8051f
Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
699 B
Python
23 lines
699 B
Python
"""Tests for trend strategy snapshot backfill helpers."""
|
|
from scripts.backfill_trend_strategy_snapshots import (
|
|
infer_exit_price,
|
|
resolve_result_label,
|
|
)
|
|
|
|
|
|
def test_infer_exit_price_short_stop_loss():
|
|
exit_p = infer_exit_price("short", 0.336, 4.85, 10, -2.45)
|
|
assert exit_p is not None
|
|
assert abs(exit_p - 0.353) < 0.002
|
|
|
|
|
|
def test_resolve_result_label_from_plan_status():
|
|
plan = {"status": "stopped_sl", "message": "stopped_sl"}
|
|
assert resolve_result_label(plan, None) == "止损"
|
|
|
|
|
|
def test_resolve_result_label_prefers_plan_status():
|
|
plan = {"status": "stopped_sl"}
|
|
trade = {"result": "移动止盈"}
|
|
assert resolve_result_label(plan, trade) == "止损"
|