use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AccountPosition {
#[serde(rename = "market_id")]
pub market_id: i32,
#[serde(rename = "symbol")]
pub symbol: String,
#[serde(rename = "initial_margin_fraction")]
pub initial_margin_fraction: String,
#[serde(rename = "open_order_count")]
pub open_order_count: i64,
#[serde(rename = "pending_order_count")]
pub pending_order_count: i64,
#[serde(rename = "position_tied_order_count")]
pub position_tied_order_count: i64,
#[serde(rename = "sign")]
pub sign: i32,
#[serde(rename = "position")]
pub position: String,
#[serde(rename = "avg_entry_price")]
pub avg_entry_price: String,
#[serde(rename = "position_value")]
pub position_value: String,
#[serde(rename = "unrealized_pnl")]
pub unrealized_pnl: String,
#[serde(rename = "realized_pnl")]
pub realized_pnl: String,
#[serde(rename = "liquidation_price")]
pub liquidation_price: String,
#[serde(
rename = "total_funding_paid_out",
skip_serializing_if = "Option::is_none"
)]
pub total_funding_paid_out: Option<String>,
#[serde(rename = "margin_mode")]
pub margin_mode: i32,
#[serde(rename = "allocated_margin")]
pub allocated_margin: String,
}
impl AccountPosition {
pub fn new(
market_id: i32,
symbol: String,
initial_margin_fraction: String,
open_order_count: i64,
pending_order_count: i64,
position_tied_order_count: i64,
sign: i32,
position: String,
avg_entry_price: String,
position_value: String,
unrealized_pnl: String,
realized_pnl: String,
liquidation_price: String,
margin_mode: i32,
allocated_margin: String,
) -> AccountPosition {
AccountPosition {
market_id,
symbol,
initial_margin_fraction,
open_order_count,
pending_order_count,
position_tied_order_count,
sign,
position,
avg_entry_price,
position_value,
unrealized_pnl,
realized_pnl,
liquidation_price,
total_funding_paid_out: None,
margin_mode,
allocated_margin,
}
}
}