1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7pub enum Currency {
8 #[serde(rename = "BTC")]
9 Bitcoin,
10 #[serde(rename = "ETH")]
11 Ethereum,
12 #[serde(rename = "SOL")]
13 Solana,
14 #[serde(rename = "USDC")]
15 UsdCoin,
16 #[serde(rename = "USDT")]
17 Tether,
18}
19
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "lowercase")]
23pub enum InstrumentKind {
24 Future,
25 Option,
26 Spot,
27 FutureCombo,
28 OptionCombo,
29}
30
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33#[serde(rename_all = "lowercase")]
34pub enum OrderSide {
35 Buy,
36 Sell,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
41#[serde(rename_all = "snake_case")]
42pub enum OrderType {
43 Limit,
44 Market,
45 StopLimit,
46 StopMarket,
47 TrailingStop,
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
52#[serde(rename_all = "lowercase")]
53pub enum OrderState {
54 Open,
55 Filled,
56 Rejected,
57 Cancelled,
58 Untriggered,
59 Triggered,
60}
61
62#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
64#[serde(rename_all = "snake_case")]
65pub enum TimeInForce {
66 GoodTillCancelled,
67 GoodTillDay,
68 FillOrKill,
69 ImmediateOrCancel,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct Instrument {
75 pub instrument_name: String,
76 pub kind: InstrumentKind,
77 pub currency: Currency,
78 pub is_active: bool,
79 pub expiration_timestamp: Option<i64>,
80 pub strike: Option<f64>,
81 pub option_type: Option<String>,
82 pub tick_size: f64,
83 pub min_trade_amount: f64,
84 pub contract_size: f64,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct Order {
90 pub order_id: String,
91 pub instrument_name: String,
92 pub direction: OrderSide,
93 pub amount: f64,
94 pub price: Option<f64>,
95 pub order_type: OrderType,
96 pub order_state: OrderState,
97 pub time_in_force: TimeInForce,
98 pub filled_amount: f64,
99 pub average_price: Option<f64>,
100 pub creation_timestamp: i64,
101 pub last_update_timestamp: i64,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106pub struct Trade {
107 pub trade_id: String,
108 pub instrument_name: String,
109 pub order_id: String,
110 pub direction: OrderSide,
111 pub amount: f64,
112 pub price: f64,
113 pub timestamp: i64,
114 pub fee: f64,
115 pub fee_currency: Currency,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120pub struct Position {
121 pub instrument_name: String,
122 pub size: f64,
123 pub direction: OrderSide,
124 pub average_price: f64,
125 pub mark_price: f64,
126 pub unrealized_pnl: f64,
127 pub realized_pnl: f64,
128 pub delta: f64,
129 pub gamma: f64,
130 pub vega: f64,
131 pub theta: f64,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct AccountSummary {
137 pub currency: Currency,
138 pub balance: f64,
139 pub equity: f64,
140 pub available_funds: f64,
141 pub margin_balance: f64,
142 pub unrealized_pnl: f64,
143 pub realized_pnl: f64,
144 pub total_pl: f64,
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149pub struct Tick {
150 pub instrument_name: String,
151 pub timestamp: i64,
152 pub best_bid_price: Option<f64>,
153 pub best_bid_amount: Option<f64>,
154 pub best_ask_price: Option<f64>,
155 pub best_ask_amount: Option<f64>,
156 pub last_price: Option<f64>,
157 pub mark_price: Option<f64>,
158 pub index_price: Option<f64>,
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize)]
163pub struct ApiResponse<T> {
164 pub jsonrpc: String,
165 pub id: Option<serde_json::Value>,
166 pub result: Option<T>,
167 pub error: Option<ApiError>,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
172pub struct ApiError {
173 pub code: i32,
174 pub message: String,
175 pub data: Option<serde_json::Value>,
176}