Running a bot on paper
Run starts your bot in this tab against live prices and places paper orders only. Status chips explain why it is or is not trading.
On this page
Run starts your strategy against live prices. It places paper orders only, in the sandbox's own practice portfolio, the API sandbox portfolio (separate from your three paper portfolios, and not counted toward them).
What happens when you click Run#
- A quick check of the last 7 daysThe strategy is replayed over the past week, read-only, and the terminal prints about how many trades a day it would make. It warns when that is under one trade every five days, so you know not to wait for it. Set
preflight = Falseon your Strategy to skip this. - Warm-upThe last closed price bars are loaded (100 by default, set by
warmup), so your strategy has history from its first step. - The loopEvery interval (never faster than every 10 seconds) the bot reads prices and calls your
on_bar. Orders go to the practice portfolio and fill against the venue's real order book, paying the venue's fees. How paper fills work. - Until you stop itIt runs until you click Stop, or close or reload the tab. Once it has placed
max_orderspaper orders (10 by default) it keeps running but places no more orders.
While it runs, Positions and P&L on the right show the portfolio, with a This run section for the run's own orders and fills. One order can be worth at most $25,000.
Why it is or is not trading#
A strip of status chips (and the Output tab, with the history) says what the bot did on its last check. Your own reasons come from ctx.why("…") in your code; call it on every branch that skips trading.
- traded
It placed a paper order.
- strategy
Your strategy's own reason, from
ctx.why().- warming up
It is still collecting the bars it needs (“warming up: 12 of 30 bars”).
- order cap
It reached
max_ordersfor this run. It keeps running, but every further order is skipped. Stop and run again to reset the count, or raise the cap.- no liquidity
An order was rejected because the book had no bids or asks to fill it.
- market closed
An order was rejected because the market is closed, resolved or not found.
- rejected
An order was rejected for another reason; the Output tab has the venue's words.
- no prices
No current price came back for your markets. Check the market ids.
- no events yet
A strategy that waits for whale trades or linked news has not seen any since it started.
- no reason given
It placed no order and your code did not call
ctx.why(). Add one so you can see why.- rate limited
Olypse asked it to slow down. It waits and carries on.
- API error
A request failed. It tries again on the next check.
- token refused
The run's access token was refused, so it stopped. Start it again.
- resolved
One of your markets resolved and no longer trades.
- token expiring
The run's access token is close to expiring. The page renews it for you; see below.
Compare with backtest#
Once a run has placed orders or checked prices, the live run strip above the Terminal and Output tabs offers Compare with backtest. It backtests the run's own window, on the same markets, interval and starting cash, and draws the two side by side: Live run (paper fills, polled marks) and Backtest (modelled fills), as P&L from each start, with a small table of trades, P&L, fees, orders and the first and last fill. The comparison shows in the right panel's Backtest tab, or under Compare when the backtest view is open. While the bot is still running the button reads Compare after stop: the comparison waits until you stop it, because only one runner works at a time.
Expect the two to differ. They are built differently:
- Fills: the live run filled against the venue's real order book at the moment of each order. The backtest fills on the next price bar, at the modelled spread and price impact.
- Prices: the live run was valued at the prices it read at each check. The backtest replays minute bars and values open positions at the bid.
- Fees: the live run paid what the paper engine charged each fill; the backtest charges each venue's fee schedule.
- Limit orders work only in the backtest, so a strategy that rests orders behaves differently in the two.
Compare them on total value, not on realized P&L alone: the portfolio's realized P&L leaves out the fee paid on a buy until the position is sold.
The access token#
A run reads data and places paper orders with a short-lived access token, which the page renews before it expires and hands to the bot between checks. A bot that never pauses (a while True: loop at the top of the file, say) cannot take the new token, keeps the old one until it expires, and then stops. Write strategies as a Strategy class with on_bar, and the engine pauses between checks for you.