pub struct Trade {
Show 19 fields pub financing: Option<f32>, pub open_time: Option<DateTime<Utc>>, pub take_profit_order: Option<TakeProfitOrder>, pub margin_used: Option<f32>, pub price: Option<f32>, pub unrealized_pl: Option<f32>, pub realized_pl: Option<f32>, pub trailing_stop_loss_order: Option<TrailingStopLossOrder>, pub close_time: Option<DateTime<Utc>>, pub instrument: Option<String>, pub state: Option<String>, pub initial_margin_required: Option<f32>, pub initial_units: Option<f32>, pub average_close_price: Option<f32>, pub current_units: Option<f32>, pub closing_transaction_i_ds: Option<Vec<String>>, pub client_extensions: Option<ClientExtensions>, pub id: Option<String>, pub stop_loss_order: Option<StopLossOrder>,
}

Fields§

§financing: Option<f32>

The financing paid/collected for this Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

§open_time: Option<DateTime<Utc>>

The date/time when the Trade was opened. format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).

§take_profit_order: Option<TakeProfitOrder>

A TakeProfitOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or better than the threshold. A TakeProfitOrder cannot be used to open a new Position.

§margin_used: Option<f32>

Margin currently used by the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

§price: Option<f32>

The execution price of the Trade. format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.

§unrealized_pl: Option<f32>

The unrealized profit/loss on the open portion of the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

§realized_pl: Option<f32>

The total profit/loss realized on the closed portion of the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

§trailing_stop_loss_order: Option<TrailingStopLossOrder>

A TrailingStopLossOrder is an order that is linked to an open Trade and created with a price distance. The price distance is used to calculate a trailing stop value for the order that is in the losing direction from the market price at the time of the order’s creation. The trailing stop value will follow the market price as it moves in the winning direction, and the order will filled (closing the Trade) by the first price that is equal to or worse than the trailing stop value. A TrailingStopLossOrder cannot be used to open a new Position.

§close_time: Option<DateTime<Utc>>

The date/time when the Trade was fully closed. Only provided for Trades whose state is CLOSED. format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).

§instrument: Option<String>

The Trade’s Instrument. format: A string containing the base currency and quote currency delimited by a “_”.

§state: Option<String>

The current state of the Trade.

§initial_margin_required: Option<f32>

The margin required at the time the Trade was created. Note, this is the ‘pure’ margin required, it is not the ‘effective’ margin used that factors in the trade risk if a GSLO is attached to the trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

§initial_units: Option<f32>

The initial size of the Trade. Negative values indicate a short Trade, and positive values indicate a long Trade. format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.

§average_close_price: Option<f32>

The average closing price of the Trade. Only present if the Trade has been closed or reduced at least once. format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.

§current_units: Option<f32>

The number of units currently open for the Trade. This value is reduced to 0.0 as the Trade is closed. format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.

§closing_transaction_i_ds: Option<Vec<String>>

The IDs of the Transactions that have closed portions of this Trade.

§client_extensions: Option<ClientExtensions>

A ClientExtensions object allows a client to attach a clientID, tag and comment to Orders and Trades in their Account. Do not set, modify, or delete this field if your account is associated with MT4.

§id: Option<String>

The Trade’s identifier, unique within the Trade’s Account. format: The string representation of the OANDA-assigned TradeID. OANDA- assigned TradeIDs are positive integers, and are derived from the TransactionID of the Transaction that opened the Trade.

§stop_loss_order: Option<StopLossOrder>

A StopLossOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or worse than the threshold. A StopLossOrder cannot be used to open a new Position.

Implementations§

source§

impl Trade

source

pub fn new() -> Trade

source

pub fn with_financing(self, x: f32) -> Self

The financing paid/collected for this Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

  • param f32
  • return Trade
source

pub fn with_open_time(self, x: DateTime<Utc>) -> Self

The date/time when the Trade was opened. format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).

  • param DateTime
  • return Trade
source

pub fn with_take_profit_order(self, x: TakeProfitOrder) -> Self

A TakeProfitOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or better than the threshold. A TakeProfitOrder cannot be used to open a new Position.

  • param TakeProfitOrder
  • return Trade
source

pub fn with_margin_used(self, x: f32) -> Self

Margin currently used by the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

  • param f32
  • return Trade
source

pub fn with_price(self, x: f32) -> Self

