pub struct OrderCore {Show 41 fields
pub commissions: IndexMap<Currency, Money>,
pub venue_order_ids: Vec<VenueOrderId>,
pub trade_ids: Vec<TradeId>,
pub previous_status: Option<OrderStatus>,
pub status: OrderStatus,
pub trader_id: TraderId,
pub strategy_id: StrategyId,
pub instrument_id: InstrumentId,
pub client_order_id: ClientOrderId,
pub venue_order_id: Option<VenueOrderId>,
pub position_id: Option<PositionId>,
pub account_id: Option<AccountId>,
pub last_trade_id: Option<TradeId>,
pub side: OrderSide,
pub order_type: OrderType,
pub quantity: Quantity,
pub time_in_force: TimeInForce,
pub liquidity_side: Option<LiquiditySide>,
pub is_reduce_only: bool,
pub is_quote_quantity: bool,
pub emulation_trigger: Option<TriggerType>,
pub contingency_type: Option<ContingencyType>,
pub order_list_id: Option<OrderListId>,
pub linked_order_ids: Option<Vec<ClientOrderId>>,
pub parent_order_id: Option<ClientOrderId>,
pub exec_algorithm_id: Option<ExecAlgorithmId>,
pub exec_algorithm_params: Option<IndexMap<Ustr, Ustr>>,
pub exec_spawn_id: Option<ClientOrderId>,
pub tags: Option<Vec<Ustr>>,
pub filled_qty: Quantity,
pub voided_qty: Quantity,
pub leaves_qty: Quantity,
pub overfill_qty: Quantity,
pub avg_px: Option<Decimal>,
pub slippage: Option<Decimal>,
pub init_id: UUID4,
pub ts_init: UnixNanos,
pub ts_submitted: Option<UnixNanos>,
pub ts_accepted: Option<UnixNanos>,
pub ts_closed: Option<UnixNanos>,
pub ts_last: UnixNanos,
/* private fields */
}Expand description
Common event-sourced state shared by order types.
Construct with Self::new and update through Self::apply. Inspect history with
Self::events; use Self::prepend_events to retain history when transforming an order,
or OrderAny::from_events to reconstruct its state from an event stream.
Fields§
§commissions: IndexMap<Currency, Money>§venue_order_ids: Vec<VenueOrderId>§trade_ids: Vec<TradeId>§previous_status: Option<OrderStatus>§status: OrderStatus§trader_id: TraderId§strategy_id: StrategyId§instrument_id: InstrumentId§client_order_id: ClientOrderId§venue_order_id: Option<VenueOrderId>§position_id: Option<PositionId>§account_id: Option<AccountId>§last_trade_id: Option<TradeId>§side: OrderSide§order_type: OrderType§quantity: Quantity§time_in_force: TimeInForce§liquidity_side: Option<LiquiditySide>§is_reduce_only: bool§is_quote_quantity: bool§emulation_trigger: Option<TriggerType>§contingency_type: Option<ContingencyType>§order_list_id: Option<OrderListId>§linked_order_ids: Option<Vec<ClientOrderId>>§parent_order_id: Option<ClientOrderId>§exec_algorithm_id: Option<ExecAlgorithmId>§exec_algorithm_params: Option<IndexMap<Ustr, Ustr>>§exec_spawn_id: Option<ClientOrderId>§filled_qty: Quantity§voided_qty: Quantity§leaves_qty: Quantity§overfill_qty: Quantity§avg_px: Option<Decimal>§slippage: Option<Decimal>§init_id: UUID4§ts_init: UnixNanos§ts_submitted: Option<UnixNanos>§ts_accepted: Option<UnixNanos>§ts_closed: Option<UnixNanos>§ts_last: UnixNanosImplementations§
Source§impl OrderCore
impl OrderCore
Sourcepub fn new(init: OrderInitialized) -> Self
pub fn new(init: OrderInitialized) -> Self
Creates a new OrderCore instance.
Sourcepub fn apply(&mut self, event: OrderEventAny) -> Result<(), OrderError>
pub fn apply(&mut self, event: OrderEventAny) -> Result<(), OrderError>
Applies the event to the order.
§Errors
Returns an error if the event is invalid for the current order status, or if
event.client_order_id() or event.strategy_id() does not match the order.
pub fn set_slippage(&mut self, price: Price)
Sourcepub fn opposite_side(side: OrderSide) -> OrderSide
pub fn opposite_side(side: OrderSide) -> OrderSide
Returns the opposite order side.
Sourcepub fn closing_side(side: PositionSide) -> Option<OrderSide>
pub fn closing_side(side: PositionSide) -> Option<OrderSide>
Returns the order side needed to close a position.
pub fn signed_decimal_qty(&self) -> Decimal
pub fn would_reduce_only( &self, side: PositionSide, position_qty: Quantity, ) -> bool
pub fn commission(&self, currency: &Currency) -> Option<Money>
pub fn commissions(&self) -> IndexMap<Currency, Money>
pub fn commissions_vec(&self) -> Vec<Money>
Sourcepub fn events(&self) -> &[OrderEventAny]
pub fn events(&self) -> &[OrderEventAny]
Returns the order events in application order.
Sourcepub fn prepend_events(
&mut self,
events: impl IntoIterator<Item = OrderEventAny>,
)
pub fn prepend_events( &mut self, events: impl IntoIterator<Item = OrderEventAny>, )
Prepends historical events in iterator order without applying their state transitions.
Used when transforming an order into another type. The next fill rebuilds the average-price fold from the combined history; other derived state is unchanged.