oanda-v20-openapi 0.2.1

The full OANDA v20 API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more.
Documentation
/*
 * OANDA v20 API
 *
 * The full OANDA v20 API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more.
 *
 * The version of the OpenAPI document: 0.2.1
 * Contact: jmicoud02@gmail.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// StopLossOrderTransaction : A StopLossOrderTransaction represents the creation of a StopLoss Order in the user's Account.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct StopLossOrderTransaction {
    /// The Transaction's Identifier.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<i32>,
    /// A date and time value using either RFC3339 or UNIX time representation. 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).
    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
    pub time: Option<String>,
    /// The ID of the user that initiated the creation of the Transaction.
    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
    pub user_id: Option<i32>,
    /// The Account's identifier
    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
    pub account_id: Option<String>,
    /// The ID of the \"batch\" that the Transaction belongs to. Transactions in the same batch are applied to the Account simultaneously.
    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
    pub batch_id: Option<i32>,
    /// The Request ID of the request which generated the transaction.
    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
    pub request_id: Option<String>,
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub r#type: Option<models::TransactionType>,
    /// The ID of the Trade to close when the price threshold is breached.
    #[serde(rename = "tradeID", skip_serializing_if = "Option::is_none")]
    pub trade_id: Option<i32>,
    /// The client ID of the Trade to be closed when the price threshold is breached.
    #[serde(rename = "clientTradeID", skip_serializing_if = "Option::is_none")]
    pub client_trade_id: Option<String>,
    /// The price threshold specified for the Stop Loss Order. If the guaranteed flag is false, the associated Trade will be closed by a market price that is equal to or worse than this threshold. If the flag is true the associated Trade will be closed at this price.
    #[serde(rename = "price", skip_serializing_if = "Option::is_none")]
    pub price: Option<f64>,
    /// Specifies the distance (in price units) from the Account's current price to use as the Stop Loss Order price. If the Trade is short the Instrument's bid price is used, and for long Trades the ask is used.
    #[serde(rename = "distance", skip_serializing_if = "Option::is_none")]
    pub distance: Option<f64>,
    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
    pub time_in_force: Option<models::TradeOrderTimeInForce>,
    /// A date and time value using either RFC3339 or UNIX time representation. 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).
    #[serde(rename = "gtdTime", skip_serializing_if = "Option::is_none")]
    pub gtd_time: Option<String>,
    #[serde(rename = "triggerCondition", skip_serializing_if = "Option::is_none")]
    pub trigger_condition: Option<models::TradeOrderTriggerCondition>,
    /// Flag indicating that the Stop Loss Order is guaranteed. The default value depends on the GuaranteedStopLossOrderMode of the account, if it is REQUIRED, the default will be true, for DISABLED or ENABLED the default is false.
    #[serde(rename = "guaranteed", skip_serializing_if = "Option::is_none")]
    pub guaranteed: Option<bool>,
    /// The fee that will be charged if the Stop Loss Order is guaranteed and the Order is filled at the guaranteed price. The value is determined at Order creation time. It is in price units and is charged for each unit of the Trade.
    #[serde(rename = "guaranteedExecutionPremium", skip_serializing_if = "Option::is_none")]
    pub guaranteed_execution_premium: Option<f64>,
    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
    pub reason: Option<models::TradeOrderTransactionReason>,
    #[serde(rename = "clientExtensions", skip_serializing_if = "Option::is_none")]
    pub client_extensions: Option<Box<models::ClientExtensions>>,
    /// The ID of the OrderFill Transaction that caused this Order to be created (only provided if this Order was created automatically when another Order was filled).
    #[serde(rename = "orderFillTransactionID", skip_serializing_if = "Option::is_none")]
    pub order_fill_transaction_id: Option<i32>,
    /// The ID of the Order that this Order replaces (only provided if this Order replaces an existing Order).
    #[serde(rename = "replacesOrderID", skip_serializing_if = "Option::is_none")]
    pub replaces_order_id: Option<i32>,
    /// The ID of the Transaction that cancels the replaced Order (only provided if this Order replaces an existing Order).
    #[serde(rename = "cancellingTransactionID", skip_serializing_if = "Option::is_none")]
    pub cancelling_transaction_id: Option<i32>,
}

impl StopLossOrderTransaction {
    /// A StopLossOrderTransaction represents the creation of a StopLoss Order in the user's Account.
    pub fn new() -> StopLossOrderTransaction {
        StopLossOrderTransaction {
            id: None,
            time: None,
            user_id: None,
            account_id: None,
            batch_id: None,
            request_id: None,
            r#type: None,
            trade_id: None,
            client_trade_id: None,
            price: None,
            distance: None,
            time_in_force: None,
            gtd_time: None,
            trigger_condition: None,
            guaranteed: None,
            guaranteed_execution_premium: None,
            reason: None,
            client_extensions: None,
            order_fill_transaction_id: None,
            replaces_order_id: None,
            cancelling_transaction_id: None,
        }
    }
}