pub struct OrderRequest {
pub symbol: Symbol,
pub side: OrderSide,
pub order_type: OrderType,
pub quantity: Decimal,
pub price: Option<Decimal>,
pub stop_price: Option<Decimal>,
pub time_in_force: TimeInForce,
pub client_order_id: Option<String>,
pub reduce_only: bool,
pub post_only: bool,
pub stp: SelfTradePrevention,
}Expand description
A request to place an order. Built with the convenience constructors and
refined with the builder methods; quantities and prices are exact Decimals.
Fields§
§symbol: SymbolThe market to trade.
side: OrderSideBuy or sell.
order_type: OrderTypeOrder type.
quantity: DecimalOrder quantity in base units.
price: Option<Decimal>Limit price (required for limit / stop-limit orders).
stop_price: Option<Decimal>Trigger price (required for stop orders).
time_in_force: TimeInForceTime-in-force policy.
client_order_id: Option<String>Optional client-supplied id for idempotent placement and reconciliation.
reduce_only: boolOnly reduce an existing position; never open or increase one.
post_only: boolOnly rest as a maker; reject if it would take liquidity.
stp: SelfTradePreventionSelf-trade-prevention policy (defaults to SelfTradePrevention::None).
Implementations§
Source§impl OrderRequest
impl OrderRequest
Sourcepub fn market_buy(symbol: Symbol, quantity: Decimal) -> OrderRequest
pub fn market_buy(symbol: Symbol, quantity: Decimal) -> OrderRequest
A market buy of quantity base units.
Sourcepub fn market_sell(symbol: Symbol, quantity: Decimal) -> OrderRequest
pub fn market_sell(symbol: Symbol, quantity: Decimal) -> OrderRequest
A market sell of quantity base units.
Sourcepub fn limit_buy(
symbol: Symbol,
quantity: Decimal,
price: Decimal,
) -> OrderRequest
pub fn limit_buy( symbol: Symbol, quantity: Decimal, price: Decimal, ) -> OrderRequest
A limit buy of quantity base units at price.
Sourcepub fn limit_sell(
symbol: Symbol,
quantity: Decimal,
price: Decimal,
) -> OrderRequest
pub fn limit_sell( symbol: Symbol, quantity: Decimal, price: Decimal, ) -> OrderRequest
A limit sell of quantity base units at price.
Sourcepub fn with_time_in_force(self, tif: TimeInForce) -> OrderRequest
pub fn with_time_in_force(self, tif: TimeInForce) -> OrderRequest
Set the time-in-force policy.
Sourcepub fn with_client_order_id(self, id: impl Into<String>) -> OrderRequest
pub fn with_client_order_id(self, id: impl Into<String>) -> OrderRequest
Attach a client order id.
Sourcepub fn reduce_only(self) -> OrderRequest
pub fn reduce_only(self) -> OrderRequest
Mark the order reduce-only.
Sourcepub fn post_only(self) -> OrderRequest
pub fn post_only(self) -> OrderRequest
Mark the order post-only.
Sourcepub fn with_stop_price(self, stop_price: Decimal) -> OrderRequest
pub fn with_stop_price(self, stop_price: Decimal) -> OrderRequest
Turn this into a trigger order that rests until the market reaches
stop_price: a market order becomes a OrderType::StopMarket, a limit
order a OrderType::StopLimit.
A stop price is what makes an order a trigger order, so setting one
promotes the type rather than leaving a stop_price that the type says
to ignore. Without this the only way to build a stop was a struct
literal, which is why no binding could place one.
Sourcepub fn with_stp(self, stp: SelfTradePrevention) -> OrderRequest
pub fn with_stp(self, stp: SelfTradePrevention) -> OrderRequest
Set the self-trade-prevention policy.
Trait Implementations§
Source§impl Clone for OrderRequest
impl Clone for OrderRequest
Source§fn clone(&self) -> OrderRequest
fn clone(&self) -> OrderRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrderRequest
impl Debug for OrderRequest
Source§impl<'de> Deserialize<'de> for OrderRequest
impl<'de> Deserialize<'de> for OrderRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrderRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrderRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for OrderRequest
Source§impl PartialEq for OrderRequest
impl PartialEq for OrderRequest
Source§impl Serialize for OrderRequest
impl Serialize for OrderRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for OrderRequest
Auto Trait Implementations§
impl Freeze for OrderRequest
impl RefUnwindSafe for OrderRequest
impl Send for OrderRequest
impl Sync for OrderRequest
impl Unpin for OrderRequest
impl UnsafeUnpin for OrderRequest
impl UnwindSafe for OrderRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more