ccdata_api/schemas/data_api/
spot.rs

1use std::collections::HashMap;
2use serde::Deserialize;
3use crate::utils::Market;
4use crate::schemas::data_api::CCInstrumentStatus;
5
6
7/// The exchange to obtain data from.
8pub enum CCSpotMarket {
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    KRAKEN,
129    KUCOIN,
130    KUNA,
131    LATOKEN,
132    LBANK,
133    LIQNET,
134    LIQUID,
135    LITEBIT,
136    LMAX,
137    LUNO,
138    LYKKE,
139    MERCADOBTC,
140    MERCATOX,
141    MEXC,
142    MOCK,
143    MTGOX,
144    NDAX,
145    NOMINEX,
146    OKCOIN,
147    OKEX,
148    ONETRADING,
149    OSL,
150    OSLHONGKONG,
151    P2PB2B,
152    PANCAKESWAP,
153    PARAMOUNTDAX,
154    PARIBU,
155    PHEMEX,
156    POLONIEX,
157    PROBIT,
158    SAFETRADE,
159    SIGENPRO,
160    SIMEX,
161    SWITCHEO,
162    THEROCKTRADING,
163    TIDEFI,
164    TIMEX,
165    TOKENOMY,
166    TRADEOGRE,
167    UNISWAP,
168    UNOCOIN,
169    UPBIT,
170    VALR,
171    VITEX,
172    WAZIRX,
173    WHITEBIT,
174    WOO,
175    XCOEX,
176    XTPUB,
177    YELLOW,
178    YOBIT,
179    ZAIF,
180    ZBDOTCOM,
181    ZBG,
182    ZEBITEX,
183    ZONDA,
184}
185
186impl Market for CCSpotMarket {
187    /// Converts enum value to `String`.
188    fn to_string(&self) -> String {
189        match self {
190            CCSpotMarket::AAX => String::from("aax"),
191            CCSpotMarket::ABCC => String::from("abcc"),
192            CCSpotMarket::ACX => String::from("acx"),
193            CCSpotMarket::AIDOSMARKET => String::from("aidosmarket"),
194            CCSpotMarket::ALPHAEX => String::from("alphaex"),
195            CCSpotMarket::ARCHAX => String::from("archax"),
196            CCSpotMarket::ASCENDEX => String::from("ascendex"),
197            CCSpotMarket::ATAIX => String::from("ataix"),
198            CCSpotMarket::BACKPACK => String::from("backpack"),
199            CCSpotMarket::BEQUANT => String::from("bequant"),
200            CCSpotMarket::BGOGO => String::from("bgogo"),
201            CCSpotMarket::BIBOX365 => String::from("bibox365"),
202            CCSpotMarket::BIGONE => String::from("bigone"),
203            CCSpotMarket::BILAXY => String::from("bilaxy"),
204            CCSpotMarket::BINANCE => String::from("binance"),
205            CCSpotMarket::BINANCEAGGREGATE => String::from("binanceaggreagate"),
206            CCSpotMarket::BINANCETR => String::from("binancetr"),
207            CCSpotMarket::BINANCEUSA => String::from("binanceusa"),
208            CCSpotMarket::BINGX => String::from("bingx"),
209            CCSpotMarket::BISQ => String::from("bisq"),
210            CCSpotMarket::BIT => String::from("bit"),
211            CCSpotMarket::BIT2C => String::from("bit2c"),
212            CCSpotMarket::BITBANK => String::from("bitbank"),
213            CCSpotMarket::BITBAY => String::from("bitbay"),
214            CCSpotMarket::BITBNS => String::from("bitbns"),
215            CCSpotMarket::BITBUY => String::from("bitbuy"),
216            CCSpotMarket::BITCI => String::from("bitci"),
217            CCSpotMarket::BITEXBOOK => String::from("bitexbook"),
218            CCSpotMarket::BITFEX => String::from("bitfex"),
219            CCSpotMarket::BITFINEX => String::from("bitfinex"),
220            CCSpotMarket::BITFLYER => String::from("bitflyer"),
221            CCSpotMarket::BITFLYEREU => String::from("bitflyereu"),
222            CCSpotMarket::BITFLYERFX => String::from("bitflyerfx"),
223            CCSpotMarket::BITFLYERUS => String::from("bitflyerus"),
224            CCSpotMarket::BITFOREX => String::from("bitforex"),
225            CCSpotMarket::BITGET => String::from("bitget"),
226            CCSpotMarket::BITHUMBGLOBAL => String::from("bithumbglobal"),
227            CCSpotMarket::BITHUMBKOREA => String::from("bithumbkorea"),
228            CCSpotMarket::BITINKA => String::from("bitinka"),
229            CCSpotMarket::BITKUB => String::from("bitkub"),
230            CCSpotMarket::BITMART => String::from("bitmart"),
231            CCSpotMarket::BITMEX => String::from("bitmex"),
232            CCSpotMarket::BITPANDA => String::from("bitpanda"),
233            CCSpotMarket::BITRUE => String::from("bitrue"),
234            CCSpotMarket::BITSO => String::from("bitso"),
235            CCSpotMarket::BITSTAMP => String::from("bitstamp"),
236            CCSpotMarket::BITTREX => String::from("bittrex"),
237            CCSpotMarket::BITVAVO => String::from("bitvavo"),
238            CCSpotMarket::BKEX => String::from("bkex"),
239            CCSpotMarket::BLACKTURTLE => String::from("blackturtle"),
240            CCSpotMarket::BLEUTRADE => String::from("bleutrade"),
241            CCSpotMarket::BLOCKCHAINCOM => String::from("blockchaindotcom"),
242            CCSpotMarket::BTCALPHA => String::from("btcalpha"),
243            CCSpotMarket::BTCBOX => String::from("btcbox"),
244            CCSpotMarket::BTCEX => String::from("btcex"),
245            CCSpotMarket::BTCMARKETS => String::from("btcmarkets"),
246            CCSpotMarket::BTCTURK => String::from("btcturk"),
247            CCSpotMarket::BTSE => String::from("btse"),
248            CCSpotMarket::BUDA => String::from("buda"),
249            CCSpotMarket::BULLISH => String::from("bullish"),
250            CCSpotMarket::BUYUCOIN => String::from("buyucoin"),
251            CCSpotMarket::BWEXCHANGE => String::from("bwexchange"),
252            CCSpotMarket::BYBIT => String::from("bybit"),
253            CCSpotMarket::BYDFI => String::from("bydfi"),
254            CCSpotMarket::CATEX => String::from("catex"),
255            CCSpotMarket::CEXIO => String::from("cexio"),
256            CCSpotMarket::COINBASE => String::from("coinbase"),
257            CCSpotMarket::COINBASEINTERNATIONAL => String::from("coinbaseinternational"),
258            CCSpotMarket::COINCHECK => String::from("coincheck"),
259            CCSpotMarket::COINCORNER => String::from("coincorner"),
260            CCSpotMarket::COINDCX => String::from("coindcx"),
261            CCSpotMarket::COINDEAL => String::from("coindeal"),
262            CCSpotMarket::COINEX => String::from("coinex"),
263            CCSpotMarket::COINFALCON => String::from("coinfalcon"),
264            CCSpotMarket::COINFIELD => String::from("coinfield"),
265            CCSpotMarket::COINJAR => String::from("coinjar"),
266            CCSpotMarket::COINMATE => String::from("coinmate"),
267            CCSpotMarket::COINONE => String::from("coinone"),
268            CCSpotMarket::COINSBIT => String::from("coinsbit"),
269            CCSpotMarket::COINSPRO => String::from("coinspro"),
270            CCSpotMarket::COINTIGER => String::from("cointiger"),
271            CCSpotMarket::COINW => String::from("coinw"),
272            CCSpotMarket::COSS => String::from("coss"),
273            CCSpotMarket::CREX24 => String::from("crex24"),
274            CCSpotMarket::CROSSTOWER => String::from("crosstower"),
275            CCSpotMarket::CRYPTOCARBON => String::from("cryptocarbon"),
276            CCSpotMarket::CRYPTODOTCOM => String::from("cryptodotcom"),
277            CCSpotMarket::CRYPTOPIA => String::from("cryptopia"),
278            CCSpotMarket::CRYPTSY => String::from("cryptsy"),
279            CCSpotMarket::CUBE => String::from("cube"),
280            CCSpotMarket::CURRENCY => String::from("currency"),
281            CCSpotMarket::DCOIN => String::from("dcoin"),
282            CCSpotMarket::DDEX => String::from("ddex"),
283            CCSpotMarket::DECOIN => String::from("decoin"),
284            CCSpotMarket::DERIBIT => String::from("deribit"),
285            CCSpotMarket::DIGIFINEX => String::from("digifinex"),
286            CCSpotMarket::ERISX => String::from("erisx"),
287            CCSpotMarket::ETORO => String::from("etoro"),
288            CCSpotMarket::EXMO => String::from("exmo"),
289            CCSpotMarket::FCOIN => String::from("fcoin"),
290            CCSpotMarket::FOXBIT => String::from("foxbit"),
291            CCSpotMarket::FTX => String::from("ftx"),
292            CCSpotMarket::FTXUS => String::from("ftxus"),
293            CCSpotMarket::GARANTEX => String::from("garantex"),
294            CCSpotMarket::GATEIO => String::from("gateio"),
295            CCSpotMarket::GEMINI => String::from("gemini"),
296            CCSpotMarket::GLOBITEX => String::from("globitex"),
297            CCSpotMarket::GOPAX => String::from("gopax"),
298            CCSpotMarket::GRAVIEX => String::from("graviex"),
299            CCSpotMarket::HASHKEY => String::from("hashkey"),
300            CCSpotMarket::HITBTC => String::from("hitbtc"),
301            CCSpotMarket::HUOBIJAPAN => String::from("huobijapan"),
302            CCSpotMarket::HUOBIPRO => String::from("huobipro"),
303            CCSpotMarket::INDEPENDENTRESERVE => String::from("independentreserve"),
304            CCSpotMarket::INDODAX => String::from("indodax"),
305            CCSpotMarket::INDOEX => String::from("indoex"),
306            CCSpotMarket::INX => String::from("inx"),
307            CCSpotMarket::ITBIT => String::from("itbit"),
308            CCSpotMarket::KORBIT => String::from("korbit"),
309            CCSpotMarket::KRAKEN => String::from("kraken"),
310            CCSpotMarket::KUCOIN => String::from("kucoin"),
311            CCSpotMarket::KUNA => String::from("kuna"),
312            CCSpotMarket::LATOKEN => String::from("latoken"),
313            CCSpotMarket::LBANK => String::from("lbank"),
314            CCSpotMarket::LIQNET => String::from("liqnet"),
315            CCSpotMarket::LIQUID => String::from("liquid"),
316            CCSpotMarket::LITEBIT => String::from("litebit"),
317            CCSpotMarket::LMAX => String::from("lmax"),
318            CCSpotMarket::LUNO => String::from("luno"),
319            CCSpotMarket::LYKKE => String::from("lykke"),
320            CCSpotMarket::MERCADOBTC => String::from("mercadobtc"),
321            CCSpotMarket::MERCATOX => String::from("mercatox"),
322            CCSpotMarket::MEXC => String::from("mexc"),
323            CCSpotMarket::MOCK => String::from("mock"),
324            CCSpotMarket::MTGOX => String::from("mtgox"),
325            CCSpotMarket::NDAX => String::from("ndax"),
326            CCSpotMarket::NOMINEX => String::from("nominex"),
327            CCSpotMarket::OKCOIN => String::from("okcoin"),
328            CCSpotMarket::OKEX => String::from("okex"),
329            CCSpotMarket::ONETRADING => String::from("onetrading"),
330            CCSpotMarket::OSL => String::from("osl"),
331            CCSpotMarket::OSLHONGKONG => String::from("oslhongkong"),
332            CCSpotMarket::P2PB2B => String::from("p2pb2b"),
333            CCSpotMarket::PANCAKESWAP => String::from("pancakeswap"),
334            CCSpotMarket::PARAMOUNTDAX => String::from("paramountdax"),
335            CCSpotMarket::PARIBU => String::from("paribu"),
336            CCSpotMarket::PHEMEX => String::from("phemex"),
337            CCSpotMarket::POLONIEX => String::from("poloniex"),
338            CCSpotMarket::PROBIT => String::from("probit"),
339            CCSpotMarket::SAFETRADE => String::from("safetrade"),
340            CCSpotMarket::SIGENPRO => String::from("sigenpro"),
341            CCSpotMarket::SIMEX => String::from("simex"),
342            CCSpotMarket::SWITCHEO => String::from("switcheo"),
343            CCSpotMarket::THEROCKTRADING => String::from("therocktrading"),
344            CCSpotMarket::TIDEFI => String::from("tidefi"),
345            CCSpotMarket::TIMEX => String::from("timex"),
346            CCSpotMarket::TOKENOMY => String::from("tokenomy"),
347            CCSpotMarket::TRADEOGRE => String::from("tradeogre"),
348            CCSpotMarket::UNISWAP => String::from("uniswap"),
349            CCSpotMarket::UNOCOIN => String::from("unocoin"),
350            CCSpotMarket::UPBIT => String::from("upbit"),
351            CCSpotMarket::VALR => String::from("valr"),
352            CCSpotMarket::VITEX => String::from("vitex"),
353            CCSpotMarket::WAZIRX => String::from("waxirx"),
354            CCSpotMarket::WHITEBIT => String::from("whitebit"),
355            CCSpotMarket::WOO => String::from("woo"),
356            CCSpotMarket::XCOEX => String::from("xcoex"),
357            CCSpotMarket::XTPUB => String::from("xtpub"),
358            CCSpotMarket::YELLOW => String::from("yellow"),
359            CCSpotMarket::YOBIT => String::from("yobit"),
360            CCSpotMarket::ZAIF => String::from("zaif"),
361            CCSpotMarket::ZBDOTCOM => String::from("zbdotcom"),
362            CCSpotMarket::ZBG => String::from("zbg"),
363            CCSpotMarket::ZEBITEX => String::from("zebitex"),
364            CCSpotMarket::ZONDA => String::from("zonda"),
365        }
366    }
367}
368
369
370/// The status of the instrument, can be one of the following: ACTIVE, IGNORED, RETIRED, EXPIRED.
371pub enum CCSpotInstrumentStatus {
372    ACTIVE,
373    IGNORED,
374    RETIRED,
375    EXPIRED,
376    READYFORDECOMMISSIONING,
377}
378
379impl CCSpotInstrumentStatus {
380    /// Converts enum value to `String`.
381    pub fn to_string(&self) -> String {
382        match self {
383            CCSpotInstrumentStatus::ACTIVE => String::from("ACTIVE"),
384            CCSpotInstrumentStatus::IGNORED => String::from("IGNORED"),
385            CCSpotInstrumentStatus::RETIRED => String::from("RETIRED"),
386            CCSpotInstrumentStatus::EXPIRED => String::from("EXPIRED"),
387            CCSpotInstrumentStatus::READYFORDECOMMISSIONING => String::from("READY_FOR_DECOMMISSIONING"),
388        }
389    }
390}
391
392
393#[derive(Deserialize, Debug)]
394pub struct CCInstrumentMapping {
395    #[serde(rename = "MAPPED_INSTRUMENT")]
396    /// The current mapping dsv for this instrument.
397    pub mapped_instrument: String,
398    #[serde(rename = "BASE")]
399    /// The current mapping information for this instrument.
400    pub base: String,
401    #[serde(rename = "BASE_ID")]
402    /// Represents the internal CCData ID for the base asset or coin (e.g., 1 for BTC). This ID is unique and immutable,
403    /// ensuring consistent identification. Applicable only to instruments with a mapping.
404    pub base_id: i32,
405    #[serde(rename = "QUOTE")]
406    /// The current mapping vs for this instrument.
407    pub quote: String,
408    #[serde(rename = "QUOTE_ID")]
409    /// Represents the internal CCData ID for the quote asset or counter coin (e.g., 5 for USD). This ID is unique and immutable,
410    /// ensuring consistent identification. Applicable only to instruments with a mapping.
411    pub quote_id: i32,
412    #[serde(rename = "TRANSFORM_FUNCTION")]
413    /// The current mapping vsscds for this instrument.
414    pub transform_function: String,
415    #[serde(rename = "CREATED_ON")]
416    /// Timestamp for when this mapping was created.
417    pub created_on: i64,
418}
419
420
421// Spot: Historical OHLCV+
422
423
424/// Spot: Historical OHLCV+
425#[derive(Deserialize, Debug)]
426pub struct CCSpotOHLCV {
427    #[serde(rename = "UNIT")]
428    /// The unit of the historical period update: MINUTE for minute, HOUR for hour and DAY for day.
429    pub unit: String,
430    #[serde(rename = "TIMESTAMP")]
431    /// The timestamp in seconds of the beginning of the histo period. For minute it would be every minute at the beginning of the minute,
432    /// for hour it would be the start of the hour and for daily it is 00:00 GMT.
433    pub timestamp: i64,
434    #[serde(rename = "TYPE")]
435    /// The type of message this is. It helps identify the nature of the data being returned.
436    pub type_: String,
437    #[serde(rename = "MARKET")]
438    /// The market / exchange under consideration (e.g. gemini, kraken, coinbase, etc).
439    pub market: String,
440    #[serde(rename = "INSTRUMENT")]
441    /// The unmapped instrument ID.
442    pub instrument: String,
443    #[serde(rename = "MAPPED_INSTRUMENT")]
444    /// The instrument ID, as derived from our mapping rules. This takes the form "BASE-QUOTE" (e.g. BTC-USD). Only available on instruments that have been mapped.
445    pub mapped_instrument: String,
446    #[serde(rename = "BASE")]
447    /// Represents the base asset or coin symbol, commonly known as the ticker (e.g., BTC). This symbol may change in cases of asset rebranding.
448    /// Applicable only to instruments with a mapping.
449    pub base: String,
450    #[serde(rename = "QUOTE")]
451    /// Represents the quote asset or counter coin symbol, commonly known as the ticker (e.g., USD). This symbol may change in cases of asset rebranding.
452    /// Applicable only to instruments with a mapping.
453    pub quote: String,
454    #[serde(rename = "BASE_ID")]
455    /// Represents the internal CCData ID for the base asset or coin (e.g., 1 for BTC). This ID is unique and immutable, ensuring consistent identification.
456    /// Applicable only to instruments with a mapping.
457    pub base_id: i32,
458    #[serde(rename = "QUOTE_ID")]
459    /// Represents the internal CCData ID for the quote asset or counter coin (e.g., 5 for USD). This ID is unique and immutable, ensuring consistent identification.
460    /// Applicable only to instruments with a mapping.
461    pub quote_id: i32,
462    #[serde(rename = "TRANSFORM_FUNCTION")]
463    /// The transform function. This is the function we apply when we do mapping to change values into easier human readable ones and to make sure the
464    /// mapped direction BASE - QUOTE is constant accross all instruments.
465    pub transform_function: String,
466    #[serde(rename = "OPEN")]
467    /// The open price for the historical period, this is based on the closest trade before the period start.
468    pub open: f64,
469    #[serde(rename = "HIGH")]
470    /// The highest trade price in the time period. If there were no trades in the time period, the open price will be given.
471    pub high: f64,
472    #[serde(rename = "LOW")]
473    /// The lowest trade price in the time period. If there were no trades in the time period, the open price will be given.
474    pub low: f64,
475    #[serde(rename = "CLOSE")]
476    /// The price of the last trade in this time period. If there were no trades in the time period, the open price will be given.
477    pub close: f64,
478    #[serde(rename = "FIRST_TRADE_TIMESTAMP")]
479    /// The timestamp, in seconds, of the first trade in this time perio. This is only available when there is at least one trade in the time period.
480    pub first_trade_timestamp: Option<i64>,
481    #[serde(rename = "LAST_TRADE_TIMESTAMP")]
482    /// The timestamp, in seconds, of the last trade in this time period. This is only available when there is at least one trade in the time period.
483    pub last_trade_timestamp: Option<i64>,
484    #[serde(rename = "FIRST_TRADE_PRICE")]
485    /// The price of the first trade in the time period. This is only available when there is at least one trade in the time period.
486    pub first_trade_price: Option<f64>,
487    #[serde(rename = "HIGH_TRADE_PRICE")]
488    /// The highest value of the trades in the time period. This is only available when there is at least one trade in the time period.
489    pub high_trade_price: Option<f64>,
490    #[serde(rename = "HIGH_TRADE_TIMESTAMP")]
491    /// The timestamp, in seconds, of the highest trade in the time period. This is only available when there is at least one trade in the time period.
492    pub high_trade_timestamp: Option<i64>,
493    #[serde(rename = "LOW_TRADE_PRICE")]
494    /// The lowest value of the trades in the time period. This is only available when there is at least one trade in the time period.
495    pub low_trade_price: Option<f64>,
496    #[serde(rename = "LOW_TRADE_TIMESTAMP")]
497    /// The timestamp, in seconds, of the lowest trade in the time period. This is only available when there is at least one trade in the time period.
498    pub low_trade_timestamp: Option<i64>,
499    #[serde(rename = "LAST_TRADE_PRICE")]
500    /// The last trade price in the time period. This is only available when there is at least one trade in the time period.
501    pub last_trade_price: Option<f64>,
502    #[serde(rename = "TOTAL_TRADES")]
503    /// The total number of trades seen in this time period. If there were no trades in the time period, 0 will be returned.
504    pub total_trades: i64,
505    #[serde(rename = "TOTAL_TRADES_BUY")]
506    /// The total number of BUY trades seen in this time period. If there were no trades in the time period, 0 will be returned.
507    pub total_trades_buy: i64,
508    #[serde(rename = "TOTAL_TRADES_SELL")]
509    // The total number of SELL trades seen in this time period. If there were no trades in the time period, 0 will be returned.
510    pub total_trades_sell: i64,
511    #[serde(rename = "TOTAL_TRADES_UNKNOWN")]
512    /// The total number of UNKNOWN trades seen in this time period. If there were no trades in the time period, 0 will be returned.
513    pub total_trades_unknown: i64,
514    #[serde(rename = "VOLUME")]
515    /// The sum of all the trade volumes in the from asset (base symbol / coin) for the time period. If there were no trades in the time period,
516    /// 0 will be returned.
517    pub volume: f64,
518    #[serde(rename = "QUOTE_VOLUME")]
519    /// The sum of all the trade volumes in the To asset (quote/counter symbol/coin) for the time period. If there were no trades in the time period,
520    /// 0 will be returned.
521    pub quote_volume: f64,
522    #[serde(rename = "VOLUME_BUY")]
523    /// The sum of all the BUY trade volumes in the from asset (base symbol / coin) for the time period.
524    pub volume_buy: f64,
525    #[serde(rename = "QUOTE_VOLUME_BUY")]
526    /// The sum of all the BUY trade volumes in the to asset (quote/counter symbol/coin) for the time period.
527    pub quote_volume_buy: f64,
528    #[serde(rename = "VOLUME_SELL")]
529    /// The sum of all the SELL trade volumes in the from asset (base symbol / coin) for the time period.
530    pub volume_sell: f64,
531    #[serde(rename = "QUOTE_VOLUME_SELL")]
532    /// The sum of all the SELL trade volumes in the To asset (quote/counter symbol/coin) for the time period.
533    pub quote_volume_sell: f64,
534    #[serde(rename = "VOLUME_UNKNOWN")]
535    /// The sum of all the UNKNOWN trade volumes in the from asset (base symbol / coin) for the time period.
536    pub volume_unknown: f64,
537    #[serde(rename = "QUOTE_VOLUME_UNKNOWN")]
538    /// The sum of all the UNKNOWN trade volumes in the To asset (quote/counter symbol/coin) for the time period.
539    pub quote_volume_unknown: f64,
540}
541
542
543// Spot: Instrument Metadata
544
545
546/// Spot: Instrument Metadata
547#[derive(Deserialize, Debug)]
548pub struct CCSpotInstrumentMetdata {
549    #[serde(rename = "METADATA_VERSION")]
550    /// The version of metadata, used for version conversions/migrates.
551    pub metadata_version: usize,
552    #[serde(rename = "INSTRUMENT_STATUS")]
553    /// The status of the instrument, we only poll / stream / connect to the ACTIVE ones, for the RETIRED / IGNORED / EXPIRED /
554    /// READY_FOR_DECOMMISSIONING means we no longer query/stream data.
555    pub instrument_status: String,
556    #[serde(rename = "FIRST_SEEN_ON_POLLING_TS")]
557    /// This is the first time instrument was seen on instrumentListSourceType POLLING.
558    pub first_seen_on_pollings_ts: i64,
559    #[serde(rename = "LAST_SEEN_ON_POLLING_TS")]
560    /// This is the last time instrument was seen on instrumentListSourceType POLLING.
561    pub last_seen_pollings_ts: i64,
562    #[serde(rename = "INSTRUMENT")]
563    /// The instrument ID as it is on the exchange with small modifications - we do not allow the following characters inside isntrument ids: ,/&?
564    pub instrument: String,
565    #[serde(rename = "INSTRUMENT_MAPPING")]
566    /// The current mapping information for this instrument.
567    pub instrument_mapping: CCInstrumentMapping,
568    #[serde(rename = "INSTRUMENT_EXTERNAL_DATA")]
569    /// The full data we get from the polling endpoint for this specific instrument. This is a JSON stringified object with different properties per exchange.
570    pub instrument_external_data: String,
571    #[serde(rename = "FIRST_OB_L2_MINUTE_SNAPSHOT_TS")]
572    /// Timestamp of the initial Level 2 minute snapshot.
573    pub first_ob_l2_minute_snapshot_ts: Option<i64>,
574}
575
576
577// Spot: Markets
578
579
580/// Spot: Markets
581#[derive(Deserialize, Debug)]
582pub struct CCSpotMarkets {
583    #[serde(rename = "TYPE")]
584    /// Type of the message.
585    pub type_: String,
586    #[serde(rename = "EXCHANGE_STATUS")]
587    /// The status of the echange. We only poll / stream / connect to the ACTIVE ones, for the RETIRED ones we no longer query for data".
588    pub exchange_status: String,
589    #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
590    /// The total number of instruments that have been verified by our mapping team and have been properly assigned with a base, quote,
591    /// mapping function, and other necessary fields. This is done to ensure that pairs like XXBTZUSD are accurately mapped to BTC-USD and that
592    /// the pair refers to the correct assets rather than using the same asset id to represent different assets.
593    pub mapped_instrument_total: i64,
594    #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
595    /// The number of instruments that have not yet been verified by our mapping team.
596    pub unmapped_instruments_total: i64,
597    #[serde(rename = "INSTRUMENT_STATUS")]
598    /// An object with the total number of instrument for each of the available instrument statuses.
599    pub instrument_status: CCInstrumentStatus,
600    #[serde(rename = "TOTAL_TRADES_SPOT")]
601    /// The total number of spot trades that this exchange has processed.
602    pub total_trades_spot: i64,
603    #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
604    /// Boolean field denoting if we have historical minute orderbook snapshots endabled for this exchange.
605    pub has_orderbook_l2_minute_snapshots_enabled: bool,
606}
607
608
609// Spot: Markets + Instruments
610
611
612#[derive(Deserialize, Debug)]
613pub struct CCInstrument {
614    #[serde(rename = "TYPE")]
615    /// Type of the message.
616    pub type_: String,
617    #[serde(rename = "INSTRUMENT_STATUS")]
618    /// Status of the current instrument.
619    pub instrument_status: String,
620    #[serde(rename = "INSTRUMENT")]
621    /// The internal exchange defined instrument id.
622    pub instrument: String,
623    #[serde(rename = "HISTO_SHARD")]
624    /// Our internal shard for historical OHLCV+ (minute/hour/day) market data. Minute data is only held in the historical database for
625    /// up to 3 weeks and we ship it to blob storage afterwards. The API utilizes multiple replicas of a single shard in a round-robin manner.
626    pub histo_shard: String,
627    #[serde(rename = "MAPPED_INSTRUMENT")]
628    /// The ccdata mapped instrument ID.
629    pub mapped_instrument: String,
630    #[serde(rename = "INSTRUMENT_MAPPING")]
631    /// The current mapping information for this instrument.
632    pub instrument_mapping: CCInstrumentMapping,
633    #[serde(rename = "HAS_TRADES_SPOT")]
634    /// A boolean field indicating whether the instrument has spot trades or not.
635    pub has_trades_spot: bool,
636    #[serde(rename = "FIRST_TRADE_SPOT_TIMESTAMP")]
637    /// The first spot defi trade timestamp.
638    pub first_trade_spot_timestamp: i64,
639    #[serde(rename = "LAST_TRADE_SPOT_TIMESTAMP")]
640    /// The last spot defi trade timestamp.
641    pub last_trade_spot_timestamp: i64,
642    #[serde(rename = "TOTAL_TRADES_SPOT")]
643    /// The total number of spot trades that this exchange has processed.
644    pub total_trades_spot: i64,
645}
646
647
648/// Spot: Markets + Instruments
649#[derive(Deserialize, Debug)]
650pub struct CCSpotMarketsInstruments {
651    #[serde(rename = "TYPE")]
652    /// Type of the message.
653    pub type_: String,
654    #[serde(rename = "EXCHANGE_STATUS")]
655    /// The status of the echange. We only poll / stream / connect to the ACTIVE ones, for the RETIRED ones we no longer query for data".
656    pub exchange_status: String,
657    #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
658    /// The total number of instruments that have been verified by our mapping team and have been properly assigned with a base, quote,
659    /// mapping function, and other necessary fields. This is done to ensure that pairs like XXBTZUSD are accurately mapped to BTC-USD and that
660    /// the pair refers to the correct assets rather than using the same asset id to represent different assets.
661    pub mapped_instrument_total: i64,
662    #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
663    /// The number of instruments that have not yet been verified by our mapping team.
664    pub unmapped_instruments_total: i64,
665    #[serde(rename = "INSTRUMENT_STATUS")]
666    /// An object with the total number of instrument for each of the available instrument statuses.
667    pub instrument_status: CCInstrumentStatus,
668    #[serde(rename = "TOTAL_TRADES_SPOT")]
669    /// The total number of spot trades that this exchange has processed.
670    pub total_trades_spot: i64,
671    #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
672    /// Boolean field denoting if we have historical minute orderbook snapshots endabled for this exchange.
673    pub has_orderbook_l2_minute_snapshots_enabled: bool,
674    #[serde(rename = "instruments")]
675    /// The list of instruments requested. It could be a selected few or all for each market.
676    pub instruments: HashMap<String, CCInstrument>,
677}