ethereal_rust_sdk 0.1.22

Trading client for Ethereal exchange
Documentation
/*
 * Ethereal Exchange API
 *
 * Ethereal HTTP API for real-time trading, order management, and market data access.
 *
 * The version of the OpenAPI document: 0.1.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct OrderDto {
    /// Id representing the order
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// A subaccount scoped unique client-generated order id (either a UUID or alphanumeric string up to 32 characters)
    #[serde(rename = "clientOrderId", skip_serializing_if = "Option::is_none")]
    pub client_order_id: Option<String>,
    #[serde(rename = "type")]
    pub r#type: models::OrderType,
    /// Remaining quantity (if modified or reduced) in native units expressed as a decimal (precision: 9)
    #[serde(rename = "availableQuantity")]
    pub available_quantity: String,
    /// Original quantity (as per order submission) in native units expressed as a decimal (precision: 9)
    #[serde(rename = "quantity")]
    pub quantity: String,
    #[serde(rename = "side")]
    pub side: models::OrderSide,
    /// Id of product this order was placed against
    #[serde(rename = "productId")]
    pub product_id: uuid::Uuid,
    /// Id of the subaccount associated to order
    #[serde(rename = "subaccountId")]
    pub subaccount_id: uuid::Uuid,
    #[serde(rename = "status")]
    pub status: models::OrderStatus,
    /// Indicates if the order is reduce only
    #[serde(rename = "reduceOnly")]
    pub reduce_only: bool,
    /// Order closes the entire current position
    #[serde(rename = "close")]
    pub close: bool,
    /// Order last updated timestamp (ms since Unix Epoch)
    #[serde(rename = "updatedAt")]
    pub updated_at: f64,
    /// Order creation timestamp (ms since Unix Epoch)
    #[serde(rename = "createdAt")]
    pub created_at: f64,
    /// Account or linked signer address that placed this order
    #[serde(rename = "sender")]
    pub sender: String,
    /// Limit price in native units expressed as a decimal, zero if market order (precision: 9)
    #[serde(rename = "price")]
    pub price: String,
    /// Filled amount in native units expressed as a decimal (precision: 9)
    #[serde(rename = "filled")]
    pub filled: String,
    /// Stop price expressed as a decimal (zero if not a stop order, precision: 9)
    #[serde(rename = "stopPrice")]
    pub stop_price: String,
    #[serde(rename = "stopType", skip_serializing_if = "Option::is_none")]
    pub stop_type: Option<models::StopTypeEnum>,
    #[serde(rename = "stopPriceType", skip_serializing_if = "Option::is_none")]
    pub stop_price_type: Option<models::StopPriceTypeEnum>,
    #[serde(rename = "timeInForce", skip_serializing_if = "Option::is_none")]
    pub time_in_force: Option<models::TimeInForce>,
    /// Order expiry timestamp (seconds since Unix Epoch)
    #[serde(rename = "expiresAt")]
    pub expires_at: f64,
    /// Only add order if it does not immediately fill (limit only)
    #[serde(rename = "postOnly", skip_serializing_if = "Option::is_none")]
    pub post_only: Option<bool>,
    #[serde(
        rename = "groupContingencyType",
        skip_serializing_if = "Option::is_none"
    )]
    pub group_contingency_type: Option<models::GroupContingencyTypeEnum>,
    /// Id of the group this order belongs to
    #[serde(rename = "groupId", skip_serializing_if = "Option::is_none")]
    pub group_id: Option<uuid::Uuid>,
    #[serde(rename = "triggered")]
    pub triggered: models::TriggeredEnum,
}

impl OrderDto {
    pub fn new(
        id: uuid::Uuid,
        r#type: models::OrderType,
        available_quantity: String,
        quantity: String,
        side: models::OrderSide,
        product_id: uuid::Uuid,
        subaccount_id: uuid::Uuid,
        status: models::OrderStatus,
        reduce_only: bool,
        close: bool,
        updated_at: f64,
        created_at: f64,
        sender: String,
        price: String,
        filled: String,
        stop_price: String,
        expires_at: f64,
        triggered: models::TriggeredEnum,
    ) -> OrderDto {
        OrderDto {
            id,
            client_order_id: None,
            r#type,
            available_quantity,
            quantity,
            side,
            product_id,
            subaccount_id,
            status,
            reduce_only,
            close,
            updated_at,
            created_at,
            sender,
            price,
            filled,
            stop_price,
            stop_type: None,
            stop_price_type: None,
            time_in_force: None,
            expires_at,
            post_only: None,
            group_contingency_type: None,
            group_id: None,
            triggered,
        }
    }
}