Skip to content

Order


dataclass backtide.backtest.Order

A trading order submitted during the simulation.

Read more in the user guide.

Attributes

id : str

Unique identifier of the order. Auto-generated if not provided. For OrderType.Cancel orders, the id field identifies the target order that should be canceled. If an order with the same id already exists in the order book, the duplicate is rejected.

symbol : str
The ticker symbol this order targets.

quantity : int | float | BaseSizer, default=1
Signed quantity (positive = buy, negative = sell). Fractional values are accepted only for crypto instruments. When a sizer is passed, the engine resolves the quantity automatically at order-processing time using portfolio equity converted to the asset's quote currency and the asset's price.

order_type : OrderType
The execution semantics (market, limit, stop-loss, etc...). Also accepts a string of the form PascalCase (StopLoss) or snake_case (stop_loss), case-insensitively.

price : float | None
Primary price for the order. The exact meaning depends on order_type:

{#order-- Market / Cancel / SettlePosition} - Market / Cancel / SettlePosition: ignored.

imit/TakeProfit: the limit / target price. </div>[](){#order--Limit/TakeProfit} <strong>-Limit/TakeProfit`: the limit / target price.

topLoss: the stop (trigger) price. </div>[](){#order--StopLoss} <strong>-StopLoss`: the stop (trigger) price.

topLossLimit/TakeProfitLimit: the stop (trigger) price. Once hit, the der converts to a limit atlimit_price. </div>[](){#order--StopLossLimit/TakeProfitLimit} <strong>-StopLossLimit/TakeProfitLimit: the stop (trigger) price. Once hit, the</strong><br><div class='param' markdown> der converts to a limit atlimit_price. </div>[](){#order--TrailingStop/TrailingStopLimit} <strong>-TrailingStop/TrailingStopLimit`: the trail amount in price units (positive).

e engine maintains the running extreme internally.

limit_price : float | None
Secondary limit price used by the StopLossLimit, TakeProfitLimit and TrailingStopLimit order types. Once the stop component triggers, the order converts to a limit order resting at this price. Ignored for all other order types.


See Also

OrderType

The type of order that can be submitted to the exchange.

Portfolio

A snapshot of the portfolio's holdings at a point in time.

State

The simulation state passed to a strategy's evaluate method on every tick.