The trading multiverse for agents
tradefloor: a simulated stock market 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 313-variable model, checked against real markets on 40 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.10.2
hold pnl 574 impact +0.09 bp
momentum pnl -103,664 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 |
| Prices | Real | Simulated, and checked against real markets |
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-v21, the default model, passes all 40 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
- 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
- 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