Skip to main content

Orders

An Order represents a trading instruction that specifies the intent to buy or sell a financial instrument. Orders contain essential information including:
  • Instrument: The specific financial instrument to trade (options, futures, etc.)
  • Quantity: The number of contracts (positive for buy orders, negative for sell orders)
  • Timing: When the order was created and when it should be executed
  • Execution Details: Information about how and when the order was filled
Orders serve as the bridge between strategy logic and actual trade execution in the backtesting environment. Currently, Pulse only supports market orders, which are executed immediately at the close price. To prevent forward-looking bias, the first day PnL of a Trade is set to zero. Let’s start by importing the necessary components and exploring how to create and work with orders in Pulse.
Output

Creating an Order

Now let’s create an order to buy 10 contracts of our call option. Note that quantity is positive for buy orders and negative for sell orders:
Output
You won’t need to create an order manually, as Its the job of the Broker. Broker has few helper methods to create orders, which will be covered in the next section.

Order Properties

Each order automatically gets a unique identifier and contains references to all the trading details: Instruments are value objects with no display helpers of their own: use instrument.id ("U|c|strike|expiry" for an option, "U|f|expiry" for a future, "U|s" for spot) when you want to read one.
Output
Output
Output

Trade

When an order is executed, it results in a Trade. A Trade represents the actual execution of an order and contains detailed information about the trade, including:
  • Trade ID: A unique identifier for the trade
  • Order Reference: The order ID that triggered the trade
  • Instrument: The financial instrument being traded
  • Quantity: The number of contracts traded
  • Open Price: The price at which the trade was opened (initialized when stats are set up)
  • PnL Tracking: Cumulative and absolute profit/loss calculations
  • Historical Data: Complete history of price movements, PnL, and quantity changes
Note that when creating a Trade, you need to provide the order ID, instrument, and quantity. The trade statistics (prices, PnL, etc.) are initialized separately using the init_stats() method with a pulse index and datafeed:
Output
Output
It is also possible to add Tags to the trade, which will be very useful later on when the Pulse fronted app is finished. Tags can be used to categorize trades, making it easier to filter and analyze them later. Note: Tags should always be a string, otherwise we wont be able to serialize them properly.
Output
You can also access all of the historical data related to the trade. For exmple, you can get the historical PnL of the trade:
Output
Output
As well as the historical price of the instrument:
Output
Last modified on November 4, 2026