feat: archive trades by close time and show open time on live positions
Sort inner-archive daily trades by closed_at_ms; add open time and live hold duration to instance and hub position cards, with exchange margin on hub footer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1418,7 +1418,7 @@ def list_daily_trades(
|
||||
search: str = "",
|
||||
db_path: Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""按日期区间列出开仓记录(本日/本周/本月/自选),含犯病与盈亏统计。"""
|
||||
"""按日期区间列出平仓记录(本日/本周/本月/自选,以平仓时间计),含犯病与盈亏统计。"""
|
||||
init_db(db_path)
|
||||
p = (period or "today").strip().lower() or "today"
|
||||
start_ms, end_ms, df, dt, period_label = resolve_period_bounds(
|
||||
@@ -1431,7 +1431,7 @@ def list_daily_trades(
|
||||
conn = _connect(db_path)
|
||||
try:
|
||||
params: list[Any] = [start_ms, end_ms]
|
||||
where = "opened_at_ms >= ? AND opened_at_ms < ?"
|
||||
where = "closed_at_ms IS NOT NULL AND closed_at_ms >= ? AND closed_at_ms < ?"
|
||||
if ex_filter:
|
||||
where += " AND exchange_key=?"
|
||||
params.append(ex_filter)
|
||||
@@ -1439,7 +1439,7 @@ def list_daily_trades(
|
||||
f"""
|
||||
SELECT * FROM archive_trade_cache
|
||||
WHERE {where}
|
||||
ORDER BY opened_at_ms DESC, trade_id DESC
|
||||
ORDER BY closed_at_ms DESC, trade_id DESC
|
||||
""",
|
||||
params,
|
||||
).fetchall()
|
||||
|
||||
Reference in New Issue
Block a user