Free, MIT-licensed, runs on your machine. For your own account only.
Agentic Trading Lab
An AI research agent for rules-based trading that keeps score honestly. It backtests published momentum and trend strategies on a century of US data and on crypto. It charges for every idea it tries, and it lets you paper trade only what survives. In its first full study it refused all three of its own best backtests.
Who it is for
People who want to automate their own brokerage account with rules instead of hunches, and who have seen enough backtests to distrust them. You might be a developer with a Robinhood or Alpaca account, or a self-directed investor wondering whether a momentum rule is worth the trouble. You can read Python, or are willing to run a few commands.
The usual problem: you try twenty variations and keep the one with the best chart. Five years of live trading later, it turns out the chart was the twentieth roll of a die. This tool keeps track of the die.
What the first study found
We tuned on data up to 1999 and judged on 2000 to September 2026, a period no candidate was allowed to see. Costs were 10 bps per unit of turnover for equities and 50 bps for crypto.
The best of 98 rules (12-month dual momentum, top 2) trailed simple equal weight out of sample. Its worst drawdown was −27.9% against −48.1%. Overfitting probability 0.50. Not promoted.
The winner (12-month cross-sectional momentum, top 5, 10% vol target) beat equal weight. Alpha 3.5%/yr, t = 2.09, and a −21.8% drawdown against −52.7%. But its Deflated Sharpe was 0.890, under the 0.95 bar. Not promoted.
A 20-day moving-average rule looked superb from 2016 to 2021 and lost money from 2022 on after costs. Overfitting probability 0.81 flagged it; Deflated Sharpe alone did not. Not promoted.
Two results held up across both universes. Trend rules roughly halved the worst drawdowns. And the slow 200-day trend rule on crypto kept a Sharpe of 0.70 at 50 bps, where the fast one went negative. Full tables: results/REPORT.md; every number is in results/study.json.
How the agent works
- Propose. It draws configurations from a bounded search space of eight published rules. By default it walks a grid; with your own Anthropic key, a Claude model picks the order instead. Either way, nothing outside the space is accepted.
- Backtest in-sample only with drifting weights, turnover costs, borrowing costs and an optional volatility target. A test checks that changing future returns never changes past decisions.
- Charge for the search. The Deflated Sharpe Ratio (Bailey and López de Prado, 2014) raises the bar with each trial. The Probability of Backtest Overfitting (Bailey, Borwein, López de Prado and Zhu, 2017) asks whether in-sample winners keep winning on unseen halves of the data.
- Look at the holdout once, with a stationary-bootstrap interval for the Sharpe ratio and alpha against equal weight (Newey-West t).
- Gate. A strategy can be promoted only if DSR ≥ 0.95, PBO ≤ 0.5 and its holdout Sharpe is positive with at least 90% confidence.
- Trade carefully. Dry run by default. Paper trading comes next. Live trading needs an explicit flag, an exact confirmation phrase, no kill-switch file, a gated strategy and per-order limits.
Try it
git clone --depth 1 https://github.com/Duncan-Haywood/oss-monorepo
cd oss-monorepo/ventures/agentic-trading-lab
pip install -e . # numpy only; add [robinhood] for crypto signing
tradelab study # rerun the whole study (downloads data, a few minutes)
tradelab research --universe ind49 --out report.json
tradelab signal --strategy sma_trend --param lookback=10
tradelab rebalance --report report.json # dry run: prints orders
tradelab rebalance --report report.json --execute # local paper account
tradelab rebalance --broker alpaca --report report.json --execute # Alpaca paper (your keys)
Brokers
| Broker | Assets | Paper mode | How |
|---|---|---|---|
| Local paper | anything | yes (default) | JSON file on your disk |
| Alpaca | US stocks and ETFs | yes | official Trading API, your keys |
| Robinhood | crypto only | no | official Crypto Trading API, your Ed25519 key |
Robinhood publishes no stock-trading API. Unofficial libraries that drive the app's private endpoints are not supported. Not affiliated with, or endorsed by, Robinhood, Alpaca, Coinbase or Anthropic.
When to use something else
If you want hands-off diversified investing, a low-cost index fund does that with no code. If you need intraday data, options or a full event-driven simulator, use a dedicated backtesting framework. If you want to invest other people's money, you need a lawyer and a registration first, not this repository. Every rebalance in a taxable account is a taxable sale; for crypto lots, the crypto cost basis calculator works out the gains to report.
Questions
Can I use this with Robinhood?
For crypto, yes: it signs requests to Robinhood's official Crypto Trading API with keys you create. Robinhood publishes no API for stocks, so for automated stock and ETF trading it supports Alpaca, which has free paper trading.
Can I run a fund with it?
No. It is built for one person trading their own account. Managing or pooling other people's money is regulated (investment adviser, investment company and securities offering rules in the US); see LEGAL.md and talk to a securities lawyer first.
Did the agent find a strategy that beats the market?
Not one that passed its own gate. On 2000 to 2026 data no rule it picked had been allowed to see, its winners either matched equal weight with lower drawdowns or, in crypto, lost money after costs. The full numbers are in results/REPORT.md.
What stops it from overfitting?
Every configuration it tries is logged and charged for: the Deflated Sharpe Ratio raises the bar with each trial, the Probability of Backtest Overfitting checks whether in-sample winners keep winning out of sample, and the 2000 onward holdout is looked at once.
Does it trade real money by default?
No. It prints orders in a dry run. Paper trading needs --execute. Live trading also needs --live, an exact confirmation phrase in an environment variable, no kill-switch file and a strategy that passed the research gate.
Where does the data come from?
US industry portfolios and the risk-free rate from the Kenneth R. French Data Library (built from CRSP, July 1926 onward), and daily BTC-USD and ETH-USD candles from Coinbase's public API. It downloads them on your machine and does not redistribute them.