Skip to main content

Module orders

Module orders 

Source
Expand description

Order types for the trading domain model.

Each order type wraps an OrderCore carrying the state common to all of them and adds its own type-specific fields. OrderAny dispatches over the concrete types.

Orders are event sourced. OrderCore::apply validates the status transition, runs the handler for that event, then appends it, so OrderAny::from_events replays a stream to reconstruct its event-derived state.

A fill-void correction rebuilds the derived fill state from the fills that survive it. avg_px folds those fills in Decimal and keeps the quotient at that precision, so no float conversion enters the next average and a rebuild agrees with the incremental update over the same fills. slippage derives from avg_px in the same arithmetic.

Re-exports§

pub use crate::orders::builder::OrderTestBuilder;
pub use crate::orders::any::LimitOrderAny;
pub use crate::orders::any::OrderAny;
pub use crate::orders::any::OrderReplayError;
pub use crate::orders::any::PassiveOrderAny;
pub use crate::orders::any::StopOrderAny;
pub use crate::orders::limit::LimitOrder;
pub use crate::orders::limit_if_touched::LimitIfTouchedOrder;
pub use crate::orders::list::OrderList;
pub use crate::orders::list::OrderListValidationError;
pub use crate::orders::market::MarketOrder;
pub use crate::orders::market_if_touched::MarketIfTouchedOrder;
pub use crate::orders::market_to_limit::MarketToLimitOrder;
pub use crate::orders::stop_limit::StopLimitOrder;
pub use crate::orders::stop_market::StopMarketOrder;
pub use crate::orders::trailing_stop_limit::TrailingStopLimitOrder;
pub use crate::orders::trailing_stop_market::TrailingStopMarketOrder;

Modules§

any
builder
limit
limit_if_touched
list
market
market_if_touched
market_to_limit
stop_limit
stop_market
stubs
trailing_stop_limit
trailing_stop_market

Structs§

OrderCore

Enums§

OrderError

Constants§

LIMIT_ORDER_TYPES
Order types that have limit prices.
LOCAL_ACTIVE_ORDER_STATUSES
Order statuses for locally active orders (pre-submission to venue).
STOP_ORDER_TYPES
Order types that have stop/trigger prices.
TRIGGERABLE_ORDER_TYPES
Order types that support the TRIGGERED order status.

Traits§

Order

Functions§

str_indexmap_to_ustr
Converts an IndexMap with String keys and values to Ustr keys and values.
ustr_indexmap_to_str
Converts an IndexMap with Ustr keys and values to String keys and values.