pub struct Order {
pub symbol: Symbol,
pub side: Side,
pub kind: OrderKind,
pub size: Volume,
pub limit_price: Option<Price>,
pub reduce_only: bool,
pub client_id: Option<String>,
pub stop: Option<StopAttachment>,
}Expand description
A request to enter, exit, or reduce a position.
This is the framework-level abstraction; concrete exchange adapters translate
it into exchange-specific payloads. The client_id is optional but strongly
recommended — it lets the framework reconcile fills back to this order.
§Example
use rustrade_core::{Order, Price, Side, StopAttachment, Volume};
// Market order — the everyday case.
let mkt = Order::market("BTCUSDT", Side::Buy, Volume(2.0));
assert_eq!(mkt.symbol.as_str(), "BTCUSDT");
// Limit order with a stop-market attachment.
let limit = Order::limit("ETHUSDT", Side::Sell, Volume(1.0), Price(3_500.0))
.with_stop(StopAttachment::stop_market(Price(3_400.0)));
assert!(limit.stop.is_some());Fields§
§symbol: SymbolSymbol the order is for.
side: SideSide of the trade (buy or sell).
kind: OrderKindMarket / limit / time-in-force variant.
size: VolumeQuantity in base-asset units or contracts.
limit_price: Option<Price>Limit price for non-market orders.
reduce_only: boolSet to true for exit orders that must never increase the position.
client_id: Option<String>Optional client-supplied id. Exchanges that support it will echo it back on fills, making reconciliation trivial.
stop: Option<StopAttachment>Optional stop-order attachment. Adapters that don’t advertise
Capability::StopOrders must
reject orders carrying this field.
Implementations§
Source§impl Order
impl Order
Sourcepub fn market(symbol: impl Into<Symbol>, side: Side, size: Volume) -> Order
pub fn market(symbol: impl Into<Symbol>, side: Side, size: Volume) -> Order
Construct a market order.
Sourcepub fn limit(
symbol: impl Into<Symbol>,
side: Side,
size: Volume,
price: Price,
) -> Order
pub fn limit( symbol: impl Into<Symbol>, side: Side, size: Volume, price: Price, ) -> Order
Construct a standard limit order resting at price.
Sourcepub fn with_reduce_only(self, reduce_only: bool) -> Order
pub fn with_reduce_only(self, reduce_only: bool) -> Order
Set or clear the reduce_only flag.
Sourcepub fn with_client_id(self, id: impl Into<String>) -> Order
pub fn with_client_id(self, id: impl Into<String>) -> Order
Set the optional client id used to reconcile fills back to this order.
Sourcepub fn with_stop(self, stop: StopAttachment) -> Order
pub fn with_stop(self, stop: StopAttachment) -> Order
Attach a stop. Adapter must advertise
Capability::StopOrders.