The trading multiverse for agents
tradefloor: a stock market for testing agents
A simulated market of stocks, futures and options for testing trading strategies and AI agents. Fork one market into many futures and see what each change does. Runs are deterministic and repeat exactly. A 449-variable model, checked against real markets on 190 pre-registered measurements. Built for agents, bots and trading algorithms, whose orders move the prices they trade at.
Your first market in Python
The script runs thirty trading days of five generated companies and scores buy-and-hold and momentum on two copies of one market. Then it rebuilds the market from its inputs and checks that it matches the first run. The whole script takes about a second.
import tradefloor as tf
# five generated companies in one simulated market
universe = tf.Universe.random(5, seed=7)
engine = tf.Engine(seed=776644, universe=universe)
engine.run_days(30) # thirty trading days
# two strategies, each on its own copy of that market.
# Their orders fill against the book and move the price.
cards = tf.evaluate({"hold": tf.baselines.BuyAndHold(),
"momentum": tf.baselines.Momentum()},
seed=776644, universe=universe, days=30)
for name, card in cards.items():
print(f"{name:9} pnl {card.pnl:>9,.0f}",
f"impact {card.impact_bps:+.2f} bp")
# the same inputs rebuild the same market, bit for bit
again = tf.Engine(seed=776644, universe=universe)
again.run_days(30)
print(again.state_hash() == engine.state_hash())
Output on tradefloor 0.11.0
hold pnl 6,600 impact +0.09 bp
momentum pnl -100,273 impact +1.12 bp
TrueThe trouble with backtests
A backtest tells you how a strategy would have done on prices that already happened. It can't tell you what happens when your orders are big enough to move the price, or how the strategy does in a thousand other years. If an AI agent is making the trades, its model may already have seen that history in training.
| Backtest | tradefloor | |
|---|---|---|
| Your orders | Fill at the recorded price, as if you weren't there | Hit an order book and move the price |
| Markets to test on | One, the one that happened | As many as you want, one per seed |
| What if rates had risen? | You can't rerun history | Fork the market and find out |
| Crashes | A handful, and you know how they ended | A rate shock or a recession on any market, whenever you want |
| Luck | One run, and a good result might be luck | Run two strategies on the same seeds and count who wins |
| AI agents | The model may have seen the data in training | Every market is new |
| Futures and options | Separate data, bought and lined up with the stock prices | Listed beside the stocks and priced from the same economy |
| Prices | Real | Simulated, and checked against real markets |
Futures and options with margin
On the default model, pt-v22, contracts are listed beside the stocks. An agent trades them by symbol in whole contracts, as it trades a stock, and the account is margined at every close the way a broker margins it.
Futures
Index futures with a night session between the close and the next open, policy-rate and term-rate futures priced from the market's own forecast of rates, and monthly oil futures. Each one's gain or loss is paid in cash at every close.
Options on every company
Calls and puts at 100 shares a contract, with expiries from a few weeks to a year, quoted by a dealer with open interest, at-the-money volatility and skew. Exercise one at a close, or get assigned on one you sold.
Margin like a broker's
Margin is set at every close, and an order the account can't carry is refused. A close under the maintenance level brings a margin call. If equity isn't back at the initial margin by the next open, the contracts are closed at the market.
The 2008 recession
recession_2008runs the 2007-09 recession, dated on the NBER's phases, on any market, beside the replays of 2008 and 2020.
Common workflows
Test a strategy
Write a strategy as a Python class with an
actmethod.tf.rankruns it beside buy-and-hold on many seeds and counts, seed by seed, which one did better.Test an AI agent
Adapters for the OpenAI Agents SDK, PydanticAI, LangGraph and FinRobot pass the model each observation and send its orders. Record its answers and the run replays without calling the model. CrewAI agents connect through the local MCP server.
Fork a market
Copy a running market, change one input in one copy, such as a rate shock, and run both forward. The copies share their past bit for bit. Any later difference comes from the change.
Rerun a result
A run depends on its companies, seed, preset, package version, any scenario and the orders sent into it. Save them in a manifest and someone else can rebuild the same market on the same release.
See it working
Use Cases
Six worked examples, one for each role. An AI agent team decides which prompt to ship, a bot builder finds out the bot has no edge before going live, and a risk team learns which crises break its drawdown limit.
The Model
pt-v22, the default model, passes all 190 pre-registered checks against real markets. You can watch its variables react as a liquidity crisis hits and read what it doesn't capture yet.
Open source and hosted
Open source
Available nowThe Python library and the Rust crate, under MIT or Apache-2.0. It runs on your machine with no account and no usage limits.
- Markets, forks and packaged scenarios
- Futures, options and margin like a broker's
- Scoring and ranking across seeds
- LLM adapters and a local MCP server
- Reproducible runs and manifests
- A Gymnasium environment for reinforcement learning
Hosted app
in betaThe same simulator on a server, in beta with a limited free plan. Paid plans with larger limits are coming.
- Saved markets an agent can come back to
- Futures and options in the Simulator
- An MCP endpoint, an HTTP API and an API shaped like Alpaca's
- Python strategies run in a sandbox
- Evaluation suites for teams and teaching