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
/*
* 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 PositionFillDto {
/// Fill price expressed as a decimal (precision: 9)
#[serde(rename = "price")]
pub price: String,
/// Quantity filled in native units expressed as a decimal (precision: 9)
#[serde(rename = "filled")]
pub filled: String,
/// Realized PnL from the fill in USD expressed as a decimal (precision: 9)
#[serde(rename = "realizedPnl")]
pub realized_pnl: String,
/// Corresponding order type that led to the position fill, LIQUIDATED if takeover
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "side")]
pub side: models::PositionSide,
/// Indicates if the fill is reduce only
#[serde(rename = "reduceOnly")]
pub reduce_only: bool,
/// The charged fee in USD expressed as a decimal (precision: 9)
#[serde(rename = "feeUsd")]
pub fee_usd: String,
/// Fill creation timestamp (ms since Unix Epoch)
#[serde(rename = "createdAt")]
pub created_at: f64,
}
impl PositionFillDto {
pub fn new(
price: String,
filled: String,
realized_pnl: String,
r#type: Type,
side: models::PositionSide,
reduce_only: bool,
fee_usd: String,
created_at: f64,
) -> PositionFillDto {
PositionFillDto {
price,
filled,
realized_pnl,
r#type,
side,
reduce_only,
fee_usd,
created_at,
}
}
}
/// Corresponding order type that led to the position fill, LIQUIDATED if takeover
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "MARKET")]
Market,
#[serde(rename = "LIMIT")]
Limit,
#[serde(rename = "REALIZED_PNL")]
RealizedPnl,
#[serde(rename = "LIQUIDATION")]
Liquidation,
#[serde(rename = "REALIZED_FUNDING")]
RealizedFunding,
}
impl Default for Type {
fn default() -> Type {
Self::Market
}
}