feat: strategy builder
This commit is contained in:
@@ -94,7 +94,10 @@ def init_db():
|
||||
spot_shock_pct REAL NOT NULL,
|
||||
iv_level_shift REAL NOT NULL,
|
||||
skew_tilt REAL NOT NULL,
|
||||
term_shift REAL NOT NULL,
|
||||
term_slope_shift REAL NOT NULL,
|
||||
rate_shock_bps REAL DEFAULT 0,
|
||||
dte_min INTEGER,
|
||||
dte_max INTEGER,
|
||||
manual_grid TEXT,
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
)""")
|
||||
@@ -324,6 +327,11 @@ def init_db():
|
||||
profile_json TEXT,
|
||||
has_options_data INTEGER DEFAULT 0
|
||||
)""",
|
||||
# Strategy Builder — Greeks scenario plan Phase 1 (2026-07-27)
|
||||
"ALTER TABLE strategy_scenarios RENAME COLUMN term_shift TO term_slope_shift",
|
||||
"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",
|
||||
]:
|
||||
try:
|
||||
c.execute(_sql)
|
||||
@@ -6351,8 +6359,9 @@ def save_scenario(scenario: Dict[str, Any]) -> str:
|
||||
scenario_id = scenario.get("id") or f"SCN-{uuid.uuid4().hex[:8].upper()}"
|
||||
conn = get_conn()
|
||||
conn.execute("""INSERT INTO strategy_scenarios (
|
||||
id, symbol, label, horizon_days, spot_shock_pct, iv_level_shift, skew_tilt, term_shift, manual_grid
|
||||
) VALUES (?,?,?,?,?,?,?,?,?)""", (
|
||||
id, symbol, label, horizon_days, spot_shock_pct, iv_level_shift, skew_tilt, term_slope_shift,
|
||||
rate_shock_bps, dte_min, dte_max, manual_grid
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)""", (
|
||||
scenario_id,
|
||||
scenario["symbol"],
|
||||
scenario.get("label", ""),
|
||||
@@ -6360,7 +6369,10 @@ def save_scenario(scenario: Dict[str, Any]) -> str:
|
||||
scenario["spot_shock_pct"],
|
||||
scenario["iv_level_shift"],
|
||||
scenario["skew_tilt"],
|
||||
scenario["term_shift"],
|
||||
scenario["term_slope_shift"],
|
||||
scenario.get("rate_shock_bps", 0.0),
|
||||
scenario.get("dte_min"),
|
||||
scenario.get("dte_max"),
|
||||
json.dumps(scenario.get("manual_grid") or []),
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user