tradefloor is a stock market simulator on which strategies can run, providing a Rust core and a Python API.
Main capabilities: given a seed and a list of companies, it advances the market forward, including prices, a limit order book, trades, and a daily-changing economic environment. Your orders match against order book depth, so your trading moves prices. Because every price is computed by it, you can use it to answer questions that real market data cannot answer: what would have happened if you had traded differently, and what caused a certain move.
Counterfactuals and explanation: you can fork a running market, change only one thing in a branch (a rate hike, a liquidity crisis, a different agent), and then measure where the two branches begin to diverge. engine.truth() breaks down the gap between price and the model's fair value into twelve factors, and engine.explain(ticker, day) decomposes the change in trade price.
Usage: wheels are installable for Linux, macOS, and Windows, suitable for CPython 3.11+, with no dependencies. The same engine is also available as a Rust crate (cargo add tradefloor). Optional add-ons include an MCP server (tradefloor[mcp]), Arrow output (tradefloor[arrow]), a Gymnasium environment (tradefloor[rl]), and one add-on per agent framework. Documentation is at https://docs.tradefloor.dev。
Evaluation and ranking: the result of a single random market reflects both the seed and the strategy. tf.rank runs multiple seeds and compares strategies using a paired sign test. Add tf.baselines.reference_agents() to the participants, and tf.versus_buy_and_hold(scores) can compare each score with buy-and-hold on the same market.
Agent interface: a Python agent is any object that has act(obs) and returns orders—a number of shares for a market order, or tf.Limit(quantity, price), tf.Cancel(). It sees a read-only view of the market and its own portfolio, and obs.history holds the daily bar for each instrument.
MCP and scenarios: tradefloor-mcp speaks MCP over stdio, and tradefloor mcp starts the same server. Strategies, markets, and scenarios are all data, so tool parameters cannot reach code. Scenario files record changes to the market and its assumptions, with each change kept separate for the fields the engine reads and the actual effect. By default no other traders react to you, so there are no liquidity spirals or predatory trading; fill modes add background traders.
Reproducibility: the same seed gives the same market on every platform. tradefloor ships with its own exp, log, pow, sin, and cos, so the system math library cannot change the results. Published presets never change, and a market with no agent orders replays exactly on named presets in later versions. To let others rerun results, publish their RunManifest; tf.evaluate and tf.rank do not write a manifest, so published scores must be rerun to be verified.
Applicable scenarios and limitations: it does not predict the market impact of wars, elections, oil shocks, or recessions—you state assumptions, and it measures agent behavior under those assumptions. Model calibration has clear boundaries, such as one year being a certified horizon, two years rated on a two-year panel, and longer runs rated only on long-term standards; driven scenarios move prices by about one-half to four-fifths of real magnitude; below a 65-minute step size is uncalibrated; by default there are no commissions, no borrow fees, no stop orders, and uninvested cash earns no interest (unless cash_interest=True is passed). In one round of tf.evaluate or tf.rank, agents run sequentially in one Python process on one seed, and agents not written should pass through MCP servers run in separate processes.
License: MIT OR Apache-2.0, either one.