ccdata_api/schemas/data_api/
options.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 CCOptionsMarket {
8    DERIBIT,
9    OKEX,
10}
11
12impl Market for CCOptionsMarket {
13    /// Converts enum values to `String`.
14    fn to_string(&self) -> String {
15        match self {
16            CCOptionsMarket::DERIBIT => String::from("deribit"),
17            CCOptionsMarket::OKEX => String::from("okex"),
18        }
19    }
20}
21
22
23// Options: Historical OHLCV+
24
25
26///Options: Historical OHLCV+
27#[derive(Deserialize, Debug)]
28pub struct CCOptionsOHLCV {
29    #[serde(rename = "UNIT")]
30    /// The level of granularity (e.g. MINUTE / HOUR / DAY).
31    pub unit: String,
32    #[serde(rename = "TIMESTAMP")]
33    /// The timestamp, in seconds, of the histo period. This refers to the first timestamp of the unit under consideration,
34    /// not the last (e.g. for daily data the timestamp will refer to 00:00 GMT/UTC).
35    pub timestamp: i64,
36    #[serde(rename = "TYPE")]
37    /// Type of the message.
38    pub type_: String,
39    #[serde(rename = "MARKET")]
40    /// The market / exchange under consideration (e.g. bitmex, deribit, ftx, etc).
41    pub market: String,
42    #[serde(rename = "INSTRUMENT")]
43    /// The unmapped instrument ID.
44    pub instrument: String,
45    #[serde(rename = "MAPPED_INSTRUMENT")]
46    /// The mapped instrument ID, derived from our mapping rules.
47    pub mapped_instrument: String,
48    #[serde(rename = "INDEX_UNDERLYING")]
49    /// The mapped index underlying asset.
50    pub index_underlying: String,
51    #[serde(rename = "QUOTE_CURRENCY")]
52    /// The mapped to asset quote / counter symbol / coin (e.g. USD). Only available on instruments that have mapping.
53    pub quote_currency: String,
54    #[serde(rename = "SETTLEMENT_CURRENCY")]
55    /// The currency that the contract is settled in (e.g. USD). Only available on instruments that have mapping.
56    pub settlement_currency: String,
57    #[serde(rename = "CONTRACT_CURRENCY")]
58    /// The currency that the contract size is denominated in (e.g. USD). Only available on instruments that have mapping.
59    pub contract_currency: String,
60    #[serde(rename = "STRIKE_CURRENCY")]
61    /// The strike currency of the contract underlying index.
62    pub strike_currency: String,
63    #[serde(rename = "INDEX_UNDERLYING_ID")]
64    /// Represents the internal CCData ID for the index underlying asset (e.g., 1). This ID is unique and immutable,
65    /// ensuring consistent identification. Applicable only to instruments with a mapping.
66    pub index_underlying_id: i32,
67    #[serde(rename = "QUOTE_CURRENCY_ID")]
68    /// Represents the internal CCData ID for the asset quote / counter symbol / coin (e.g. 5). This ID is unique and immutable,
69    /// ensuring consistent identification. Applicable only to instruments with a mapping.
70    pub quote_currency_id: i32,
71    #[serde(rename = "SETTLEMENT_CURRENCY_ID")]
72    /// Represents the internal CCData ID for the currency that the contract is settled in (e.g. 5). This ID is unique and immutable,
73    /// ensuring consistent identification. Applicable only to instruments with a mapping.
74    pub settlement_currency_id: i32,
75    #[serde(rename = "CONTRACT_CURRENCY_ID")]
76    /// Represents the internal CCData ID for the currency that the contract size is denominated in (e.g. 5). This ID is unique and immutable,
77    /// ensuring consistent identification. Applicable only to instruments with a mapping.
78    pub contract_currency_id: i32,
79    #[serde(rename = "STRIKE_CURRENCY_ID")]
80    /// Represents the internal CCData ID for the strike currency of the contract underlying index. This ID is unique and immutable,
81    /// ensuring consistent identification. Applicable only to instruments with a mapping.
82    pub strike_currency_id: i32,
83    #[serde(rename = "TRANSFORM_FUNCTION")]
84    /// The transform function. This is the function we apply when we do mapping to change values into easier human readable
85    /// ones and to make sure the mapped direction BASE - QUOTE is constant accross all instruments.
86    pub transform_function: String,
87    #[serde(rename = "OPEN")]
88    /// The open price for the historical period, based on the closest trade before the period start.
89    pub open: f64,
90    #[serde(rename = "HIGH")]
91    /// 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.
92    pub high: f64,
93    #[serde(rename = "LOW")]
94    /// 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.
95    pub low: f64,
96    #[serde(rename = "CLOSE")]
97    /// 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.
98    pub close: f64,
99    #[serde(rename = "NUMBER_OF_CONTRACTS")]
100    /// 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.
101    pub number_of_contracts: i64,
102    #[serde(rename = "TOTAL_TRADES")]
103    /// The total number of trades that occurred in the time period. If there were no trades in the time period, 0 will be given.
104    pub total_trades: i64,
105    #[serde(rename = "TOTAL_TRADES_BUY")]
106    /// The total number of BUY trades that occurred in the in time period.
107    pub total_trades_buy: i64,
108    #[serde(rename = "TOTAL_TRADES_SELL")]
109    /// The total number of SELL trades that occurred in the time period.
110    pub total_trades_sell: i64,
111    #[serde(rename = "TOTAL_TRADES_UNKNOWN")]
112    /// The total number of UNKNOWN trades that occurred in the time period.
113    pub total_trades_unknown: i64,
114    #[serde(rename = "VOLUME")]
115    /// 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.
116    pub volume: f64,
117    #[serde(rename = "QUOTE_VOLUME")]
118    /// 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.
119    pub quote_volume: f64,
120    #[serde(rename = "VOLUME_BUY")]
121    /// The sum of all the BUY trade volumes in the from asset (base symbol / coin) for the time period.
122    pub volume_buy: f64,
123    #[serde(rename = "QUOTE_VOLUME_BUY")]
124    /// The sum of all the BUY trade volumes in the To asset (quote/counter symbol/coin) for the time period.
125    pub quote_volume_buy: f64,
126    #[serde(rename = "VOLUME_SELL")]
127    /// The sum of all the SELL trade volumes in the from asset (base symbol / coin) for the time period.
128    pub volume_sell: f64,
129    #[serde(rename = "QUOTE_VOLUME_SELL")]
130    /// The sum of all the SELL trade volumes in the To asset (quote/counter symbol/coin) for the time period.
131    pub quote_volume_sell: f64,
132    #[serde(rename = "VOLUME_UNKNOWN")]
133    /// The sum of all the UNKNOWN trade volumes in the from asset (base symbol / coin) for the time period.
134    pub volume_unknown: f64,
135    #[serde(rename = "QUOTE_VOLUME_UNKNOWN")]
136    /// The sum of all the UNKNOWN trade volumes in the To asset (quote/counter symbol/coin) for the time period.
137    pub quote_volume_unknown: f64,
138    #[serde(rename = "NOTIONAL_VOLUME")]
139    /// The sum of all the notional trade volumes in the from asset (base symbol / coin) for the time period.
140    /// If there were no trades in the time period, 0 will be given.
141    pub notional_volume: f64,
142    #[serde(rename = "NOTIONAL_QUOTE_VOLUME")]
143    /// The sum of all the notional trade volumes in the To asset (quote/counter symbol/coin) for the time period.
144    /// If there were no trades in the time period, 0 will be given.
145    pub notional_quote_volume: f64,
146    #[serde(rename = "NOTIONAL_VOLUME_BUY")]
147    /// The sum of all the BUY notional trade volumes in the from asset (base symbol / coin) for the time period.
148    pub notional_volume_buy: f64,
149    #[serde(rename = "NOTIONAL_QUOTE_VOLUME_BUY")]
150    /// The sum of all the BUY notional trade volumes in the To asset (quote/counter symbol/coin) for the time period.
151    pub notional_quote_volume_buy: f64,
152    #[serde(rename = "NOTIONAL_VOLUME_SELL")]
153    /// The sum of all the SELL notional trade volumes in the from asset (base symbol / coin) for the time period.
154    pub notional_volume_sell: f64,
155    #[serde(rename = "NOTIONAL_QUOTE_VOLUME_SELL")]
156    /// The sum of all the SELL notional trade volumes in the To asset (quote/counter symbol/coin) for the time period.
157    pub notional_quote_volume_sell: f64,
158    #[serde(rename = "NOTIONAL_VOLUME_UNKNOWN")]
159    /// The sum of all the UNKNOWN notional trade volumes in the from asset (base symbol / coin) for the time period.
160    pub notional_volume_unknown: f64,
161    #[serde(rename = "NOTIONAL_QUOTE_VOLUME_UNKNOWN")]
162    /// The sum of all the UNKNOWN notional trade volumes in the To asset (quote/counter symbol/coin) for the time period.
163    pub notional_quote_volume_unknown: f64,
164}
165
166
167// Options: Markets
168
169
170/// Options: Markets
171#[derive(Deserialize, Debug)]
172pub struct CCOptionsMarkets {
173    #[serde(rename = "TYPE")]
174    /// Type of the message.
175    pub type_: String,
176    #[serde(rename = "EXCHANGE_STATUS")]
177    /// The status of the echange. We only poll / stream / connect to the ACTIVE ones, for the RETIRED ones we no longer query for data.
178    pub exchange_status: String,
179    #[serde(rename = "MAPPED_INSTRUMENTS_TOTAL")]
180    /// The total number of instruments that have been verified by our mapping team and have been properly assigned with a base, quote,
181    /// mapping function, and other necessary fields. This is done to ensure that pairs like XXBTZUSD are accurately mapped to BTC-USD and
182    /// that the pair refers to the correct assets rather than using the same asset id to represent different assets.
183    pub mapped_instrument_total: i64,
184    #[serde(rename = "UNMAPPED_INSTRUMENTS_TOTAL")]
185    /// The number of instruments that have not yet been verified by our mapping team.
186    pub unmapped_instruments_total: i64,
187    #[serde(rename = "INSTRUMENT_STATUS")]
188    /// An object with the total number of instrument for each of the available instrument statuses.
189    pub instrument_status: CCInstrumentStatus,
190    #[serde(rename = "TOTAL_TRADES_OPTIONS")]
191    /// The total number of options trades that this exchange has processed.
192    pub total_trades_options: i64,
193    #[serde(rename = "TOTAL_OPEN_INTEREST_OPTIONS_UPDATES")]
194    /// The total number of options open interest updates that this exchange has processed.
195    pub total_open_interest_updates: i64,
196    #[serde(rename = "HAS_ORDERBOOK_L2_MINUTE_SNAPSHOTS_ENABLED")]
197    pub has_orderbook_l2_minute_snapshots_enabled: Option<bool>,
198}