Order is created by calling Strategy.buy() or Strategy.sell(). Pending orders are accessible via Strategy.orders. When an order is executed (filled), it produces a Trade.
All placed orders are Good ‘Til Canceled — they remain pending until filled or explicitly canceled.
Properties
Order size in units. Negative values indicate a short order.
- A value between
0and1(exclusive) is treated as a fraction of current available liquidity (cash plusPosition.plminus used margin). - A value greater than or equal to
1is an absolute number of units.
Limit price for limit orders. When set, the order fills only if the market reaches this price.
None for market orders, which fill at the next available price.Stop price for stop-limit or stop-market orders.
None if no stop was set, or if the stop price has already been triggered (in which case the order becomes a market or limit order).Stop-loss price declared at order creation. If set, a contingent stop-market order is automatically placed on the resulting
Trade once this order fills.See also Trade.sl for modifying stop-loss on an active trade.Take-profit price declared at order creation. If set, a contingent limit order is automatically placed on the resulting
Trade once this order fills.See also Trade.tp for modifying take-profit on an active trade.Arbitrary value attached to the order for tracking purposes. The tag is inherited by the See also
Trade that results from this order.Trade.tag.True if the order is long (i.e. size > 0).True if the order is short (i.e. size < 0).True for contingent orders — the OCO stop-loss and take-profit bracket orders that are automatically attached to an active trade.Contingent orders are canceled automatically when their parent trade closes. You can modify them via Trade.sl and Trade.tp.Methods
Order.cancel()
cancel() also removes that contingent order from the trade (setting trade.sl or trade.tp to None).