feat: strategy builder
This commit is contained in:
@@ -341,6 +341,11 @@ def init_db():
|
||||
"ALTER TABLE strategy_scenarios ADD COLUMN rate_shock_bps REAL DEFAULT 0",
|
||||
"ALTER TABLE strategy_scenarios ADD COLUMN dte_min INTEGER",
|
||||
"ALTER TABLE strategy_scenarios ADD COLUMN dte_max INTEGER",
|
||||
# Strategy Builder — Construire/Analyse historique merge: tags which mode priced
|
||||
# this strategy when it was saved, so the saved-strategies library (now shown in
|
||||
# both modes) can badge it and the other mode knows it's re-pricing a strategy that
|
||||
# wasn't originally priced there.
|
||||
"ALTER TABLE saved_strategies ADD COLUMN source TEXT DEFAULT 'synthetic'",
|
||||
]:
|
||||
try:
|
||||
c.execute(_sql)
|
||||
@@ -6421,8 +6426,8 @@ def save_strategy(strategy: Dict[str, Any]) -> str:
|
||||
conn = get_conn()
|
||||
conn.execute("""INSERT INTO saved_strategies (
|
||||
id, scenario_id, symbol, template_name, objective, legs,
|
||||
entry_cost, max_gain, max_loss, net_pnl_scenario, net_delta, notes
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
||||
entry_cost, max_gain, max_loss, net_pnl_scenario, net_delta, notes, source
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
||||
strategy_id,
|
||||
strategy.get("scenario_id"),
|
||||
strategy["symbol"],
|
||||
@@ -6435,6 +6440,7 @@ def save_strategy(strategy: Dict[str, Any]) -> str:
|
||||
strategy.get("net_pnl_scenario"),
|
||||
strategy.get("net_delta"),
|
||||
strategy.get("notes", ""),
|
||||
strategy.get("source", "synthetic"),
|
||||
))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user