feat: archive entry type from review, prune stale trades on sync, manual delete

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 12:39:27 +08:00
parent e68e29629e
commit 46963a4498
7 changed files with 260 additions and 19 deletions
+26
View File
@@ -9,6 +9,7 @@ from hub_ohlcv_lib import aggregate_ohlcv_bars
from hub_symbol_archive_lib import (
_fill_missing_bars,
init_db,
load_symbol_trades,
resolve_archive_chart,
upsert_bars_5m,
upsert_trade_overlay,
@@ -134,6 +135,31 @@ def test_resolve_archive_chart_history_range():
assert len(out["candles"]) >= 40
def test_sync_prunes_missing_trades():
with tempfile.TemporaryDirectory() as td:
db = Path(td) / "archive.db"
init_db(db)
upsert_trades_cache(
"gate",
[
{"id": 1, "symbol": "BNB/USDT", "result": "止损", "pnl_amount": -1},
{"id": 2, "symbol": "BNB/USDT", "result": "止盈", "pnl_amount": 1},
],
db_path=db,
prune_missing=False,
)
stats = upsert_trades_cache(
"gate",
[{"id": 1, "symbol": "BNB/USDT", "result": "止损", "pnl_amount": -1}],
db_path=db,
prune_missing=True,
)
rows = load_symbol_trades("gate", "BNB/USDT", db_path=db)
assert len(rows) == 1
assert rows[0]["trade_id"] == 1
assert stats["removed"] == 1
def test_list_with_overlay_filters():
with tempfile.TemporaryDirectory() as td:
db = Path(td) / "archive.db"