feat(scripts): add backfill for missing trend strategy snapshots
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -127,6 +127,7 @@ def save_trend_plan_snapshot(
|
||||
result_label: str,
|
||||
exit_price: float | None = None,
|
||||
pnl_amount: float | None = None,
|
||||
closed_at: str | None = None,
|
||||
) -> None:
|
||||
init_strategy_snapshot_table(conn)
|
||||
row = _row_dict(plan_row)
|
||||
@@ -134,7 +135,7 @@ def save_trend_plan_snapshot(
|
||||
if plan_id <= 0:
|
||||
return
|
||||
m = cfg.get("app_module")
|
||||
closed_at = (
|
||||
close_ts = (closed_at or "").strip() or (
|
||||
m.app_now_str()
|
||||
if m is not None and hasattr(m, "app_now_str")
|
||||
else datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
|
||||
@@ -158,10 +159,10 @@ def save_trend_plan_snapshot(
|
||||
result_label,
|
||||
row.get("status"),
|
||||
row.get("opened_at"),
|
||||
closed_at,
|
||||
close_ts,
|
||||
pnl_amount,
|
||||
_json_dumps(payload),
|
||||
closed_at,
|
||||
close_ts,
|
||||
),
|
||||
)
|
||||
prune_strategy_snapshots(conn, keep=STRATEGY_SNAPSHOTS_MAX_ROWS)
|
||||
|
||||
Reference in New Issue
Block a user