feat(scripts): add backfill for missing trend strategy snapshots

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-07 16:53:50 +08:00
parent f976697203
commit 9257a8051f
3 changed files with 274 additions and 3 deletions
+22
View File
@@ -0,0 +1,22 @@
"""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) == "止损"