ccdata_api/schemas/data_api/derivatives_indices.rs
1use serde::Deserialize;
2use crate::utils::Market;
3use crate::schemas::data_api::CCInstrumentStatus;
4
5
6/// The exchange to obtain data from.
7pub enum CCDerIndicesMarket {
8 BINANCE,
9 BITGET,
10 BITMEX,
11 BTCEX,
12 BYBIT,
13 COINBASEINTERNATIONAL,
14 CROSSTOWER,
15 CRYPTODOTCOM,
16 DERIBIT,
17 DYDXV4,
18 FTX,
19 KRAKEN,
20 MOCK,
21 OKEX,
22}
23
24impl Market for CCDerIndicesMarket {
25 /// Converts enum value to `String`.
26 fn to_string(&self) -> String {
27 match self {
28 CCDerIndicesMarket::BINANCE => String::from("binance"),
29 CCDerIndicesMarket::BITGET => String::from("bitget"),
30 CCDerIndicesMarket::BITMEX => String::from("bitmex"),
31 CCDerIndicesMarket::BTCEX => String::from("btcex"),
32 CCDerIndicesMarket::BYBIT => String::from("bybit"),
33 CCDerIndicesMarket::COINBASEINTERNATIONAL => String::from("coinbaseinternational"),
34 CCDerIndicesMarket::CROSSTOWER => String::from("crosstower"),
35 CCDerIndicesMarket::CRYPTODOTCOM => String::from("cryptodotcom"),
36 CCDerIndicesMarket::DERIBIT => String::from("deribit"),
37 CCDerIndicesMarket::DYDXV4 => String::from("dydxv4"),
38 CCDerIndicesMarket::FTX => String::from("ftx"),
39 CCDerIndicesMarket::KRAKEN => String::from("kraken"),
40 CCDerIndicesMarket::MOCK => String::from("mock"),
41 CCDerIndicesMarket::OKEX => String::from("okex"),
42
43 }
44 }
45}
46
47
48// Derivatives Indices: Historical OHLCV+
49
50
51/// Derivatives Indices: Historical OHLCV+
52#[derive(Deserialize, Debug)]
53pub struct CCDerIndicesOHLCV {
54 #[serde(rename = "UNIT")]
55 /// The unit of the historical period update: MINUTE for minute, HOUR for hour and DAY for day.
56 pub unit: String,
57 #[serde(rename = "TIMESTAMP")]
58 /// The timestamp in seconds of the histo period, for minute it would be every minute at the beginning of the minute,
59 /// for hour it would be start of the hour and for daily it is 00:00 GMT/UTC.
60 pub timestamp: i64,
61 #[serde(rename = "TYPE")]
62 /// Type of the message.
63 pub type_: String,
64 #[serde(rename = "MARKET")]
65 /// The market / exchange you have requested (name of the market / exchange e.g. bitmex, deribit, ftx, etc.).
66 pub market: String,
67 #[serde(rename = "INSTRUMENT")]
68 /// The specific financial asset pair that an index is tracking in unmapped format. In most cases this is a combiation of the base and quote assets of the pair.
69 pub instrument: String,
70 #[serde(rename = "OPEN")]
71 /// The unmapped instrument ID.
72 pub open: f64,
73 #[serde(rename = "HIGH")]
74 /// The open value for the historical period, this is based on the closest index update before the period start.
75 pub high: f64,
76 #[serde(rename = "LOW")]
77 /// The max between the open and the highest index update value in this time period (same as open when there no messages in the time period).
78 pub low: f64,
79 #[serde(rename = "CLOSE")]
80 /// The min between the open and the lowest index update value in this time period (same as open when there no messages in the time period).
81 pub close: f64,
82 #[serde(rename = "FIRST_MESSAGE_TIMESTAMP")]
83 /// The timestamp in seconds of the first index update in this time period (only available when we have at least one index update in the time period).
84 pub first_message_timestamp: i64,
85 #[serde(rename = "LAST_MESSAGE_TIMESTAMP")]
86 /// The timestamp in seconds of the last index update in this time period (only available when we have at least one index update in the time period).
87 pub last_message_timestamp: i64,
88 #[serde(rename = "FIRST_MESSAGE_VALUE")]
89 /// The open based on the first index update in the time period (only available when we have at least one index update in the time period).
90 pub first_message_value: f64,
91 #[serde(rename = "HIGH_MESSAGE_VALUE")]
92 /// The highest value of the messages in the time period (only available when we have at least one index update in the time period).
93 pub high_message_value: f64,
94 #[serde(rename = "HIGH_MESSAGE_TIMESTAMP")]
95 /// The timestamp in seconds of the highest index update in this time period (only available when we have at least one index update in the time period).
96 pub high_message_timestamp: i64,
97 #[serde(rename = "LOW_MESSAGE_VALUE")]
98 /// The lowest value of the messages in the time period (only available when we have at least one index update in the time period).
99 pub low_message_value: f64,
100 #[serde(rename = "LOW_MESSAGE_TIMESTAMP")]
101 /// The timestamp in seconds of the lowest index update in this time period (only available when we have at least one index update in the time period).
102 pub low_message_timestamp: i64,
103 #[serde(rename = "LAST_MESSAGE_VALUE")]
104 /// The last index update value in the time period (only available when we have at least one index update in the time period).
105 pub last_message_value: f64,
106 #[serde(rename = "TOTAL_INDEX_UPDATES")]
107 /// The total number of message updates seen in this time period (0 when there no messages in the time period).
108 pub total_index_updates: i32,
109 #[serde(rename = "MAPPED_INSTRUMENT")]
110 /// The instrument ID, as derived from our mapping rules. Only available on instruments that have been mapped.
111 pub mapped_instrument: String,
112 #[serde(rename = "CURRENCY")]
113 /// The mapped index currency. Only available on instruments that have mapping.
114 pub currency: String,
115 #[serde(rename = "CURRENCY_ID")]
116 /// Represents the internal CCData ID for the mapped index currency, e.g. 1. This ID is unique and immutable, ensuring consistent identification.
117 // Applicable only to instruments with a mapping.
118 pub currency_id: i32,
119 #[serde(rename = "TRANSFORM_FUNCTION")]
120 /// The transform function. This is the function we apply when we do mapping to change values into easier human readable ones and to make
121 /// sure the mapped direction BASE - QUOTE is constant accross all instruments.
122 pub transform_function: String,
123}
124
125
126// Derivatives Indices: Markets
127
128
129/// Derivatives Indices: Markets
130#[derive(Deserialize, Debug)]
131pub struct CCDerIndicesMarkets {
132 #[serde(rename = "TYPE")]
133 /// Type of the message.
134 pub type_: String,
135 #[serde(rename = "EXCHANGE_STATUS")]
136 /// The status of the echange. We only poll / stream / connect to the ACTIVE ones, for the RETIRED ones we no longer query for data.
137 pub exchange_status: String,
138 #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
139 /// The total number of instruments that have been verified by our mapping team and have been properly assigned with a base, quote,
140 /// mapping function, and other necessary fields. This is done to ensure that pairs like XXBTZUSD are accurately mapped to BTC-USD and that
141 /// the pair refers to the correct assets rather than using the same asset id to represent different assets.
142 pub mapped_instrument_total: i64,
143 #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
144 /// The number of instruments that have not yet been verified by our mapping team.
145 pub unmapped_instruments_total: i64,
146 #[serde(rename = "INSTRUMENT_STATUS")]
147 /// An object with the total number of instrument for each of the available instrument statuses.
148 pub instrument_status: CCInstrumentStatus,
149}