1use serde::Deserialize;
2use std::collections::HashMap;
3
4pub type QuotesResponse = HashMap<String, Quote>;
6
7#[derive(Debug, Clone, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct Quote {
10 pub asset_type: String,
11 pub asset_main_type: String,
12 pub cusip: Option<String>,
13 pub symbol: String,
14 pub description: String,
15 pub quote: Option<EquityQuote>,
16 pub fundamental: Option<FundamentalData>,
17 pub extended: Option<ExtendedQuote>,
18 pub reference: Option<ReferenceData>,
19 pub regular: Option<RegularMarketData>,
20}
21
22#[derive(Debug, Clone, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub struct EquityQuote {
25 #[serde(rename = "52WeekHigh")]
26 pub fifty_two_week_high: f64,
27 #[serde(rename = "52WeekLow")]
28 pub fifty_two_week_low: f64,
29 pub ask_mic_id: String,
30 pub ask_price: f64,
31 pub ask_size: i64,
32 pub bid_mic_id: String,
33 pub bid_price: f64,
34 pub bid_size: i64,
35 pub close_price: f64,
36 pub high_price: f64,
37 pub last_mic_id: String,
38 pub last_price: f64,
39 pub last_size: i64,
40 pub low_price: f64,
41 pub mark: f64,
42 pub net_change: f64,
43 pub net_percent_change: f64,
44 pub open_price: f64,
45 pub quote_time_in_long: i64,
46 pub security_status: String,
47 pub total_volume: i64,
48 pub trade_time_in_long: i64,
49}
50
51#[derive(Debug, Clone, Deserialize)]
52#[serde(rename_all = "camelCase")]
53pub struct FundamentalData {
54 pub avg10_day_volume: i64,
55 pub avg1_year_volume: i64,
56 pub declaration_date: String,
57 pub div_amount: f64,
58 pub div_ex_date: String,
59 pub div_freq: i32,
60 pub div_pay_date: String,
61 pub div_yield: f64,
62 pub eps: f64,
63 pub exchange: String,
64 pub high52: f64,
65 pub last_earnings_date: String,
66 pub low52: f64,
67 pub market_cap: f64,
68 pub market_cap_float: f64,
69 pub pe_ratio: f64,
70 pub peg_ratio: f64,
71 pub pb_ratio: f64,
72 pub pr_ratio: f64,
73 pub pcf_ratio: f64,
74 pub gross_margin_ttm: f64,
75 pub net_profit_margin_ttm: f64,
76 pub operating_margin_ttm: f64,
77 pub return_on_equity: f64,
78 pub return_on_assets: f64,
79 pub return_on_investment: f64,
80 pub quick_ratio: f64,
81 pub current_ratio: f64,
82 pub interest_coverage: f64,
83 pub total_debt_to_capital: f64,
84 pub lt_debt_to_equity: f64,
85 pub total_debt_to_equity: f64,
86 pub revenue_per_share_ttm: f64,
87 pub book_value_per_share: f64,
88 pub short_int_to_float: f64,
89 pub short_int_day_to_cover: f64,
90 pub shares_outstanding: i64,
91 pub beta: f64,
92 pub volatility: f64,
93}
94
95#[derive(Debug, Clone, Deserialize)]
96#[serde(rename_all = "camelCase")]
97pub struct ExtendedQuote {
98 }
100
101#[derive(Debug, Clone, Deserialize)]
102#[serde(rename_all = "camelCase")]
103pub struct ReferenceData {
104 }
106
107#[derive(Debug, Clone, Deserialize)]
108#[serde(rename_all = "camelCase")]
109pub struct RegularMarketData {
110 }
112
113pub type ExpirationMap = HashMap<String, HashMap<String, Vec<OptionContract>>>;
115
116#[derive(Debug, Clone, Deserialize, PartialEq)]
117#[serde(rename_all = "UPPERCASE")]
118pub enum PutCall {
119 Put,
120 Call,
121}
122
123#[derive(Debug, Clone, Deserialize)]
124#[serde(rename_all = "camelCase")]
125pub struct ChainsResponse {
126 pub symbol: String,
127 pub status: String,
128 pub underlying: Option<UnderlyingInfo>,
129 pub strategy: String,
130 pub interval: f64,
131 pub is_delayed: bool,
132 pub is_index: bool,
133 pub interest_rate: f64,
134 pub underlying_price: f64,
135 pub volatility: f64,
136 pub days_to_expiration: f64,
137 pub number_of_contracts: i64,
138 #[serde(rename = "callExpDateMap")]
139 pub call_exp_date_map: ExpirationMap,
140 #[serde(rename = "putExpDateMap")]
141 pub put_exp_date_map: ExpirationMap,
142}
143
144#[derive(Debug, Clone, Deserialize)]
145#[serde(rename_all = "camelCase")]
146pub struct UnderlyingInfo {
147 pub symbol: String,
148 pub description: String,
149 pub change: f64,
150 pub percent_change: f64,
151 pub close: f64,
152 pub quote_time: i64,
153 pub trade_time: i64,
154 pub bid: f64,
155 pub ask: f64,
156 pub last: f64,
157 pub mark: f64,
158 pub mark_change: f64,
159 pub mark_percent_change: f64,
160 pub bid_size: i64,
161 pub ask_size: i64,
162 pub high_price: f64,
163 pub low_price: f64,
164 pub open_price: f64,
165 pub total_volume: i64,
166 #[serde(rename = "52WeekHigh")]
167 pub fifty_two_week_high: f64,
168 #[serde(rename = "52WeekLow")]
169 pub fifty_two_week_low: f64,
170 pub delayed: bool,
171}
172
173#[derive(Debug, Clone, Deserialize)]
174#[serde(rename_all = "camelCase")]
175pub struct OptionContract {
176 #[serde(rename = "putCall")]
177 pub put_call: PutCall,
178 pub symbol: String,
179 pub description: String,
180 pub exchange_name: String,
181 pub bid: f64,
182 pub ask: f64,
183 pub last: f64,
184 pub mark: f64,
185 pub bid_size: i64,
186 pub ask_size: i64,
187 pub bid_ask_size: String,
188 pub last_size: i64,
189 pub high_price: f64,
190 pub low_price: f64,
191 pub open_price: f64,
192 pub close_price: f64,
193 pub total_volume: i64,
194 pub trade_date: Option<String>,
195 pub trade_time_in_long: i64,
196 pub quote_time_in_long: i64,
197 pub net_change: f64,
198 pub volatility: f64,
199 pub delta: f64,
200 pub gamma: f64,
201 pub theta: f64,
202 pub vega: f64,
203 pub rho: f64,
204 pub open_interest: i64,
205 pub time_value: f64,
206 pub theoretical_option_value: f64,
207 pub theoretical_volatility: f64,
208 pub strike_price: f64,
209 pub expiration_date: String,
210 pub days_to_expiration: i64,
211 pub expiration_type: String,
212 pub last_trading_day: i64,
213 pub multiplier: f64,
214 pub settlement_type: String,
215 pub deliverable_note: String,
216 pub in_the_money: bool,
217 pub is_penny_pilot: bool,
218}
219
220#[derive(Debug, Clone, Deserialize)]
221#[serde(rename_all = "camelCase")]
222pub struct PriceHistoryResponse {
223 pub candles: Vec<Candle>,
224 pub symbol: String,
225 pub empty: bool,
226}
227
228#[derive(Debug, Clone, Deserialize)]
229#[serde(rename_all = "camelCase")]
230pub struct Candle {
231 pub open: f64,
232 pub high: f64,
233 pub low: f64,
234 pub close: f64,
235 pub volume: i64,
236 pub datetime: i64,
238}
239
240pub type MoversResponse = Vec<Mover>;
242
243#[derive(Debug, Clone, Deserialize)]
244#[serde(rename_all = "camelCase")]
245pub struct Mover {
246 pub change: f64,
247 pub description: String,
248 pub direction: String,
249 pub last: f64,
250 #[serde(rename = "percentChange")]
251 pub percent_change: f64,
252 pub symbol: String,
253 #[serde(rename = "totalVolume")]
254 pub total_volume: i64,
255}
256
257pub type InstrumentsResponse = Vec<Instrument>;
259
260#[derive(Debug, Clone, Deserialize)]
261#[serde(rename_all = "camelCase")]
262pub struct Instrument {
263 pub cusip: String,
264 pub symbol: String,
265 pub description: String,
266 pub exchange: String,
267 pub asset_type: String,
268}
269
270pub type MarketHoursResponse = HashMap<String, MarketHours>;
272
273#[derive(Debug, Clone, Deserialize)]
274#[serde(rename_all = "camelCase")]
275pub struct MarketHours {
276 pub date: String,
277 pub market_type: String,
278 pub exchange: Option<String>,
279 pub category: Option<String>,
280 pub product: String,
281 pub product_name: String,
282 pub is_open: bool,
283 #[serde(rename = "sessionHours")]
284 pub session_hours: Option<HashMap<String, Vec<MarketSession>>>,
285}
286
287#[derive(Debug, Clone, Deserialize)]
288#[serde(rename_all = "camelCase")]
289pub struct MarketSession {
290 pub start: String,
291 pub end: String,
292}
293
294#[derive(Debug, Clone, Deserialize)]
295#[serde(rename_all = "camelCase")]
296pub struct ExpirationChainResponse {
297 pub expiration_list: Vec<ExpirationDate>,
298 pub status: String,
299}
300
301#[derive(Debug, Clone, Deserialize)]
302#[serde(rename_all = "camelCase")]
303pub struct ExpirationDate {
304 pub expiration_date: String,
305 pub days_to_expiration: i32,
306 pub expiration_type: String,
307 pub standard: bool,
308}