Skip to main content

NewOrder

Struct NewOrder 

Source
pub struct NewOrder { /* private fields */ }
Expand description

Order to be placed.

An order at market is executed at once. A limit, a stop and a stop-limit order wait at their price until the market reaches it, till they are cancelled or, when good_till names a moment, till then.

Stop loss and take profit are given as prices or as distances from the price the order is executed at: the stop loss lies that far below the price of a buy and above the price of a sell, the take profit on the other side. The server takes only distances for an order at market.

Implementations§

Source§

impl NewOrder

Source

pub const fn market( account: AccountId, symbol: SymbolId, side: TradeSide, volume: Volume, ) -> Self

Orders the volume, in units of the symbol, at the price of the market.

Source

pub const fn limit( account: AccountId, symbol: SymbolId, side: TradeSide, volume: Volume, price: Price, ) -> Self

Orders the volume, in units of the symbol, at the given price or a better one.

Source

pub const fn stop( account: AccountId, symbol: SymbolId, side: TradeSide, volume: Volume, price: Price, ) -> Self

Orders the volume, in units of the symbol, at market once the given price is reached.

Source

pub const fn stop_limit( account: AccountId, symbol: SymbolId, side: TradeSide, volume: Volume, stop: Price, slippage: u32, ) -> Self

Orders the volume, in units of the symbol, once the given stop price is reached, at a price no further from it than the slippage, in points of the symbol.

The server models the limit of a stop-limit order as that distance and takes no limit price for it. The server itself accepts any slippage up to the largest value of the wire integer, so the bound is checked before the order is sent: the slippage is at least one point and, taken as a distance in price, no larger than the stop price, beyond which the limit of a sell order would not be a positive price. A slippage outside that range yields ValueError::BelowMinimum or ValueError::AboveMaximum.

Source

pub const fn good_till(self, expiry: Timestamp) -> Self

Keeps a pending order in force till the given moment and no longer.

An order at market does not wait, so one with an expiry is refused before it is sent.

Source

pub fn label(self, label: Label) -> Self

Gives the order a label, which the position it opens keeps.

Source

pub fn comment(self, comment: Comment) -> Self

Gives the order a comment, which the position it opens keeps.

Source

pub const fn stop_loss(self, price: Price) -> Self

Sets a stop loss at the given price, in place of one set before.

An order at market with a stop loss given as a price is refused before it is sent.

Source

pub const fn take_profit(self, price: Price) -> Self

Sets a take profit at the given price, in place of one set before.

An order at market with a take profit given as a price is refused before it is sent.

Source

pub const fn stop_loss_distance(self, distance: Price) -> Self

Sets a stop loss at the given distance from the price of execution, in place of one set before.

Source

pub const fn take_profit_distance(self, distance: Price) -> Self

Sets a take profit at the given distance from the price of execution, in place of one set before.

Source

pub const fn account(&self) -> AccountId

Returns the account the order is placed on.

Source

pub const fn symbol(&self) -> SymbolId

Returns the symbol the order trades.

Source

pub const fn side(&self) -> TradeSide

Returns the direction of the order.

Source

pub const fn volume(&self) -> Volume

Returns the volume of the order, in units of the symbol.

Source

pub const fn kind(&self) -> OrderType

Returns the kind of the order.

Trait Implementations§

Source§

impl Clone for NewOrder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NewOrder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for NewOrder

Source§

impl Hash for NewOrder

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NewOrder

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NewOrder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more