Implement dual target-close paths and residual option expiry.

Document and enforce: A full dual-leg close, B perp-only when deep OTM with residual archive that does not block next open, and expiry settlement when target is missed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 18:32:05 +08:00
parent 96e8e5cb70
commit 4994aaab16
14 changed files with 595 additions and 118 deletions
+22
View File
@@ -97,6 +97,28 @@ CREATE TABLE IF NOT EXISTS strategy_state (
last_error TEXT,
updated_at_ms INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS residual_options (
id INTEGER PRIMARY KEY AUTOINCREMENT,
group_id TEXT NOT NULL UNIQUE,
option_inst_id TEXT NOT NULL,
option_side TEXT NOT NULL,
option_qty_eth REAL NOT NULL,
option_qty_contracts REAL,
option_entry_px REAL NOT NULL,
strike REAL,
expiry_ymd TEXT,
expiry_ms INTEGER,
entry_index_px REAL,
initial_premium REAL DEFAULT 0,
status TEXT NOT NULL DEFAULT 'pending',
created_at_ms INTEGER NOT NULL,
settled_at_ms INTEGER,
settle_px REAL,
settle_pnl REAL,
note TEXT,
FOREIGN KEY(group_id) REFERENCES groups(group_id)
);
"""