pub struct OrderBuilder { /* private fields */ }Expand description
Order builder.
Note that the price input to the OrderBuilder is in the “common” units of the perpetual/currency,
not the quantized/atomic value.
Two main classes of orders in dYdX from persistence perspective are short-term and long-term (stateful) orders.
For different types of orders see also Stop-Limit Versus Stop-Loss and Perpetual order types on dYdX Chain.
Implementations§
Source§impl OrderBuilder
impl OrderBuilder
Sourcepub fn new(
market_params: OrderMarketParams,
subaccount_owner: String,
subaccount_number: u32,
client_id: u32,
) -> Self
pub fn new( market_params: OrderMarketParams, subaccount_owner: String, subaccount_number: u32, client_id: u32, ) -> Self
Create a new Order builder.
Sourcepub fn market(self, side: OrderSide, size: Decimal) -> Self
pub fn market(self, side: OrderSide, size: Decimal) -> Self
Set as Market order.
An instruction to immediately buy or sell an asset at the best available price when the order is placed.
Sourcepub fn limit(self, side: OrderSide, price: Decimal, size: Decimal) -> Self
pub fn limit(self, side: OrderSide, price: Decimal, size: Decimal) -> Self
Set as Limit order.
With a limit order, a trader specifies the price at which they’re willing to buy or sell an asset. Unlike market orders, limit orders don’t go into effect until the market price hits a trader’s “limit price.”
Sourcepub fn stop_limit(
self,
side: OrderSide,
price: Decimal,
trigger_price: Decimal,
size: Decimal,
) -> Self
pub fn stop_limit( self, side: OrderSide, price: Decimal, trigger_price: Decimal, size: Decimal, ) -> Self
Set as Stop Limit order.
Stop-limit orders use a stop trigger_price and a limit price to give investors greater control over their trades.
Sourcepub fn stop_market(
self,
side: OrderSide,
trigger_price: Decimal,
size: Decimal,
) -> Self
pub fn stop_market( self, side: OrderSide, trigger_price: Decimal, size: Decimal, ) -> Self
Set as Stop Market order.
When using a stop order, the trader sets a trigger_price to trigger a buy or sell order on their exchange.
Sourcepub fn take_profit_limit(
self,
side: OrderSide,
price: Decimal,
trigger_price: Decimal,
size: Decimal,
) -> Self
pub fn take_profit_limit( self, side: OrderSide, price: Decimal, trigger_price: Decimal, size: Decimal, ) -> Self
Set as Take Profit Limit order.
The order enters in force if the price reaches trigger_price and is executed at price after that.
Sourcepub fn take_profit_market(
self,
side: OrderSide,
trigger_price: Decimal,
size: Decimal,
) -> Self
pub fn take_profit_market( self, side: OrderSide, trigger_price: Decimal, size: Decimal, ) -> Self
Set as Take Profit Market order.
The order enters in force if the price reaches trigger_price and converts to an ordinary market order.
Sourcepub fn short_term(self) -> Self
pub fn short_term(self) -> Self
Set order as a short-term order.
Sourcepub fn conditional(self) -> Self
pub fn conditional(self) -> Self
Set order as a conditional order, triggered using trigger_price.
Sourcepub fn time_in_force(self, tif: OrderTimeInForce) -> Self
pub fn time_in_force(self, tif: OrderTimeInForce) -> Self
Sourcepub fn reduce_only(self, reduce: bool) -> Self
pub fn reduce_only(self, reduce: bool) -> Self
Set an order as reduce-only.
Sourcepub fn until(self, gtof: OrderGoodUntil) -> Self
pub fn until(self, gtof: OrderGoodUntil) -> Self
Set order’s expiration.
Trait Implementations§
Source§impl Clone for OrderBuilder
impl Clone for OrderBuilder
Source§fn clone(&self) -> OrderBuilder
fn clone(&self) -> OrderBuilder
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OrderBuilder
impl Debug for OrderBuilder
Auto Trait Implementations§
impl Freeze for OrderBuilder
impl RefUnwindSafe for OrderBuilder
impl Send for OrderBuilder
impl Sync for OrderBuilder
impl Unpin for OrderBuilder
impl UnwindSafe for OrderBuilder
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].