Welcome to Deflow
Deflow is an autonomous options trading desk. Four specialised agents observe the market, structure defined-risk option spreads, audit them adversarially and route them to a live Alpaca paper account - under a deterministic risk gate that no language model can talk its way past.
The AI is not a chat feature bolted onto a trading bot. The agents run the desk end to end on a five-minute cycle, and refusing to trade is a first-class output: roughly half of all symbol-cycles end with the desk declining, on the record, with the stage and reason attached. Every decision is written to a hash-chained ledger anyone can verify.
- • Measured, not vibes - implied volatility against a jump-robust forecast of realised volatility
- • Bounded, always - every structure has a defined maximum loss before it is ever proposed
- • Checkable, forever - a tamper-evident ledger and the broker's own marks on the dashboard
Where everything lives
Qwen/Qwen2.5-72B-Instruct via Featherless2026-09-01How it works
Every five minutes during US market hours the desk runs one cycle over its universe (SPY, QQQ, IWM, AAPL, MSFT, NVDA, AMD, TSLA):
analyse → structure → reason → audit → gate → route → reconcileThe Analyst measures each name and refuses anything without a measured edge. The Structurer builds candidate spreads from the live chain. The reasoning model picks among them - among them only; it cannot invent a trade. The Auditor attacks the choice with Monte Carlo and real transaction costs. The gate rules. The Executor routes. And on the next cycle the desk reconciles: an accepted order is not a fill, and the book only changes when the broker confirms one.
The four agents
The edge: variance premium
Option prices embed a forecast of volatility. Deflow builds its own - bipower variation, a jump-robust estimator that a single earnings gap can't distort - and trades only the gap between the two, in either direction:
The desk also reads the IV term structure for priced-in catalysts: an inverted curve means the market is paying up for an event, and short-dated premium selling stands down around it.
The deterministic gate
Twelve circuit breakers, pure standard-library Python, zero LLM involvement, microseconds per evaluation. All twelve always run - no short-circuiting - and the gate runs twice: once at approval, again immediately before the order leaves. It fails closed, and it sizes trades down before it vetoes them.
01 defined_risk_structureevery structure must have a bounded max loss02 max_loss_2pctmax loss of the trade ≤ 2% of account equity03 trade_delta_boundnet delta of the structure within ±0.3504 probability_of_profitcredit: ≥ 65% win rate · debit: ≥ 30% plus positive expectancy05 aggregate_risk_6pctcapital at risk across the whole book ≤ 6% after the fill06 symbol_concentration_3pctrisk in any one underlying ≤ 3%07 portfolio_delta_boundbook net delta within ±1.2 after the fill08 max_open_positionsat most 6 open structures09 dte_window7 to 60 days to expiry10 payoff_qualitycredit ≥ 15% of spread width · debit reward/risk ≥ 0.811 daily_drawdown_killswitchtrading halts at −3% on the day12 vega_ceilingbook |vega| ≤ 2.5 per $1,000 of equityTry it yourself: the dashboard's risk-gate panel submits a deliberately bad trade - a naked call - and shows which breakers trip, live, with the gate's own wording.
Order & exit lifecycle
Submitted is not filled. Entries and exits both live as working orders until the broker confirms a fill; only then does the book change, at the price actually given. A stale order is cancelled - and dropped only when the broker confirms the cancel, because a cancel acknowledgement is a request, not an outcome, and an order can still fill while it is pending.
Exits are priced from the position's current mark, never its entry price, with the concession always against the desk. Positions carry a profit target that tightens as expiry approaches, a stop at 50% of max loss, and a hard exit at 3 days to expiry. A mark that falls outside the structure's own payoff bounds is flagged suspect and cannot fire an exit - bad quote data defers one cycle rather than realising a phantom loss.
Decision ledger
Every event the desk produces - analyst views, proposals, audits, gate verdicts, orders, fills, exits, refusals - is appended to a ledger where each entry carries the SHA-256 of the one before it. Altering or deleting any historical record breaks the chain from that point forward, visibly and permanently.
GET /api/ledger/verifyRefusals
Most systems only show what they did. Deflow's most informative output is what it declined to do: every refusal is recorded with the stage that made it - the analyst saw no edge, the model abstained, the auditor objected fatally, or the gate vetoed - and its exact reason. The dashboard's refusals panel is the desk's actual behaviour, not an absence of it.
Self-hosting & running
git clone https://github.com/mrnetwork0001/Deflow.git && cd Deflow python -m venv .venv && .venv/bin/pip install -r requirements.txt cp .env.example .env # add your Alpaca + Featherless keys .venv/bin/python main.py
DEFLOW_DRY_RUN=truefull pipeline, no orders submittedDEFLOW_PORTAPI + dashboard port (default 8000)DEFLOW_CYCLE_SECONDScycle cadence (default 300)One command brings up the desk, the API and the dashboard: the frontend is a static export served by the same FastAPI process, so there is no Node runtime in production.
HTTP API
Read-only observability plus two deliberate write endpoints. There is no endpoint that places an order directly - orders exist only as the output of a full pipeline that has cleared the gate.
GET /api/statuseverything the dashboard shows: performance, market state, working ordersGET /api/performanceequity and P&L on the broker's marks, with the desk's mid-marks labelledGET /api/positionsopen and closed structuresGET /api/refusalsevery trade the desk declined, attributed to the stage that said noGET /api/ledgerthe hash-chained decision ledger, filterable by eventGET /api/ledger/verifyre-derives the chain and reports the first break, if anyGET /api/pnl-card?date=one trading day summarised for a shareable cardGET /api/streamserver-sent events: the decision stream, livePOST /api/cyclerun one full trading cycle nowPOST /api/risk/evaluatesubmit a hypothetical trade; the twelve breakers rule on it