Add dynamic agent registry and options mandate

Introduces a dashboard-managed agent registry (`state/agents.json`) used by nightly research and market-open execution, including support for custom/disabled agents and per-agent time budgets. Expands personas to four agents (adds Maverick), shifts pick targets to include mandatory options, and updates prompts/finalization nudges to enforce option research without hard-failing runs.

Strengthens execution safety by adding option-specific guardrails (conviction floor, premium cap, reserved option slot through trade/day/buying-power caps), validates OCC option symbols in schemas, and normalizes invalid option direction cases. The dashboard was refactored into modular views, adds an Agents admin tab, and improves live portfolio visibility with Alpaca-first data and snapshot fallback.
This commit is contained in:
Aryan Singh committed 2026-07-07 22:00:20 -05:00
1 parent b3821abd69
commit e1ac514f30
36 files changed
+1476 -294

No files matched your search

+58
View File
@@ -133,7 +133,9 @@ def test_option_sizing_by_premium():
o = orders[0]
assert o.instrument == "option" and o.multiplier == 100
assert o.contract_symbol == "AAPL260724C00295000"
# premium cap: weight = min(requested, persona cap, max_option_weight_pct=0.10)
# qty = floor(0.10 * 100000 / (7.39 * 100)) = floor(10000 / 739) = 13
assert abs(o.weight_pct - 0.10) < 1e-9
assert o.qty == 13
@@ -148,3 +150,59 @@ def test_buying_power_trim():
assert len(orders) == 1
assert orders[0].ticker == "HI"
assert any("buying power" in n for n in notes)
def _opt_pick(ticker="AAPL", conviction=0.8, weight=0.05, right="call"):
sym = f"{ticker}260724{'C' if right == 'call' else 'P'}00295000"
return Pick(
ticker=ticker, conviction=conviction, thesis="t", requested_weight_pct=weight,
instrument="option", option_right=right, contract_symbol=sym,
strike=295.0, expiry="2026-07-24",
)
def test_option_conviction_gate():
lo = _opt_pick("AAPL", conviction=0.4)
hi = _opt_pick("MSFT", conviction=0.8)
orders, notes = _plan(
[_out("nova", [lo, hi])],
{lo.contract_symbol: 3.0, hi.contract_symbol: 3.0},
)
assert {o.ticker for o in orders} == {"MSFT"}
assert any("conviction" in n and "floor" in n for n in notes)
def test_option_reserved_in_per_agent_cap():
# option is the LOWEST conviction of 5 picks with cap 4 — it must still survive
eq = [_pick(t, conviction=c) for t, c in [("A", 0.9), ("B", 0.85), ("C", 0.8), ("D", 0.75)]]
opt = _opt_pick("AAPL", conviction=0.7)
prices = {p.ticker: 100.0 for p in eq} | {opt.contract_symbol: 3.0}
orders, notes = _plan([_out("nova", [*eq, opt])], prices)
assert len(orders) == 4
assert any(o.instrument == "option" for o in orders)
assert any("reserved option slot" in n for n in notes)
def test_option_reserved_in_day_cap():
# day cap 2, option ranks 3rd by conviction -> swapped back in
eq = [_pick(t, conviction=c) for t, c in [("A", 0.9), ("B", 0.85)]]
opt = _opt_pick("AAPL", conviction=0.7)
prices = {p.ticker: 100.0 for p in eq} | {opt.contract_symbol: 3.0}
orders, notes = _plan(
[_out("nova", [*eq, opt])], prices,
risk=RiskConfig(max_trades_per_day=2, max_trades_per_agent=5),
)
assert len(orders) == 2
assert any(o.instrument == "option" for o in orders)
assert any("reserved option" in n for n in notes)
def test_option_survives_buying_power_trim():
# option has lowest conviction but equities get dropped first
eq = [_pick("BIG", conviction=0.9, weight=0.10)]
opt = _opt_pick("AAPL", conviction=0.7, weight=0.05)
prices = {"BIG": 200.0, opt.contract_symbol: 5.0}
# equity order = 50 * 200 = 10k; option = qty 10 * 5 * 100 = 5k; BP only fits the option
orders, notes = _plan([_out("nova", [*eq, opt])], prices, buying_power=6_000.0)
assert len(orders) == 1
assert orders[0].instrument == "option"