Order

Struct Order 

Source
pub struct Order {
Show 31 fields pub id: String, pub client_order_id: Option<String>, pub timestamp: Option<i64>, pub datetime: Option<String>, pub last_trade_timestamp: Option<i64>, pub symbol: String, pub order_type: OrderType, pub time_in_force: Option<String>, pub post_only: Option<bool>, pub reduce_only: Option<bool>, pub side: OrderSide, pub price: Option<Decimal>, pub stop_price: Option<Decimal>, pub trigger_price: Option<Decimal>, pub take_profit_price: Option<Decimal>, pub stop_loss_price: Option<Decimal>, pub trailing_delta: Option<Decimal>, pub trailing_percent: Option<Decimal>, pub activation_price: Option<Decimal>, pub callback_rate: Option<Decimal>, pub working_type: Option<String>, pub amount: Decimal, pub filled: Option<Decimal>, pub remaining: Option<Decimal>, pub cost: Option<Decimal>, pub average: Option<Decimal>, pub status: OrderStatus, pub fee: Option<Fee>, pub fees: Option<Vec<Fee>>, pub trades: Option<Vec<String>>, pub info: HashMap<String, Value>,
}
Expand description

Order structure

Represents a trading order with all its metadata including prices, amounts, fees, and timestamps.

Fields§

§id: String

Order ID

§client_order_id: Option<String>

Client order ID

§timestamp: Option<i64>

Timestamp when order was created (milliseconds)

§datetime: Option<String>

Datetime when order was created

§last_trade_timestamp: Option<i64>

Last update timestamp (milliseconds)

§symbol: String

Symbol (e.g., “BTC/USDT”)

§order_type: OrderType

Order type (market, limit, etc.)

§time_in_force: Option<String>

Time in force (GTC, IOC, FOK, etc.)

§post_only: Option<bool>

Post only flag

§reduce_only: Option<bool>

Reduce only flag (for futures)

§side: OrderSide

Order side (buy/sell)

§price: Option<Decimal>

Order price

§stop_price: Option<Decimal>

Stop price (for stop orders)

§trigger_price: Option<Decimal>

Trigger price

§take_profit_price: Option<Decimal>

Take profit price

§stop_loss_price: Option<Decimal>

Stop loss price

§trailing_delta: Option<Decimal>

Trailing delta (for trailing stop orders, in basis points)

§trailing_percent: Option<Decimal>

Trailing percent (for trailing stop orders)

§activation_price: Option<Decimal>

Activation price (for trailing stop orders)

§callback_rate: Option<Decimal>

Callback rate (for futures trailing stop orders)

§working_type: Option<String>

Working type (CONTRACT_PRICE or MARK_PRICE for futures)

§amount: Decimal

Order amount

§filled: Option<Decimal>

Filled amount

§remaining: Option<Decimal>

Remaining amount

§cost: Option<Decimal>

Cost (filled_amount * average_price)

§average: Option<Decimal>

Average fill price

§status: OrderStatus

Order status

§fee: Option<Fee>

Fee information

§fees: Option<Vec<Fee>>

Fees (multiple fees)

§trades: Option<Vec<String>>

Trades associated with this order

§info: HashMap<String, Value>

Raw exchange info

Implementations§

Source§

impl Order

Source

pub fn new( id: String, symbol: String, order_type: OrderType, side: OrderSide, amount: Decimal, price: Option<Decimal>, status: OrderStatus, ) -> Order

Create a new order

Source

pub fn is_open(&self) -> bool

Check if order is open

Source

pub fn is_closed(&self) -> bool

Check if order is closed

Source

pub fn is_filled(&self) -> bool

Check if order is filled

Source

pub fn is_cancelled(&self) -> bool

Check if order is cancelled

Source

pub fn datetime_utc(&self) -> Option<DateTime<Utc>>

Get DateTime from timestamp

Source

pub fn fill_percentage(&self) -> Option<Decimal>

Calculate fill percentage

Source§

impl Order

Source

pub fn builder(symbol: String, side: OrderSide, amount: Decimal) -> OrderBuilder

Creates an order builder.

Preferred way to construct orders, providing a fluent API with validation.

§Examples
use ccxt_core::types::{Order, OrderSide};
use rust_decimal_macros::dec;

let order = Order::builder("BTC/USDT".to_string(), OrderSide::Buy, dec!(0.1))
    .limit(dec!(50000))
    .time_in_force(ccxt_core::types::TimeInForce::GTC)
    .build()
    .expect("valid order");

Trait Implementations§

Source§

impl Clone for Order

Source§

fn clone(&self) -> Order

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Order

Source§

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

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

impl<'de> Deserialize<'de> for Order

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Order, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Order

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Order

§

impl RefUnwindSafe for Order

§

impl Send for Order

§

impl Sync for Order

§

impl Unpin for Order

§

impl UnwindSafe for Order

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,