Persist options review deletes across local resync.
Hide deleted rows by history key and contract/close fingerprint so local options_trades imports no longer resurrect them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -226,6 +226,38 @@ class OptionsReviewTests(unittest.TestCase):
|
||||
).fetchone()
|
||||
self.assertEqual(float(row["realized_pnl_total"]), 1.23)
|
||||
|
||||
def test_hide_trade_persists_across_local_sync(self):
|
||||
conn = _conn()
|
||||
from lib.options.options_db import init_options_tables
|
||||
from lib.options.options_review_lib import (
|
||||
hide_review_trade,
|
||||
sync_options_from_local_trades,
|
||||
)
|
||||
|
||||
init_options_tables(conn)
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO options_trades
|
||||
(inst_id, underlying, opt_type, strike, sheets, eth_amount,
|
||||
open_quote, premium_paid, status, realized_pnl, created_at, closed_at)
|
||||
VALUES ('ETH-USD-1-C','ETH','C',2000,1,0.01,0.01,0.2,'closed',1.0,
|
||||
'2026-03-01 10:00:00','2026-03-01 11:00:00')
|
||||
"""
|
||||
)
|
||||
sync_options_from_local_trades(conn)
|
||||
tid = conn.execute("SELECT id FROM options_review_trades").fetchone()["id"]
|
||||
out = hide_review_trade(conn, tid)
|
||||
self.assertTrue(out["ok"])
|
||||
self.assertEqual(
|
||||
conn.execute("SELECT COUNT(*) AS c FROM options_review_trades").fetchone()["c"],
|
||||
0,
|
||||
)
|
||||
sync_options_from_local_trades(conn)
|
||||
self.assertEqual(
|
||||
conn.execute("SELECT COUNT(*) AS c FROM options_review_trades").fetchone()["c"],
|
||||
0,
|
||||
)
|
||||
|
||||
def test_local_options_trades_import(self):
|
||||
conn = _conn()
|
||||
from lib.options.options_db import init_options_tables
|
||||
|
||||
Reference in New Issue
Block a user