The execution price of the Trade. format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.

  • param f32
  • return Trade
source

pub fn with_unrealized_pl(self, x: f32) -> Self

The unrealized profit/loss on the open portion of the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

  • param f32
  • return Trade
source

pub fn with_realized_pl(self, x: f32) -> Self

The total profit/loss realized on the closed portion of the Trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

  • param f32
  • return Trade
source

pub fn with_trailing_stop_loss_order(self, x: TrailingStopLossOrder) -> Self

A TrailingStopLossOrder is an order that is linked to an open Trade and created with a price distance. The price distance is used to calculate a trailing stop value for the order that is in the losing direction from the market price at the time of the order’s creation. The trailing stop value will follow the market price as it moves in the winning direction, and the order will filled (closing the Trade) by the first price that is equal to or worse than the trailing stop value. A TrailingStopLossOrder cannot be used to open a new Position.

  • param TrailingStopLossOrder
  • return Trade
source

pub fn with_close_time(self, x: DateTime<Utc>) -> Self

The date/time when the Trade was fully closed. Only provided for Trades whose state is CLOSED. format: The RFC 3339 representation is a string conforming to https://tools.ietf.org/rfc/rfc3339.txt. The Unix representation is a string representing the number of seconds since the Unix Epoch (January 1st, 1970 at UTC). The value is a fractional number, where the fractional part represents a fraction of a second (up to nine decimal places).

  • param DateTime
  • return Trade
source

pub fn with_instrument(self, x: String) -> Self

The Trade’s Instrument. format: A string containing the base currency and quote currency delimited by a “_”.

  • param String
  • return Trade
source

pub fn with_state(self, x: String) -> Self

The current state of the Trade.

  • param String
  • return Trade
source

pub fn with_initial_margin_required(self, x: f32) -> Self

The margin required at the time the Trade was created. Note, this is the ‘pure’ margin required, it is not the ‘effective’ margin used that factors in the trade risk if a GSLO is attached to the trade. format: A decimal number encoded as a string. The amount of precision provided depends on the Account’s home currency.

  • param f32
  • return Trade
source

pub fn with_initial_units(self, x: f32) -> Self

The initial size of the Trade. Negative values indicate a short Trade, and positive values indicate a long Trade. format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.

  • param f32
  • return Trade
source

pub fn with_average_close_price(self, x: f32) -> Self

The average closing price of the Trade. Only present if the Trade has been closed or reduced at least once. format: A decimal number encodes as a string. The amount of precision provided depends on the Instrument.

  • param f32
  • return Trade
source

pub fn with_current_units(self, x: f32) -> Self

The number of units currently open for the Trade. This value is reduced to 0.0 as the Trade is closed. format: A decimal number encoded as a string. The amount of precision provided depends on what the number represents.

  • param f32
  • return Trade
source

pub fn with_closing_transaction_i_ds(self, x: Vec<String>) -> Self

The IDs of the Transactions that have closed portions of this Trade.

  • param Vec
  • return Trade
source

pub fn with_client_extensions(self, x: ClientExtensions) -> Self

A ClientExtensions object allows a client to attach a clientID, tag and comment to Orders and Trades in their Account. Do not set, modify, or delete this field if your account is associated with MT4.

  • param ClientExtensions
  • return Trade
source

pub fn with_id(self, x: String) -> Self

The Trade’s identifier, unique within the Trade’s Account. format: The string representation of the OANDA-assigned TradeID. OANDA- assigned TradeIDs are positive integers, and are derived from the TransactionID of the Transaction that opened the Trade.

  • param String
  • return Trade
source

pub fn with_stop_loss_order(self, x: StopLossOrder) -> Self

A StopLossOrder is an order that is linked to an open Trade and created with a price threshold. The Order will be filled (closing the Trade) by the first price that is equal to or worse than the threshold. A StopLossOrder cannot be used to open a new Position.

  • param StopLossOrder
  • return Trade

Trait Implementations§

source§

impl Debug for Trade

source§

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

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

impl<'de> Deserialize<'de> for Trade

source§

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

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

impl Serialize for Trade

source§

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Trade

§

impl RefUnwindSafe for Trade

§

impl Send for Trade

§

impl Sync for Trade

§

impl Unpin for Trade

§

impl UnwindSafe for Trade

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,