Running a backtest
Backtest switches the sandbox to the backtest view: pick the window, cash, venue, data, bars and costs, then replay your strategy on past prices.
On this page
A backtest replays your strategy over past prices as if it had been running then, with modelled fills and costs, and reports what it would have made or lost. It reads data only and places no orders.
Click Backtest in the top bar (or press ⌘ ⇧ B, Ctrl Shift B on Windows). The page switches to the backtest view: the setup bar on top, the result under it. While it is open the top-bar button reads Back to code; that button, Back to code at the top left of the view and the same shortcut all return to the editor. The view also has a Saved runs button and an Assistant button, which opens the sandbox assistant beside the results. In the backtest view the top bar has no Unit tests button and Run (a paper bot) is a plain button; running a bot or the tests switches back to the code view, where their output is.
Backtest is off when nothing is open, or when the open file is not a strategy (a strategy file ends with olypse.main(YourStrategy)). Its tooltip says which. Hello — read markets is such a file: it can only run.
The setup bar#
- Window (UTC)
Pick a preset (7 days, 30 days, 92 days (max) or Research window), or click the first and then the last day on the calendar. Both days count: the window runs from 00:00 UTC on the first day to 00:00 UTC after the last. One backtest covers at most 92 days, up to the last full UTC day.
- Starting cash
The practice cash the replay starts with, from $1 to $10,000,000.
- Venue
Which of the strategy's markets to replay. The list is read before the run from
marketsunder[strategy]inconfig.toml, from the market ids a single file names, or from the last run, and the hint under the box says which (for example “2 markets from config.toml”). With markets on both venues you can pick All venues, Kalshi or Polymarket (each with its count); with one venue it reads, for example, “Kalshi only”. Choosing one venue sends that venue's markets as the Markets setting: a line under the bar lists them (“Runs on … (the Markets setting …)”), your strategy sees only them inself.marketsandctx.marketsfromon_starton, and the result carries a MARKETS SETTING warning. State your code built in__init__from its own list does not see the change. All venues sends no Markets setting.- Data
Venue history (the venues' own minute prices, any dates) or Research dataset (Olypse's frozen recording of 9 August to 21 September 2026, with real quotes). Choosing the research dataset moves the window inside its dates. See below.
- Bars
The price bar size the replay steps through: 1m, 5m, 15m or 1h, or Strategy's own (your strategy's
interval). Longer bars replay faster but see fewer moves, and a resting order can fill more shares on a longer bar (see below).
Costs and fills#
Costs and fills opens the advanced settings, closed by default. Polymarket's half-spread and the price impact were fitted to real fills; change the settings to see how much the result depends on them. An empty box restores the default.
- Half-spread, Kalshi (¢) and Half-spread, Polymarket (¢): half the gap between the bid and the ask, which a market order pays over the midpoint. It is used only where the venue has no quote: on Kalshi, a bar without one; on Polymarket, every bar, scaled up on thin markets.
- Slippage (¢): an extra cost on every fill.
- Order delay (s): the time from placing an order until it can fill (2 seconds by default).
- Resting orders fill: The data's default (when touched on venue history, when traded through on the research dataset), When touched or When traded through.
- Venue fees: on (the venues' current schedules) or off.
- Comparison lines: also replay with harsher fills and nearby values of the settings in
config.toml, for the extra lines on the equity chart. Each line is one more replay, so the run takes longer.
Then click Run backtest. While it runs, the bar reads “Backtesting” with a percentage and a Stop button, and the result area shows a progress bar with the engine's progress note. On a phone, once a result or an error shows, the setup folds to one line (the dates, the days and the cash) with Edit setup and Run again. Every finished backtest is saved to your account: up to 100, with 50 MB of results in total, and at most 30 saved an hour. Past a limit the result still shows, with a note that starts “Not saved:” and names the limit; delete old saved runs, or wait for the hour to pass. Reading the results.
The two data sources#
| What | Venue history | Research dataset |
|---|---|---|
| Dates | Any window of up to 92 days | 9 August to 21 September 2026 only |
| Prices | Minute bars; Kalshi with bid and ask, Polymarket price only (its spread is estimated) | Minute bars built from real bid/ask quotes on both venues |
| Market orders fill | On the next bar, even on a wide or fake book (flagged WIDE / FAKE BOOK afterwards). A Kalshi order meeting an empty side of the book is not filled | 2 seconds after the order, at the valid quote then (a bid above 0, an ask below 100¢, a spread of 20¢ or less), or not at all |
| Resting (limit) orders fill | When the bar's price touches the limit (optimistic), up to about 1,000 shares (Kalshi) or 1,500 (Polymarket) for each minute of the bar that had a price: up to 5, 15 or 60 times that on 5m, 15m or 1h bars | Only when trades or quotes go strictly through the limit (conservative), at most 25 shares per qualifying trade or bar |
| Results arrive | At the venue's resolution time | When Olypse first saw the result |
How fills and costs are modelled#
- Buys pay the ask and sells get the bid. Where a venue publishes no quote, the spread is estimated, wider on thin markets.
- On venue history a market order always fills on the next bar, even when the book is empty on one side, wider than 20¢ or a “fake 50¢ book” (except a Kalshi order meeting an empty side, which is not filled). Such fills are flagged WIDE / FAKE BOOK: read them as prices nobody could really trade at.
- On the research dataset a market order needs a real quote: a bid above 0, an ask below 100¢ and a spread of 20¢ or less. Otherwise it is not filled.
- Large orders cost more: a price impact grows with the order's size, and an order much larger than the usual book is filled in parts and the rest dropped.
- Resting orders on venue history fill whenever a bar's price touches the limit, up to about 1,000 shares (Kalshi) or 1,500 (Polymarket) for each minute of the bar that had a price, so a 1h bar can fill up to 60 times as many as a 1m bar. This is an optimistic rule, because Olypse cannot know your place in the queue.
- Resting orders on the research dataset fill only when a trade or quote goes strictly through the limit, at most 25 shares per qualifying trade or bar.
- Kalshi fees: takers pay 0.07 × the series' multiplier × contracts × price × (1 − price), rounded up to $0.000001. A few series (for example NFL games) also charge resting orders 0.0175 × the same.
- Polymarket fees: takers pay each market's own fee schedule, typically a rate of 0.04 to 0.07 × contracts × price × (1 − price). Many markets charge nothing, and resting orders never pay.
- Open positions at the end are valued at the bid, what a sale would fetch.
When a backtest fails#
A failed backtest shows a card in the backtest view: what went wrong, the error's own first line, How to fix it, and the buttons Fix with assistant (for an error in your code), Run again and Dismiss (which brings back the previous result). The run log is under it. The common ones:
| What it says | What to do |
|---|---|
| The strategy lists no market to test | Add markets = ["kalshi:…"] under [strategy] in config.toml. The assistant can search for a ticker. |
| This file is not a strategy, so it cannot be backtested | Open a file that ends with olypse.main(YourStrategy), such as the project's strategy.py. Hello — read markets is not one: it only runs. |
| A KeyError on a market after you picked one venue | Your code keeps state per market from its own list. Build it in on_start from ctx.markets, or set Venue back to All venues. |
| There are no prices for a market in this window | The id may be wrong or the market had closed. Check it with the assistant's market search, or pick dates when it traded. |
| Whale trades cut off | The window has more whale trades than one backtest loads. Shorten it to the hours you care about. |
| The window is longer than 92 days, or outside the research dataset | Pick 92 days or fewer. For the research dataset, pick dates inside 9 August to 21 September 2026 (the Research window preset), or switch Data to venue history. |
| Too many markets for one backtest | A backtest takes at most 100 markets: pick one venue, or trim the list under [strategy] in config.toml. |
| Too many markets for this window | A backtest takes at most 2,300 market-days (markets × days in the window: 76 markets over 30 days, 25 over 92, 100 over 23): use fewer markets or a shorter window. |
| The sandbox's key was refused, or the sandbox was asked to slow down | Run it again: each run gets a fresh key. If it was asked to slow down, wait a minute or shorten the window. |
| Something else is running | Stop the running bot or backtest with Stop, then run the backtest again. |
| numpy or pandas not found | Only the Python standard library is available. Ask the assistant to rewrite that part without it. |
| A syntax error or an undefined name | Code check lists the line with a red mark. Fix with assistant sends the error to the assistant's Fix mode. |