/*
 * Websocket Subscription Schemas
 *
 * Schema definitions Websocket API subscriptions for Thalex exchange.
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AccountSummary {
    /// Total unrealised profit or loss.
    #[serde(rename = "unrealised_pnl")]
    pub unrealised_pnl: rust_decimal::Decimal,
    /// Total margin based on cash holdings.
    #[serde(rename = "cash_collateral")]
    pub cash_collateral: rust_decimal::Decimal,
    /// Total margin from unrealised P&L and cash holdings.
    #[serde(rename = "margin")]
    pub margin: rust_decimal::Decimal,
    /// Required margin based on current position.
    #[serde(rename = "required_margin")]
    pub required_margin: rust_decimal::Decimal,
    /// Difference between margin and required margin.
    #[serde(rename = "remaining_margin")]
    pub remaining_margin: rust_decimal::Decimal,
    /// Realised profit or loss in current session.
    #[serde(rename = "session_realised_pnl")]
    pub session_realised_pnl: rust_decimal::Decimal,
    /// List of cash holdings, for each relevant currency, and how they contribute to margin.
    #[serde(rename = "cash")]
    pub cash: Vec<models::AccountSummaryCashInner>,
}

impl AccountSummary {
    pub fn new(
        unrealised_pnl: rust_decimal::Decimal,
        cash_collateral: rust_decimal::Decimal,
        margin: rust_decimal::Decimal,
        required_margin: rust_decimal::Decimal,
        remaining_margin: rust_decimal::Decimal,
        session_realised_pnl: rust_decimal::Decimal,
        cash: Vec<models::AccountSummaryCashInner>,
    ) -> AccountSummary {
        AccountSummary {
            unrealised_pnl,
            cash_collateral,
            margin,
            required_margin,
            remaining_margin,
            session_realised_pnl,
            cash,
        }
    }
}
