Skip to main content
An Order is an intent to trade; a Trade is the filled position that results. The Broker turns one into the other. In a backtest the broker is the SimulationBroker, which fills market orders only.

Placing an order

From inside on_update() you place orders with the strategy helpers:
Both build an instrument and forward to the broker. buy always sends a positive quantity; sell always sends a negative one - so the sign of a trade’s quantity tells you the direction. For full control (or to pass a pre-built Option / Future) call the broker directly:
is_lots=True means the quantity is a number of contracts, and the position’s unit count is quantity * contract_size. With is_lots=False the quantity is already in underlying units.

How fills work

The SimulationBroker fills every open order during the broker step of the same pulse that on_update() placed it on. The resulting Trade.open_datetime equals that pulse’s last_pulse, and the trade is priced at the market data for that pulse.
Same-pulse fills, no slippageThere is no one-pulse delay and no slippage: an order placed this pulse is filled this pulse at the price you just looked at. Only market orders exist. To model a delay, place the order on a later pulse yourself. (The Broker.create_order docstring still reads “next pulse”; the simulation broker actually fills same-pulse.)Filling at the close you just saw is the standard “trade-at-close” assumption. It is harmless for slow, path-driven strategies (monthly rolls, theta harvesting), where the underlying’s move dwarfs the entry tick; it matters more for signal-timing or higher-frequency strategies, which implicitly assume they can transact at the exact print their signal fired on. For those, place the order on the next pulse, or set fill_price= to apply a slippage haircut.

The Trade

A filled Order becomes a Trade, which the portfolio reprices every pulse. Each trade keeps per-pulse histories aligned to its datetimes: abs_pnl_history, pct_pnl_history, pulse_abs_pnl_history, price_history, notional_history, the greek histories with the underlying_price_history and iv_history they were taken against, and daily roll-ups (daily_abs_pnl_history, daily_pct_pnl_history).
Closing fills like any other actionclose(...) flags the trade; the portfolio books the close at the end of the pulse. An expired instrument is closed automatically at its last price.

Managing trades by tag

Tags set on entry are the handle for managing groups later:
Both query helpers take match_all (default False): False matches a trade with any of the tags, True requires all of them. Related: Architecture and the pulse loop · Timing · Portfolio, equity and PnL · Greeks
Last modified on November 4, 2026