feat: IBKR ticket in Dashboard + Journal MtM (Strike, DTE, legs)
Adds full Interactive Brokers order ticket to both the Dashboard cockpit and the Journal de Bord MtM expanded rows. Each ticket shows the underlying, computed strike in dollars, estimated expiry date (nearest Friday), per-leg BUY/SELL CALL/PUT breakdown, order type LIMIT, budget and target. Also adds Strike and DTE columns to the MtM table and persists strike_guidance + expiry_days_at_entry in trade_entry_prices. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -207,6 +207,8 @@ def init_db():
|
||||
("last_seen_at", "TEXT"),
|
||||
("pnl_pct", "REAL"),
|
||||
("capital_invested", "REAL"),
|
||||
("strike_guidance", "TEXT"),
|
||||
("expiry_days_at_entry", "INTEGER"),
|
||||
]:
|
||||
try:
|
||||
c.execute(f"ALTER TABLE trade_entry_prices ADD COLUMN {col} {definition}")
|
||||
@@ -1008,6 +1010,16 @@ def log_trade_entries(run_id: str, scored_patterns: List[Dict[str, Any]], quotes
|
||||
_orig.get("horizon_days") or
|
||||
90
|
||||
)
|
||||
strike_guidance = (
|
||||
trade.get("strike_guidance") or
|
||||
sp.get("recommended_trade", {}).get("strike_guidance") or
|
||||
None
|
||||
)
|
||||
expiry_days_entry = int(
|
||||
trade.get("expiry_days") or
|
||||
sp.get("recommended_trade", {}).get("expiry_days") or
|
||||
horizon
|
||||
)
|
||||
|
||||
existing_row = conn.execute(
|
||||
"SELECT id FROM trade_entry_prices WHERE pattern_id=? AND underlying=? AND strategy=?",
|
||||
@@ -1025,12 +1037,14 @@ def log_trade_entries(run_id: str, scored_patterns: List[Dict[str, Any]], quotes
|
||||
(run_id, pattern_id, pattern_name, underlying, strategy,
|
||||
entry_price, entry_date, score_at_entry, latest_score,
|
||||
expected_move_pct, horizon_days, ev_at_entry, ev_net,
|
||||
trade_score, matched_profile, last_seen_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (
|
||||
trade_score, matched_profile, last_seen_at,
|
||||
strike_guidance, expiry_days_at_entry)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (
|
||||
run_id, pid, pattern_name, ticker_key, strategy,
|
||||
entry_price, today, eff_score, eff_score,
|
||||
exp_move, horizon, ev_gross, ev_net,
|
||||
trade_score, matched, now_ts,
|
||||
strike_guidance, expiry_days_entry,
|
||||
))
|
||||
inserted_count += 1
|
||||
_log.info(f"[TradeLog] NEW trade: pattern='{pattern_name}' {underlying} {strategy} score={eff_score} gain={exp_move:.0f}% profile='{matched}' price={entry_price}")
|
||||
|
||||
Reference in New Issue
Block a user