1use std::{fmt::Display, collections::HashMap};
2use serde::{Serialize, Deserialize};
3use crate::schemas::data_api::InstrumentStatus;
4
5
6#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)]
7pub enum SpotMarket {
9 AAX,
10 ABCC,
11 ACX,
12 AIDOSMARKET,
13 ALPHAEX,
14 ARCHAX,
15 ASCENDEX,
16 ATAIX,
17 BACKPACK,
18 BEQUANT,
19 BGOGO,
20 BIBOX365,
21 BIGONE,
22 BILAXY,
23 BINANCE,
24 BINANCEAGGREGATE,
25 BINANCETR,
26 BINANCEUSA,
27 BINGX,
28 BISQ,
29 BIT,
30 BIT2C,
31 BITBANK,
32 BITBAY,
33 BITBNS,
34 BITBUY,
35 BITCI,
36 BITEXBOOK,
37 BITFEX,
38 BITFINEX,
39 BITFLYER,
40 BITFLYEREU,
41 BITFLYERFX,
42 BITFLYERUS,
43 BITFOREX,
44 BITGET,
45 BITHUMBGLOBAL,
46 BITHUMBKOREA,
47 BITINKA,
48 BITKUB,
49 BITMART,
50 BITMEX,
51 BITPANDA,
52 BITRUE,
53 BITSO,
54 BITSTAMP,
55 BITTREX,
56 BITVAVO,
57 BKEX,
58 BLACKTURTLE,
59 BLEUTRADE,
60 BLOCKCHAINCOM,
61 BTCALPHA,
62 BTCBOX,
63 BTCEX,
64 BTCMARKETS,
65 BTCTURK,
66 BTSE,
67 BUDA,
68 BULLISH,
69 BUYUCOIN,
70 BWEXCHANGE,
71 BYBIT,
72 BYDFI,
73 CATEX,
74 CEXIO,
75 COINBASE,
76 COINBASEINTERNATIONAL,
77 COINCHECK,
78 COINCORNER,
79 COINDCX,
80 COINDEAL,
81 COINEX,
82 COINFALCON,
83 COINFIELD,
84 COINJAR,
85 COINMATE,
86 COINONE,
87 COINSBIT,
88 COINSPRO,
89 COINTIGER,
90 COINW,
91 COSS,
92 CREX24,
93 CROSSTOWER,
94 CRYPTOCARBON,
95 CRYPTODOTCOM,
96 CRYPTOPIA,
97 CRYPTSY,
98 CUBE,
99 CURRENCY,
100 DCOIN,
101 DDEX,
102 DECOIN,
103 DERIBIT,
104 DIGIFINEX,
105 ERISX,
106 ETORO,
107 EXMO,
108 FCOIN,
109 FOXBIT,
110 FTX,
111 FTXUS,
112 GARANTEX,
113 GATEIO,
114 GEMINI,
115 GLOBITEX,
116 GOPAX,
117 GRAVIEX,
118 HASHKEY,
119 HITBTC,
120 HUOBIJAPAN,
121 HUOBIPRO,
122 INDEPENDENTRESERVE,
123 INDODAX,
124 INDOEX,
125 INX,
126 ITBIT,
127 KORBIT,
128 #[default]
129 KRAKEN,
130 KUCOIN,
131 KUNA,
132 LATOKEN,
133 LBANK,
134 LIQNET,
135 LIQUID,
136 LITEBIT,
137 LMAX,
138 LUNO,
139 LYKKE,
140 MERCADOBTC,
141 MERCATOX,
142 MEXC,
143 MOCK,
144 MTGOX,
145 NDAX,
146 NOMINEX,
147 OKCOIN,
148 OKEX,
149 ONETRADING,
150 OSL,
151 OSLHONGKONG,
152 P2PB2B,
153 PANCAKESWAP,
154 PARAMOUNTDAX,
155 PARIBU,
156 PHEMEX,
157 POLONIEX,
158 PROBIT,
159 SAFETRADE,
160 SIGENPRO,
161 SIMEX,
162 SWITCHEO,
163 THEROCKTRADING,
164 TIDEFI,
165 TIMEX,
166 TOKENOMY,
167 TRADEOGRE,
168 UNISWAP,
169 UNOCOIN,
170 UPBIT,
171 VALR,
172 VITEX,
173 WAZIRX,
174 WHITEBIT,
175 WOO,
176 XCOEX,
177 XTPUB,
178 YELLOW,
179 YOBIT,
180 ZAIF,
181 ZBDOTCOM,
182 ZBG,
183 ZEBITEX,
184 ZONDA,
185}
186
187impl Display for SpotMarket {
188 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
189 match self {
190 Self::AAX => write!(f, "aax"),
191 Self::ABCC => write!(f, "abcc"),
192 Self::ACX => write!(f, "acx"),
193 Self::AIDOSMARKET => write!(f, "aidosmarket"),
194 Self::ALPHAEX => write!(f, "alphaex"),
195 Self::ARCHAX => write!(f, "archax"),
196 Self::ASCENDEX => write!(f, "ascendex"),
197 Self::ATAIX => write!(f, "ataix"),
198 Self::BACKPACK => write!(f, "backpack"),
199 Self::BEQUANT => write!(f, "bequant"),
200 Self::BGOGO => write!(f, "bgogo"),
201 Self::BIBOX365 => write!(f, "bibox365"),
202 Self::BIGONE => write!(f, "bigone"),
203 Self::BILAXY => write!(f, "bilaxy"),
204 Self::BINANCE => write!(f, "binance"),
205 Self::BINANCEAGGREGATE => write!(f, "binanceaggreagate"),
206 Self::BINANCETR => write!(f, "binancetr"),
207 Self::BINANCEUSA => write!(f, "binanceusa"),
208 Self::BINGX => write!(f, "bingx"),
209 Self::BISQ => write!(f, "bisq"),
210 Self::BIT => write!(f, "bit"),
211 Self::BIT2C => write!(f, "bit2c"),
212 Self::BITBANK => write!(f, "bitbank"),
213 Self::BITBAY => write!(f, "bitbay"),
214 Self::BITBNS => write!(f, "bitbns"),
215 Self::BITBUY => write!(f, "bitbuy"),
216 Self::BITCI => write!(f, "bitci"),
217 Self::BITEXBOOK => write!(f, "bitexbook"),
218 Self::BITFEX => write!(f, "bitfex"),
219 Self::BITFINEX => write!(f, "bitfinex"),
220 Self::BITFLYER => write!(f, "bitflyer"),
221 Self::BITFLYEREU => write!(f, "bitflyereu"),
222 Self::BITFLYERFX => write!(f, "bitflyerfx"),
223 Self::BITFLYERUS => write!(f, "bitflyerus"),
224 Self::BITFOREX => write!(f, "bitforex"),
225 Self::BITGET => write!(f, "bitget"),
226 Self::BITHUMBGLOBAL => write!(f, "bithumbglobal"),
227 Self::BITHUMBKOREA => write!(f, "bithumbkorea"),
228 Self::BITINKA => write!(f, "bitinka"),
229 Self::BITKUB => write!(f, "bitkub"),
230 Self::BITMART => write!(f, "bitmart"),
231 Self::BITMEX => write!(f, "bitmex"),
232 Self::BITPANDA => write!(f, "bitpanda"),
233 Self::BITRUE => write!(f, "bitrue"),
234 Self::BITSO => write!(f, "bitso"),
235 Self::BITSTAMP => write!(f, "bitstamp"),
236 Self::BITTREX => write!(f, "bittrex"),
237 Self::BITVAVO => write!(f, "bitvavo"),
238 Self::BKEX => write!(f, "bkex"),
239 Self::BLACKTURTLE => write!(f, "blackturtle"),
240 Self::BLEUTRADE => write!(f, "bleutrade"),
241 Self::BLOCKCHAINCOM => write!(f, "blockchaindotcom"),
242 Self::BTCALPHA => write!(f, "btcalpha"),
243 Self::BTCBOX => write!(f, "btcbox"),
244 Self::BTCEX => write!(f, "btcex"),
245 Self::BTCMARKETS => write!(f, "btcmarkets"),
246 Self::BTCTURK => write!(f, "btcturk"),
247 Self::BTSE => write!(f, "btse"),
248 Self::BUDA => write!(f, "buda"),
249 Self::BULLISH => write!(f, "bullish"),
250 Self::BUYUCOIN => write!(f, "buyucoin"),
251 Self::BWEXCHANGE => write!(f, "bwexchange"),
252 Self::BYBIT => write!(f, "bybit"),
253 Self::BYDFI => write!(f, "bydfi"),
254 Self::CATEX => write!(f, "catex"),
255 Self::CEXIO => write!(f, "cexio"),
256 Self::COINBASE => write!(f, "coinbase"),
257 Self::COINBASEINTERNATIONAL => write!(f, "coinbaseinternational"),
258 Self::COINCHECK => write!(f, "coincheck"),
259 Self::COINCORNER => write!(f, "coincorner"),
260 Self::COINDCX => write!(f, "coindcx"),
261 Self::COINDEAL => write!(f, "coindeal"),
262 Self::COINEX => write!(f, "coinex"),
263 Self::COINFALCON => write!(f, "coinfalcon"),
264 Self::COINFIELD => write!(f, "coinfield"),
265 Self::COINJAR => write!(f, "coinjar"),
266 Self::COINMATE => write!(f, "coinmate"),
267 Self::COINONE => write!(f, "coinone"),
268 Self::COINSBIT => write!(f, "coinsbit"),
269 Self::COINSPRO => write!(f, "coinspro"),
270 Self::COINTIGER => write!(f, "cointiger"),
271 Self::COINW => write!(f, "coinw"),
272 Self::COSS => write!(f, "coss"),
273 Self::CREX24 => write!(f, "crex24"),
274 Self::CROSSTOWER => write!(f, "crosstower"),
275 Self::CRYPTOCARBON => write!(f, "cryptocarbon"),
276 Self::CRYPTODOTCOM => write!(f, "cryptodotcom"),
277 Self::CRYPTOPIA => write!(f, "cryptopia"),
278 Self::CRYPTSY => write!(f, "cryptsy"),
279 Self::CUBE => write!(f, "cube"),
280 Self::CURRENCY => write!(f, "currency"),
281 Self::DCOIN => write!(f, "dcoin"),
282 Self::DDEX => write!(f, "ddex"),
283 Self::DECOIN => write!(f, "decoin"),
284 Self::DERIBIT => write!(f, "deribit"),
285 Self::DIGIFINEX => write!(f, "digifinex"),
286 Self::ERISX => write!(f, "erisx"),
287 Self::ETORO => write!(f, "etoro"),
288 Self::EXMO => write!(f, "exmo"),
289 Self::FCOIN => write!(f, "fcoin"),
290 Self::FOXBIT => write!(f, "foxbit"),
291 Self::FTX => write!(f, "ftx"),
292 Self::FTXUS => write!(f, "ftxus"),
293 Self::GARANTEX => write!(f, "garantex"),
294 Self::GATEIO => write!(f, "gateio"),
295 Self::GEMINI => write!(f, "gemini"),
296 Self::GLOBITEX => write!(f, "globitex"),
297 Self::GOPAX => write!(f, "gopax"),
298 Self::GRAVIEX => write!(f, "graviex"),
299 Self::HASHKEY => write!(f, "hashkey"),
300 Self::HITBTC => write!(f, "hitbtc"),
301 Self::HUOBIJAPAN => write!(f, "huobijapan"),
302 Self::HUOBIPRO => write!(f, "huobipro"),
303 Self::INDEPENDENTRESERVE => write!(f, "independentreserve"),
304 Self::INDODAX => write!(f, "indodax"),
305 Self::INDOEX => write!(f, "indoex"),
306 Self::INX => write!(f, "inx"),
307 Self::ITBIT => write!(f, "itbit"),
308 Self::KORBIT => write!(f, "korbit"),
309 Self::KRAKEN => write!(f, "kraken"),
310 Self::KUCOIN => write!(f, "kucoin"),
311 Self::KUNA => write!(f, "kuna"),
312 Self::LATOKEN => write!(f, "latoken"),
313 Self::LBANK => write!(f, "lbank"),
314 Self::LIQNET => write!(f, "liqnet"),
315 Self::LIQUID => write!(f, "liquid"),
316 Self::LITEBIT => write!(f, "litebit"),
317 Self::LMAX => write!(f, "lmax"),
318 Self::LUNO => write!(f, "luno"),
319 Self::LYKKE => write!(f, "lykke"),
320 Self::MERCADOBTC => write!(f, "mercadobtc"),
321 Self::MERCATOX => write!(f, "mercatox"),
322 Self::MEXC => write!(f, "mexc"),
323 Self::MOCK => write!(f, "mock"),
324 Self::MTGOX => write!(f, "mtgox"),
325 Self::NDAX => write!(f, "ndax"),
326 Self::NOMINEX => write!(f, "nominex"),
327 Self::OKCOIN => write!(f, "okcoin"),
328 Self::OKEX => write!(f, "okex"),
329 Self::ONETRADING => write!(f, "onetrading"),
330 Self::OSL => write!(f, "osl"),
331 Self::OSLHONGKONG => write!(f, "oslhongkong"),
332 Self::P2PB2B => write!(f, "p2pb2b"),
333 Self::PANCAKESWAP => write!(f, "pancakeswap"),
334 Self::PARAMOUNTDAX => write!(f, "paramountdax"),
335 Self::PARIBU => write!(f, "paribu"),
336 Self::PHEMEX => write!(f, "phemex"),
337 Self::POLONIEX => write!(f, "poloniex"),
338 Self::PROBIT => write!(f, "probit"),
339 Self::SAFETRADE => write!(f, "safetrade"),
340 Self::SIGENPRO => write!(f, "sigenpro"),
341 Self::SIMEX => write!(f, "simex"),
342 Self::SWITCHEO => write!(f, "switcheo"),
343 Self::THEROCKTRADING => write!(f, "therocktrading"),
344 Self::TIDEFI => write!(f, "tidefi"),
345 Self::TIMEX => write!(f, "timex"),
346 Self::TOKENOMY => write!(f, "tokenomy"),
347 Self::TRADEOGRE => write!(f, "tradeogre"),
348 Self::UNISWAP => write!(f, "uniswap"),
349 Self::UNOCOIN => write!(f, "unocoin"),
350 Self::UPBIT => write!(f, "upbit"),
351 Self::VALR => write!(f, "valr"),
352 Self::VITEX => write!(f, "vitex"),
353 Self::WAZIRX => write!(f, "waxirx"),
354 Self::WHITEBIT => write!(f, "whitebit"),
355 Self::WOO => write!(f, "woo"),
356 Self::XCOEX => write!(f, "xcoex"),
357 Self::XTPUB => write!(f, "xtpub"),
358 Self::YELLOW => write!(f, "yellow"),
359 Self::YOBIT => write!(f, "yobit"),
360 Self::ZAIF => write!(f, "zaif"),
361 Self::ZBDOTCOM => write!(f, "zbdotcom"),
362 Self::ZBG => write!(f, "zbg"),
363 Self::ZEBITEX => write!(f, "zebitex"),
364 Self::ZONDA => write!(f, "zonda"),
365 }
366 }
367}
368
369
370#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)]
371pub enum SpotInstrumentStatus {
373 #[default]
374 ACTIVE,
375 IGNORED,
376 RETIRED,
377 EXPIRED,
378 READYFORDECOMMISSIONING,
379}
380
381impl Display for SpotInstrumentStatus {
382 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
383 match self {
384 Self::ACTIVE => write!(f, "ACTIVE"),
385 Self::IGNORED => write!(f, "IGNORED"),
386 Self::RETIRED => write!(f, "RETIRED"),
387 Self::EXPIRED => write!(f, "EXPIRED"),
388 Self::READYFORDECOMMISSIONING => write!(f, "READY_FOR_DECOMMISSIONING"),
389 }
390 }
391}
392
393
394#[derive(Clone, Debug, Serialize, Deserialize)]
395pub struct SpotInstrumentMapping {
396 #[serde(rename = "MAPPED_INSTRUMENT")]
397 pub mapped_instrument: String,
399 #[serde(rename = "BASE")]
400 pub base: String,
402 #[serde(rename = "BASE_ID")]
403 pub base_id: i32,
406 #[serde(rename = "QUOTE")]
407 pub quote: String,
409 #[serde(rename = "QUOTE_ID")]
410 pub quote_id: i32,
413 #[serde(rename = "TRANSFORM_FUNCTION")]
414 pub transform_function: String,
416 #[serde(rename = "CREATED_ON")]
417 pub created_on: i64,
419}
420
421
422#[derive(Clone, Debug, Serialize, Deserialize)]
427pub struct SpotOHLCV {
428 #[serde(rename = "UNIT")]
429 pub unit: String,
431 #[serde(rename = "TIMESTAMP")]
432 pub timestamp: i64,
435 #[serde(rename = "TYPE")]
436 pub type_: String,
438 #[serde(rename = "MARKET")]
439 pub market: String,
441 #[serde(rename = "INSTRUMENT")]
442 pub instrument: String,
444 #[serde(rename = "MAPPED_INSTRUMENT")]
445 pub mapped_instrument: String,
447 #[serde(rename = "BASE")]
448 pub base: String,
451 #[serde(rename = "QUOTE")]
452 pub quote: String,
455 #[serde(rename = "BASE_ID")]
456 pub base_id: i32,
459 #[serde(rename = "QUOTE_ID")]
460 pub quote_id: i32,
463 #[serde(rename = "TRANSFORM_FUNCTION")]
464 pub transform_function: String,
467 #[serde(rename = "OPEN")]
468 pub open: f64,
470 #[serde(rename = "HIGH")]
471 pub high: f64,
473 #[serde(rename = "LOW")]
474 pub low: f64,
476 #[serde(rename = "CLOSE")]
477 pub close: f64,
479 #[serde(rename = "FIRST_TRADE_TIMESTAMP")]
480 pub first_trade_timestamp: Option<i64>,
482 #[serde(rename = "LAST_TRADE_TIMESTAMP")]
483 pub last_trade_timestamp: Option<i64>,
485 #[serde(rename = "FIRST_TRADE_PRICE")]
486 pub first_trade_price: Option<f64>,
488 #[serde(rename = "HIGH_TRADE_PRICE")]
489 pub high_trade_price: Option<f64>,
491 #[serde(rename = "HIGH_TRADE_TIMESTAMP")]
492 pub high_trade_timestamp: Option<i64>,
494 #[serde(rename = "LOW_TRADE_PRICE")]
495 pub low_trade_price: Option<f64>,
497 #[serde(rename = "LOW_TRADE_TIMESTAMP")]
498 pub low_trade_timestamp: Option<i64>,
500 #[serde(rename = "LAST_TRADE_PRICE")]
501 pub last_trade_price: Option<f64>,
503 #[serde(rename = "TOTAL_TRADES")]
504 pub total_trades: i64,
506 #[serde(rename = "TOTAL_TRADES_BUY")]
507 pub total_trades_buy: i64,
509 #[serde(rename = "TOTAL_TRADES_SELL")]
510 pub total_trades_sell: i64,
512 #[serde(rename = "TOTAL_TRADES_UNKNOWN")]
513 pub total_trades_unknown: i64,
515 #[serde(rename = "VOLUME")]
516 pub volume: f64,
519 #[serde(rename = "QUOTE_VOLUME")]
520 pub quote_volume: f64,
523 #[serde(rename = "VOLUME_BUY")]
524 pub volume_buy: f64,
526 #[serde(rename = "QUOTE_VOLUME_BUY")]
527 pub quote_volume_buy: f64,
529 #[serde(rename = "VOLUME_SELL")]
530 pub volume_sell: f64,
532 #[serde(rename = "QUOTE_VOLUME_SELL")]
533 pub quote_volume_sell: f64,
535 #[serde(rename = "VOLUME_UNKNOWN")]
536 pub volume_unknown: f64,
538 #[serde(rename = "QUOTE_VOLUME_UNKNOWN")]
539 pub quote_volume_unknown: f64,
541}
542
543
544#[derive(Clone, Debug, Serialize, Deserialize)]
549pub struct SpotInstrumentMetdata {
550 #[serde(rename = "METADATA_VERSION")]
551 pub metadata_version: usize,
553 #[serde(rename = "INSTRUMENT_STATUS")]
554 pub instrument_status: String,
557 #[serde(rename = "FIRST_SEEN_ON_POLLING_TS")]
558 pub first_seen_on_pollings_ts: i64,
560 #[serde(rename = "LAST_SEEN_ON_POLLING_TS")]
561 pub last_seen_pollings_ts: i64,
563 #[serde(rename = "INSTRUMENT")]
564 pub instrument: String,
566 #[serde(rename = "INSTRUMENT_MAPPING")]
567 pub instrument_mapping: SpotInstrumentMapping,
569 #[serde(rename = "INSTRUMENT_EXTERNAL_DATA")]
570 pub instrument_external_data: String,
572 #[serde(rename = "FIRST_OB_L2_MINUTE_SNAPSHOT_TS")]
573 pub first_ob_l2_minute_snapshot_ts: Option<i64>,
575}
576
577
578#[derive(Clone, Debug, Serialize, Deserialize)]
583pub struct SpotMarkets {
584 #[serde(rename = "TYPE")]
585 pub type_: String,
587 #[serde(rename = "EXCHANGE_STATUS")]
588 pub exchange_status: String,
590 #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
591 pub mapped_instrument_total: i64,
595 #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
596 pub unmapped_instruments_total: i64,
598 #[serde(rename = "INSTRUMENT_STATUS")]
599 pub instrument_status: InstrumentStatus,
601 #[serde(rename = "TOTAL_TRADES_SPOT")]
602 pub total_trades_spot: i64,
604 #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
605 pub has_orderbook_l2_minute_snapshots_enabled: bool,
607}
608
609
610#[derive(Clone, Debug, Serialize, Deserialize)]
614pub struct Instrument {
615 #[serde(rename = "TYPE")]
616 pub type_: String,
618 #[serde(rename = "INSTRUMENT_STATUS")]
619 pub instrument_status: String,
621 #[serde(rename = "INSTRUMENT")]
622 pub instrument: String,
624 #[serde(rename = "HISTO_SHARD")]
625 pub histo_shard: String,
628 #[serde(rename = "MAPPED_INSTRUMENT")]
629 pub mapped_instrument: String,
631 #[serde(rename = "INSTRUMENT_MAPPING")]
632 pub instrument_mapping: SpotInstrumentMapping,
634 #[serde(rename = "HAS_TRADES_SPOT")]
635 pub has_trades_spot: bool,
637 #[serde(rename = "FIRST_TRADE_SPOT_TIMESTAMP")]
638 pub first_trade_spot_timestamp: i64,
640 #[serde(rename = "LAST_TRADE_SPOT_TIMESTAMP")]
641 pub last_trade_spot_timestamp: i64,
643 #[serde(rename = "TOTAL_TRADES_SPOT")]
644 pub total_trades_spot: i64,
646}
647
648
649#[derive(Clone, Debug, Serialize, Deserialize)]
651pub struct SpotMarketsInstruments {
652 #[serde(rename = "TYPE")]
653 pub type_: String,
655 #[serde(rename = "EXCHANGE_STATUS")]
656 pub exchange_status: String,
658 #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
659 pub mapped_instrument_total: i64,
663 #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
664 pub unmapped_instruments_total: i64,
666 #[serde(rename = "INSTRUMENT_STATUS")]
667 pub instrument_status: InstrumentStatus,
669 #[serde(rename = "TOTAL_TRADES_SPOT")]
670 pub total_trades_spot: i64,
672 #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
673 pub has_orderbook_l2_minute_snapshots_enabled: bool,
675 #[serde(rename = "instruments")]
676 pub instruments: HashMap<String, Instrument>,
678}