ccdata_api/schemas/data_api/
futures.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 CCFuturesMarket {
8    BINANCE,
9    BITFINEX,
10    BITGET,
11    BITMEX,
12    BTCEX,
13    BYBIT,
14    COINBASE,
15    COINBASEINTERNATIONAL,
16    CROSSTOWER,
17    CRYPTODOTCOM,
18    DERIBIT,
19    DYDXV4,
20    FTX,
21    KRAKEN,
22    MOCK,
23    OKEX,
24}
25
26impl Market for CCFuturesMarket {
27    /// Converts enum value to `String`.
28    fn to_string(&self) -> String {
29        match self {
30            CCFuturesMarket::BINANCE => String::from("binance"),
31            CCFuturesMarket::BITFINEX => String::from("bitfinex"),
32            CCFuturesMarket::BITGET => String::from("bitget"),
33            CCFuturesMarket::BITMEX => String::from("bitmex"),
34            CCFuturesMarket::BTCEX => String::from("btcex"),
35            CCFuturesMarket::BYBIT => String::from("bybit"),
36            CCFuturesMarket::COINBASE => String::from("coinbase"),
37            CCFuturesMarket::COINBASEINTERNATIONAL => String::from("coinbaseinternational"),
38            CCFuturesMarket::CROSSTOWER => String::from("crosstower"),
39            CCFuturesMarket::CRYPTODOTCOM => String::from("cryptodotcom"),
40            CCFuturesMarket::DERIBIT => String::from("deribit"),
41            CCFuturesMarket::DYDXV4 => String::from("dydxv4"),
42            CCFuturesMarket::FTX => String::from("ftx"),
43            CCFuturesMarket::KRAKEN => String::from("kraken"),
44            CCFuturesMarket::MOCK => String::from("mock"),
45            CCFuturesMarket::OKEX => String::from("okex"),
46
47        }
48    }
49}
50
51
52// Futures: Historical OHLCV+
53
54
55/// Futures: Historical OHLCV+
56#[derive(Deserialize, Debug)]
57pub struct CCFuturesOHLCV {
58    #[serde(rename = "UNIT")]
59    /// The level of granularity (e.g. MINUTE / HOUR / DAY).
60    pub unit: String,
61    #[serde(rename = "TIMESTAMP")]
62    /// The timestamp, in seconds, of the histo period. This refers to the first timestamp of the unit under consideration,
63    /// not the last (e.g. for daily data the timestamp will refer to 00:00 GMT/UTC).
64    pub timestamp: i64,
65    #[serde(rename = "TYPE")]
66    /// Type of the message.
67    pub type_: String,
68    #[serde(rename = "MARKET")]
69    /// The market / exchange under consideration (e.g. bitmex, deribit, ftx, etc).
70    pub market: String,
71    #[serde(rename = "INSTRUMENT")]
72    /// The unmapped instrument ID.
73    pub instrument: String,
74    #[serde(rename = "MAPPED_INSTRUMENT")]
75    /// The mapped instrument ID, derived from our mapping rules.
76    pub mapped_instrument: String,
77    #[serde(rename = "INDEX_UNDERLYING")]
78    /// The mapped index underlying asset.
79    pub index_underlying: String,
80    #[serde(rename = "QUOTE_CURRENCY")]
81    /// The mapped to asset quote / counter symbol / coin (e.g. USD). Only available on instruments that have mapping.
82    pub quote_currency: String,
83    #[serde(rename = "SETTLEMENT_CURRENCY")]
84    /// The currency that the contract is settled in (e.g. USD). Only available on instruments that have mapping.
85    pub settlement_currency: String,
86    #[serde(rename = "CONTRACT_CURRENCY")]
87    /// The currency that the contract size is denominated in (e.g. USD). Only available on instruments that have mapping.
88    pub contract_currency: String,
89    #[serde(rename = "DENOMINATION_TYPE")]
90    /// VANILLA = (SETTLEMENT_CURRENCY = QUOTE_CURRENCY), INVERSE = (SETTLEMENT_CURRENCY = INDEX_UNDERLYING),
91    /// QUANTO (SETTLEMENT_CURRENCY != INDEX_UNDERLYING or QUOTE_CURRENCY).
92    pub denomination_type: String,
93    #[serde(rename = "INDEX_UNDERLYING_ID")]
94    /// Represents the internal CCData ID for the index underlying asset (e.g., 1). This ID is unique and immutable,
95    /// ensuring consistent identification. Applicable only to instruments with a mapping.
96    pub index_underlying_id: i32,
97    #[serde(rename = "QUOTE_CURRENCY_ID")]
98    /// Represents the internal CCData ID for the asset quote / counter symbol / coin (e.g. 5). This ID is unique and immutable,
99    /// ensuring consistent identification. Applicable only to instruments with a mapping.
100    pub quote_currency_id: i32,
101    #[serde(rename = "SETTLEMENT_CURRENCY_ID")]
102    /// Represents the internal CCData ID for the currency that the contract is settled in (e.g. 5). This ID is unique and immutable,
103    /// ensuring consistent identification. Applicable only to instruments with a mapping.
104    pub settlement_currency_id: i32,
105    #[serde(rename = "CONTRACT_CURRENCY_ID")]
106    /// Represents the internal CCData ID for the currency that the contract size is denominated in (e.g. 5). This ID is unique and immutable,
107    /// ensuring consistent identification. Applicable only to instruments with a mapping.
108    pub contract_currency_id: i32,
109    #[serde(rename = "TRANSFORM_FUNCTION")]
110    /// The transform function. This is the function we apply when we do mapping to change values into easier human readable ones
111    /// and to make sure the mapped direction BASE - QUOTE is constant accross all instruments.
112    pub transform_function: String,
113    #[serde(rename = "OPEN")]
114    /// The open price for the historical period, based on the closest trade before the period start.
115    pub open: f64,
116    #[serde(rename = "HIGH")]
117    /// The highest trade price of the historical period. If there were no trades in the period, the open price will be taken as the highest.
118    pub high: f64,
119    #[serde(rename = "LOW")]
120    /// The lowest trade price of the historical period. If there were no trades in the period, the open price will be taken as the lowest.
121    pub low: f64,
122    #[serde(rename = "CLOSE")]
123    /// The price of the last trade of the historical period. If there were no trades in the period, the open price will be taken as the close.
124    pub close: f64,
125    #[serde(rename = "FIRST_TRADE_TIMESTAMP")]
126    /// The timestamp, in seconds, of the first trade of the time period. Only available when there is at least one trade in the time period.
127    pub first_trade_timestamp: i64,
128    #[serde(rename = "LAST_TRADE_TIMESTAMP")]
129    /// The timestamp, in seconds, of the last trade of the time period. Only available when there is at least one trade in the time period).
130    pub last_trade_timestamp: i64,
131    #[serde(rename = "FIRST_TRADE_PRICE")]
132    /// The price of the first trade of the time period. Only available when there is at least one trade in the time period.
133    pub first_trade_price: f64,
134    #[serde(rename = "HIGH_TRADE_PRICE")]
135    /// The highest trade price of the time period. Only available when there is at least one trade in the time period.
136    pub high_trade_price: f64,
137    #[serde(rename = "HIGH_TRADE_TIMESTAMP")]
138    /// The timestamp, in seconds, of the highest trade in this time period. Only available when there is at least one trade in the time period.
139    pub high_trade_timestamp: i64,
140    #[serde(rename = "LOW_TRADE_PRICE")]
141    /// The lowest trade price of the time period. Only available when there is at least one trade in the time period.
142    pub low_trade_price: f64,
143    #[serde(rename = "LOW_TRADE_TIMESTAMP")]
144    /// The timestamp, in seconds, of the lowest trade of the time period. Only available when there is at least one trade in the time period.
145    pub low_trade_timestamp: i64,
146    #[serde(rename = "LAST_TRADE_PRICE")]
147    /// The price of the last trade of the period. Only available when there is at least one trade in the time period.
148    pub last_trade_price: f64,
149    #[serde(rename = "TOTAL_TRADES")]
150    /// The total number of trades that occurred in the time period. If there were no trades in the time period, 0 will be given.
151    pub total_trades: i64,
152    #[serde(rename = "TOTAL_TRADES_BUY")]
153    /// The total number of BUY trades that occurred in the in time period.
154    pub total_trades_buy: i64,
155    #[serde(rename = "TOTAL_TRADES_SELL")]
156    /// The total number of SELL trades that occurred in the time period.
157    pub total_trades_sell: i64,
158    #[serde(rename = "TOTAL_TRADES_UNKNOWN")]
159    /// The total number of UNKNOWN trades that occurred in the time period.
160    pub total_trades_unknown: i64,
161    #[serde(rename = "NUMBER_OF_CONTRACTS")]
162    /// The sum of all the trade number of contracts for the time period. If there were no trades in the time period, 0 will be given.
163    pub number_of_contracts: i64,
164    #[serde(rename = "VOLUME")]
165    /// 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, 0 will be given.
166    pub volume: f64,
167    #[serde(rename = "QUOTE_VOLUME")]
168    /// 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, 0 will be given.
169    pub quote_volume: f64,
170    #[serde(rename = "VOLUME_BUY")]
171    /// The sum of all the BUY trade volumes in the from asset (base symbol / coin) for the time period.
172    pub volume_buy: f64,
173    #[serde(rename = "QUOTE_VOLUME_BUY")]
174    /// The sum of all the BUY trade volumes in the To asset (quote/counter symbol/coin) for the time period.
175    pub quote_volume_buy: f64,
176    #[serde(rename = "VOLUME_SELL")]
177    /// The sum of all the SELL trade volumes in the from asset (base symbol / coin) for the time period.
178    pub volume_sell: f64,
179    #[serde(rename = "QUOTE_VOLUME_SELL")]
180    /// The sum of all the SELL trade volumes in the To asset (quote/counter symbol/coin) for the time period.
181    pub quote_volume_sell: f64,
182    #[serde(rename = "VOLUME_UNKNOWN")]
183    /// The sum of all the UNKNOWN trade volumes in the from asset (base symbol / coin) for the time period.
184    pub volume_unknown: f64,
185    #[serde(rename = "QUOTE_VOLUME_UNKNOWN")]
186    /// The sum of all the UNKNOWN trade volumes in the To asset (quote/counter symbol/coin) for the time period.
187    pub quote_volume_unknown: f64,
188}
189
190
191// Futures: Markets
192
193
194/// Futures: Markets
195#[derive(Deserialize, Debug)]
196pub struct CCFuturesMarkets {
197    #[serde(rename = "TYPE")]
198    /// Type of the message.
199    pub type_: String,
200    #[serde(rename = "EXCHANGE_STATUS")]
201    /// The status of the echange. We only poll / stream / connect to the ACTIVE ones, for the RETIRED ones we no longer query for data.
202    pub exchange_status: String,
203    #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
204    /// The total number of instruments that have been verified by our mapping team and have been properly assigned with a base, quote, mapping function,
205    /// and other necessary fields. This is done to ensure that pairs like XXBTZUSD are accurately mapped to BTC-USD and that the pair refers
206    // to the correct assets rather than using the same asset id to represent different assets.
207    pub mapped_instrument_total: i64,
208    #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
209    /// The number of instruments that have not yet been verified by our mapping team.
210    pub unmapped_instruments_total: i64,
211    #[serde(rename = "INSTRUMENT_STATUS")]
212    /// An object with the total number of instrument for each of the available instrument statuses.
213    pub instrument_status: CCInstrumentStatus,
214    #[serde(rename = "TOTAL_TRADES_FUTURES")]
215    /// The total number of futures trades that this exchange has processed.
216    pub total_trades_futures: i64,
217    #[serde(rename = "TOTAL_FUNDING_RATE_UPDATES")]
218    /// The total number of futures funding rate updates that this exchange has processed.
219    pub total_funding_rate_updates: i64,
220    #[serde(rename = "TOTAL_OPEN_INTEREST_UPDATES")]
221    /// The total number of futures open interest updates that this exchange has processed.
222    pub total_open_interest_updates: i64,
223    #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
224    /// Boolean field denoting if we have historical minute orderbook snapshots endabled for this exchange.
225    pub has_orderbook_l2_minute_snapshots_enabled: bool,
226}