Skip to main content
pulse-core runs a backtest as a loop over timestamps. Each timestamp is a pulse. On every pulse your strategy gets a chance to look at the market and place orders, the broker fills any orders, and the portfolio marks everything to market. The pieces below are wired together for you by run_sequentially; you normally only write a Strategy.

The components

A Strategy reaches all of these through self: self.datafeed, self.resolver, self.broker, self.portfolio, self.pulse_index, plus self.last_pulse and self.current_equity. DataFeed and ResolverRegistry come from pulse-data-components (pdc), the sibling package that owns the data layer. pulse-core re-exports them, so from pulse import DataFeed and from pulse_data_components import DataFeed are the same class; the engine modules themselves live under pulse.core (pulse.core.atm, pulse.core.strategy, pulse.core.trade, …) and are re-exported from pulse too.

One pulse, step by step

Strategy.pulse() does the same five steps every time:
  1. Advance the clock. PulseIndex moves to the next timestamp; it becomes self.last_pulse.
  2. Run your logic. on_update() reads data as of self.last_pulse and places orders with self.buy(...) / self.sell(...) / self.broker.create_order(...).
  3. Fill orders. The broker turns every open order into a trade at the current pulse.
  4. Book the trades. New trades are added to the portfolio; all open trades are repriced. A contract missing from this pulse’s snapshot books a flat pulse and logs a warning rather than stopping the run (see DataFeed).
  5. Update the books. Equity, fees and greeks are recomputed for this pulse.
How fills and entry pricing workThe simulation broker uses a simple, idealized fill model:
  • Fills are immediate and frictionless. An order fills on the same pulse you place it, at the price you saw in on_update() - no delay, no slippage, no partial fills. Entries are therefore slightly optimistic, since you always trade at the observed price.
  • Fine for slow strategies, watch it for timing. 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 to model “decide now, fill next.”
  • A position opens flat. On the pulse it opens, a trade is marked at its own fill price, so it carries no PnL until the next pulse.
  • The entry price is yours to set. Pass fill_price= to self.buy(...), self.sell(...), or self.broker.create_order(...) to trade at a price you choose - a fixed level, or the observed price adjusted for slippage - rather than the settlement price.
Because on_update() only ever sees data as of self.last_pulse, a backtest cannot look into the future - you can only act on what was knowable at the time. See DataFeed and market data for how that “as of” rule is enforced.

Running a backtest

run_sequentially builds the whole environment from defaults and runs your strategy:
run_sequentially takes a list of strategies, so one call runs one strategy or a whole parameter sweep. It accepts the pieces you want to override - datetimes, datafeed, resolver, fee_calculator - and fills the rest with local defaults built from PDC_PATH. To build the environment explicitly (for example to share one datafeed across runs) use EnvironmentBuilder. Without datetimes, the calendar is the underlying’s own settlement dates, intersected across its instrument families (available_settlements(uid, unified=True)) and across underlyings. See Timing. Related: Timing · DataFeed and market data · Orders, trades and the broker · Portfolio, equity and PnL
Last modified on November 4, 2026