1use super::{history::SortDirection, order::Side};
2use rust_decimal::Decimal;
3
4#[derive(
5 Debug,
6 strum::Display,
7 Clone,
8 Copy,
9 serde::Serialize,
10 serde::Deserialize,
11 strum::EnumString,
12 PartialEq,
13 Eq,
14 Hash,
15)]
16#[strum(serialize_all = "PascalCase")]
17#[serde(rename_all = "PascalCase")]
18pub enum FillType {
19 User,
20 BookLiquidation,
21 Adl,
22 Backstop,
23 Liquidation,
24 AllLiquidation,
25 CollateralConversion,
26 CollateralConversionAndSpotLiquidation,
27}
28
29#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
30#[serde(rename_all = "camelCase")]
31pub struct Fill {
32 pub trade_id: Option<i64>,
33 pub client_id: Option<String>,
34 pub order_id: String,
35 pub symbol: String,
36 pub fee_symbol: String,
37 pub price: Decimal,
38 pub quantity: Decimal,
39 pub fee: Decimal,
40 pub side: Side,
41 pub timestamp: String,
42 pub is_maker: bool,
43 pub system_order_type: Option<String>,
44}
45
46#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
47pub struct FillsHistoryParams {
48 pub symbol: Option<String>,
50 pub from: Option<i64>,
52 pub to: Option<i64>,
54 pub fill_type: Option<FillType>,
56 pub market_type: Option<String>,
58 pub order_id: Option<String>,
60 pub strategy_id: Option<String>,
62 pub limit: Option<u64>,
64 pub offset: Option<u64>,
66 pub sort_direction: Option<SortDirection>,
68}
69
70impl FillsHistoryParams {
71 pub fn with_symbol<S: Into<String>>(mut self, symbol: S) -> Self {
72 self.symbol = Some(symbol.into());
73 self
74 }
75
76 pub fn with_from(mut self, from: i64) -> Self {
77 self.from = Some(from);
78 self
79 }
80
81 pub fn with_to(mut self, to: i64) -> Self {
82 self.to = Some(to);
83 self
84 }
85
86 pub fn with_fill_type(mut self, fill_type: FillType) -> Self {
87 self.fill_type = Some(fill_type);
88 self
89 }
90
91 pub fn with_market_type(mut self, market_type: String) -> Self {
92 self.market_type = Some(market_type);
93 self
94 }
95
96 pub fn with_order_id<S: Into<String>>(mut self, order_id: S) -> Self {
97 self.order_id = Some(order_id.into());
98 self
99 }
100
101 pub fn with_strategy_id<S: Into<String>>(mut self, strategy_id: S) -> Self {
102 self.strategy_id = Some(strategy_id.into());
103 self
104 }
105
106 pub fn with_limit(mut self, limit: u64) -> Self {
107 self.limit = Some(limit);
108 self
109 }
110
111 pub fn with_offset(mut self, offset: u64) -> Self {
112 self.offset = Some(offset);
113 self
114 }
115
116 pub fn with_sort_direction(mut self, sort_direction: SortDirection) -> Self {
117 self.sort_direction = Some(sort_direction);
118 self
119 }
120}