rusty_feeder/exchange/binance/spot/
types.rs1use crate::provider::prelude::*;
7use smartstring::alias::String;
8
9pub const BINANCE_SPOT_API_URL: &str = "https://api.binance.com";
11
12pub const BINANCE_SPOT_WS_URL: &str = "wss://stream.binance.com:9443/ws";
14
15pub const BINANCE_SPOT_WS_COMBINED_URL: &str = "wss://stream.binance.com:9443/stream";
17
18pub const BINANCE_SPOT_RATE_LIMITS: &[RateLimit] = &[
20 RateLimit {
21 limit_type: "REQUEST_WEIGHT",
22 interval: "MINUTE",
23 interval_num: 1,
24 limit: 1200,
25 },
26 RateLimit {
27 limit_type: "RAW_REQUESTS",
28 interval: "MINUTE",
29 interval_num: 5,
30 limit: 6100,
31 },
32 RateLimit {
33 limit_type: "ORDERS",
34 interval: "SECOND",
35 interval_num: 10,
36 limit: 50,
37 },
38 RateLimit {
39 limit_type: "ORDERS",
40 interval: "DAY",
41 interval_num: 1,
42 limit: 160000,
43 },
44];
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48pub enum BinanceOrderType {
49 Limit,
51
52 Market,
54
55 StopLoss,
57
58 StopLossLimit,
60
61 TakeProfit,
63
64 TakeProfitLimit,
66
67 LimitMaker,
69}
70
71impl BinanceOrderType {
72 pub const fn as_str(&self) -> &'static str {
74 match self {
75 BinanceOrderType::Limit => "LIMIT",
76 BinanceOrderType::Market => "MARKET",
77 BinanceOrderType::StopLoss => "STOP_LOSS",
78 BinanceOrderType::StopLossLimit => "STOP_LOSS_LIMIT",
79 BinanceOrderType::TakeProfit => "TAKE_PROFIT",
80 BinanceOrderType::TakeProfitLimit => "TAKE_PROFIT_LIMIT",
81 BinanceOrderType::LimitMaker => "LIMIT_MAKER",
82 }
83 }
84
85 pub fn to_smartstring(&self) -> String {
87 self.as_str().into()
88 }
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq)]
93pub enum BinanceOrderSide {
94 Buy,
96
97 Sell,
99}
100
101impl BinanceOrderSide {
102 pub const fn as_str(&self) -> &'static str {
104 match self {
105 BinanceOrderSide::Buy => "BUY",
106 BinanceOrderSide::Sell => "SELL",
107 }
108 }
109
110 pub fn to_smartstring(&self) -> String {
112 self.as_str().into()
113 }
114}
115
116#[derive(Debug, Clone, Copy, PartialEq, Eq)]
118pub enum BinanceTimeInForce {
119 GTC,
121
122 IOC,
124
125 FOK,
127}
128
129impl BinanceTimeInForce {
130 pub const fn as_str(&self) -> &'static str {
132 match self {
133 BinanceTimeInForce::GTC => "GTC",
134 BinanceTimeInForce::IOC => "IOC",
135 BinanceTimeInForce::FOK => "FOK",
136 }
137 }
138
139 pub fn to_smartstring(&self) -> String {
141 self.as_str().into()
142 }
143}
144
145#[derive(Debug, Clone, Copy, PartialEq, Eq)]
147pub enum BinanceOrderStatus {
148 New,
150
151 PartiallyFilled,
153
154 Filled,
156
157 Canceled,
159
160 PendingCancel,
162
163 Rejected,
165
166 Expired,
168}
169
170impl BinanceOrderStatus {
171 pub const fn as_str(&self) -> &'static str {
173 match self {
174 BinanceOrderStatus::New => "NEW",
175 BinanceOrderStatus::PartiallyFilled => "PARTIALLY_FILLED",
176 BinanceOrderStatus::Filled => "FILLED",
177 BinanceOrderStatus::Canceled => "CANCELED",
178 BinanceOrderStatus::PendingCancel => "PENDING_CANCEL",
179 BinanceOrderStatus::Rejected => "REJECTED",
180 BinanceOrderStatus::Expired => "EXPIRED",
181 }
182 }
183
184 pub fn to_smartstring(&self) -> String {
186 self.as_str().into()
187 }
188}
189
190#[derive(Debug, Clone, Copy, PartialEq, Eq)]
192pub enum BinanceKlineInterval {
193 Minute1,
195
196 Minute3,
198
199 Minute5,
201
202 Minute15,
204
205 Minute30,
207
208 Hour1,
210
211 Hour2,
213
214 Hour4,
216
217 Hour6,
219
220 Hour8,
222
223 Hour12,
225
226 Day1,
228
229 Day3,
231
232 Week1,
234
235 Month1,
237}
238
239impl BinanceKlineInterval {
240 pub const fn as_str(&self) -> &'static str {
242 match self {
243 BinanceKlineInterval::Minute1 => "1m",
244 BinanceKlineInterval::Minute3 => "3m",
245 BinanceKlineInterval::Minute5 => "5m",
246 BinanceKlineInterval::Minute15 => "15m",
247 BinanceKlineInterval::Minute30 => "30m",
248 BinanceKlineInterval::Hour1 => "1h",
249 BinanceKlineInterval::Hour2 => "2h",
250 BinanceKlineInterval::Hour4 => "4h",
251 BinanceKlineInterval::Hour6 => "6h",
252 BinanceKlineInterval::Hour8 => "8h",
253 BinanceKlineInterval::Hour12 => "12h",
254 BinanceKlineInterval::Day1 => "1d",
255 BinanceKlineInterval::Day3 => "3d",
256 BinanceKlineInterval::Week1 => "1w",
257 BinanceKlineInterval::Month1 => "1M",
258 }
259 }
260
261 pub fn to_smartstring(&self) -> String {
263 self.as_str().into()
264 }
265}