An autonomous momentum + options trading system where a risk agent has hard veto power over every order — and the execution agent is structurally incapable of bypassing it.
Momentum investing works — but running it with real discipline means position sizing, earnings-drift detection, options-overlay collateral math, risk vetoes, and exit timing, done consistently, every day. So it runs as a pipeline of five specialized agents, each with one narrow job, plus an optional sixth.
Scores every liquid stock on momentum and reads real SEC earnings filings for post-earnings drift signals.
Turns the snapshot into buy/trim/exit proposals and options-spread candidates. Rules only — no risk checks, no sizing.
Can flag a name as risky. Cannot invent or size a trade. Abstains entirely without an API key — the pipeline runs unchanged.
Veto authority. Position limits, per-name caps, and the single-pot capital rule — no dollar spent twice.
The only agent that talks to the broker. Refuses anything not approved — it raises an exception rather than submitting.
Reports P&L, exposure, and reconciles the book against the broker after every cycle.
Money is never spent twice — portfolio.py enforces it with runtime assertions that raise, not logic that could silently drift.
Top 6 stocks by a vol-adjusted momentum score (12-month minus last month, 3-month, trend, relative strength vs. SPY), equal-weighted. Goes to 100% cash if SPY is below its 200-day moving average.
Buys stocks the day after a confirmed earnings beat, using real SEC EDGAR filing data — not simulated. Two independent signals (SUE score + volume-confirmed gap) must both agree.
Sells 20-delta put credit spreads on stocks the other sleeves already own. Closes at 50% of max profit, or unconditionally within 5 days of expiry to avoid assignment.
2011–2026, mechanically screened. The test period was run exactly once.
| Period | Return | Win Rate | Profit Factor | Max DD | Sharpe | Alpha (ann) |
|---|---|---|---|---|---|---|
| Train 2011–18 | +360.1% | 95.2% | 2.12 | −15.3% | 0.95 | +12.0% |
| Validate 2019–21 | +221.7% | 92.7% | 1.20 | −47.0% | 1.17 | +32.0% |
| Test 2022–26 | +1072.1% | 94.3% | 2.47 | −30.6% | 1.88 | +64.5% |
Test period was run once and never tuned on.
The headline numbers use a 39-name universe hand-picked in 2026. The identical strategy was rerun on a mechanically screened, survivorship-bias-free 951-name universe — including delistings and bankruptcies the hand-picked list omits.
Not just a backtest — a real, verifiable trading bug found and fixed on paper capital.
Momentum core deployed live — bought 6 stocks (CNC, JAZZ, TD, UTHR, VLO, WBD) equal-weight. Clean fill.
3 option spread orders submitted — all three expired unfilled. Root cause: the limit price was calculated from a Black-Scholes model's own strikes and expiry, not the real listed contracts — every order asked for more credit than the spread could pay.
Diagnosed and fixed 4 independent defects. Also found the agents could open a spread but had no path to close one — built a leg-pairing module that reconstructs an open spread directly from the broker's own position data.
The TD 115/105 put credit spread filled. Sold the 115 put at $0.95, bought the 105 put at $0.40 — net credit $0.55/share ($110 total) on 2 contracts. Real premium collected.
The 12:45pm and 3:45pm scheduled cycles both correctly recognized the open position, did not duplicate it, and correctly left it alone — the full open → hold → close lifecycle running unattended, on real fills, not a backtest.
Paper trading only, by construction — no live-trading code path exists.
4 independent gates must ALL pass: env flag, paper API endpoint, account number prefix, and a SHA-256 hash checked against a tracked source allowlist — not just a .env file.
Enforced by runtime assertions, not logic that could silently drift. An earlier bug where this wasn't enforced inflated a 15-year backtest CAGR by ~8 percentage points before it was caught.
Including tests that pin the capital invariants, and tests that specifically prove the Execution Agent raises an exception if handed an unapproved order.
Runs 3× per weekday with zero human intervention — but a run that finds nothing to do is safe by default: if the market is closed, every proposal is automatically rejected.
I built this to survive rigorous backtesting, not just produce a good-looking curve. Parameters were fit only on 2011–2018, checked once on 2019–2021, and the 2022–2026 test window was run exactly once — never touched again to adjust a threshold or a gate. Across that out-of-sample test period: +1072% return, a 2.47 profit factor, a 1.88 annualized Sharpe, and +64.5%/year alpha versus SPY, on a mechanically screened universe rather than a handful of cherry-picked tickers.
The earnings-drift sleeve is backtested on real data, not a simulated distribution: it pulls actual quarterly EPS and filing dates from SEC EDGAR's XBRL API, and only counts a signal when two independent measures — a SUE score and a volume-confirmed price gap — both agree.
Capital accounting is enforced structurally, not just in spirit. One pot of money, shared by the momentum core, the earnings-drift sleeve, and the options overlay, with runtime assertions that raise the moment a dollar would be spent twice — not application logic that could silently drift out of sync.
The same discipline carries into live trading. A risk agent has hard veto authority over every order, checking position limits, per-name concentration, and the capital rule before anything reaches the broker. The execution agent is the only component allowed to talk to Alpaca, and it structurally cannot submit anything the risk agent didn't approve — it raises rather than executes. All of this is pinned by 64 automated tests, including ones that specifically prove that refusal behavior. And it isn't just a backtest anymore — the system is live on Alpaca paper trading, running autonomously three times a day, and has already sold a real put credit spread and collected the premium.
Momentum + Options Agents — Agentic Hackathon, Alpaca Paper Trading