1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* 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 PositionDto {
/// Id representing the position
#[serde(rename = "id")]
pub id: uuid::Uuid,
/// Current cost of the position in USD expressed as a decimal (precision: 9)
#[serde(rename = "cost")]
pub cost: String,
/// Position size in native units expressed as a decimal (precision: 9)
#[serde(rename = "size")]
pub size: String,
/// Charged but unapplied funding on position, negative if paid, expressed as a decimal (precision: 9)
#[serde(rename = "fundingUsd")]
pub funding_usd: String,
/// Charged and applied funding on position, negative if paid, expressed as a decimal (precision: 9)
#[serde(rename = "fundingAccruedUsd")]
pub funding_accrued_usd: String,
/// Fees accrued in USD expressed as a decimal (precision: 9)
#[serde(rename = "feesAccruedUsd")]
pub fees_accrued_usd: String,
/// Realized PnL in USD expressed as a decimal (precision: 9)
#[serde(rename = "realizedPnl")]
pub realized_pnl: String,
/// Cumulative USD value of all position increases expressed as a decimal (precision: 9)
#[serde(rename = "totalIncreaseNotional")]
pub total_increase_notional: String,
/// Cumulative quantity of all position increases expressed as a decimal (precision: 9)
#[serde(rename = "totalIncreaseQuantity")]
pub total_increase_quantity: String,
/// Cumulative USD value of all position decreases expressed as a decimal (precision: 9)
#[serde(rename = "totalDecreaseNotional")]
pub total_decrease_notional: String,
/// Cumulative quantity of all position decreases expressed as a decimal (precision: 9)
#[serde(rename = "totalDecreaseQuantity")]
pub total_decrease_quantity: String,
#[serde(rename = "side")]
pub side: models::OrderSide,
/// Id of product to this position belongs to
#[serde(rename = "productId")]
pub product_id: uuid::Uuid,
/// Position last updated timestamp (ms since Unix Epoch)
#[serde(rename = "updatedAt")]
pub updated_at: f64,
/// Position creation timestamp (ms since Unix Epoch)
#[serde(rename = "createdAt")]
pub created_at: f64,
/// Whether the position was liquidated
#[serde(rename = "isLiquidated")]
pub is_liquidated: bool,
/// Product price at the time of liquidation (undefined if not liquidated, precision: 9)
#[serde(rename = "liquidationPrice", skip_serializing_if = "Option::is_none")]
pub liquidation_price: Option<String>,
}
impl PositionDto {
pub fn new(
id: uuid::Uuid,
cost: String,
size: String,
funding_usd: String,
funding_accrued_usd: String,
fees_accrued_usd: String,
realized_pnl: String,
total_increase_notional: String,
total_increase_quantity: String,
total_decrease_notional: String,
total_decrease_quantity: String,
side: models::OrderSide,
product_id: uuid::Uuid,
updated_at: f64,
created_at: f64,
is_liquidated: bool,
) -> PositionDto {
PositionDto {
id,
cost,
size,
funding_usd,
funding_accrued_usd,
fees_accrued_usd,
realized_pnl,
total_increase_notional,
total_increase_quantity,
total_decrease_notional,
total_decrease_quantity,
side,
product_id,
updated_at,
created_at,
is_liquidated,
liquidation_price: None,
}
}
}