/*
 * Thalex RPC API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * 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 AccountBreakdownRpcResult {
    /// Account number
    #[serde(rename = "account_number")]
    pub account_number: String,
    /// 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,
    /// Total realised profit or loss in current session.
    #[serde(rename = "session_realised_pnl")]
    pub session_realised_pnl: rust_decimal::Decimal,
    /// Position profit or loss in current session.
    #[serde(rename = "realised_position_pnl")]
    pub realised_position_pnl: rust_decimal::Decimal,
    /// Realised perpetual funding profit or loss in current session.
    #[serde(rename = "realised_perpetual_funding")]
    pub realised_perpetual_funding: rust_decimal::Decimal,
    /// Fees paid in current session.
    #[serde(rename = "session_fees")]
    pub session_fees: rust_decimal::Decimal,
    /// List of positions each with unrealised P&L.
    #[serde(rename = "portfolio")]
    pub portfolio: Vec<models::AccountBreakdownRpcResultPortfolioInner>,
    /// List of cash holdings, for each relevant currency, and how they contribute to margin.
    #[serde(rename = "cash")]
    pub cash: Vec<models::AccountBreakdownRpcResultCashInner>,
}

impl AccountBreakdownRpcResult {
    pub fn new(
        account_number: String,
        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,
        realised_position_pnl: rust_decimal::Decimal,
        realised_perpetual_funding: rust_decimal::Decimal,
        session_fees: rust_decimal::Decimal,
        portfolio: Vec<models::AccountBreakdownRpcResultPortfolioInner>,
        cash: Vec<models::AccountBreakdownRpcResultCashInner>,
    ) -> AccountBreakdownRpcResult {
        AccountBreakdownRpcResult {
            account_number,
            unrealised_pnl,
            cash_collateral,
            margin,
            required_margin,
            remaining_margin,
            session_realised_pnl,
            realised_position_pnl,
            realised_perpetual_funding,
            session_fees,
            portfolio,
            cash,
        }
    }
}
