Orders
AnOrder 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
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
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: useinstrument.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 aTrade. 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
init_stats() method with a pulse index and datafeed:
Output
Output
Output
Output
Output
Output

