1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
11#[non_exhaustive]
12pub struct PaginatedResponse<T> {
13 pub results: Option<Vec<T>>,
15 pub status: Option<String>,
17 pub request_id: Option<String>,
19 #[serde(rename = "resultsCount")]
21 pub results_count: Option<usize>,
22 pub count: Option<usize>,
24 pub next_url: Option<String>,
26 pub ticker: Option<String>,
28 pub adjusted: Option<bool>,
30 #[serde(rename = "queryCount")]
32 pub query_count: Option<usize>,
33}
34
35#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum Timespan {
42 Second,
44 Minute,
46 Hour,
48 Day,
50 Week,
52 Month,
54 Quarter,
56 Year,
58}
59
60impl Timespan {
61 pub fn as_str(&self) -> &'static str {
63 match self {
64 Self::Second => "second",
65 Self::Minute => "minute",
66 Self::Hour => "hour",
67 Self::Day => "day",
68 Self::Week => "week",
69 Self::Month => "month",
70 Self::Quarter => "quarter",
71 Self::Year => "year",
72 }
73 }
74}
75
76#[derive(Debug, Clone, Copy, PartialEq, Eq)]
78pub enum Sort {
79 Asc,
81 Desc,
83}
84
85impl Sort {
86 pub fn as_str(&self) -> &'static str {
88 match self {
89 Self::Asc => "asc",
90 Self::Desc => "desc",
91 }
92 }
93}
94
95#[derive(Debug, Clone, Copy, PartialEq, Eq)]
97pub enum Order {
98 Asc,
100 Desc,
102}
103
104impl Order {
105 pub fn as_str(&self) -> &'static str {
107 match self {
108 Self::Asc => "asc",
109 Self::Desc => "desc",
110 }
111 }
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
120#[non_exhaustive]
121pub struct AggBar {
122 #[serde(rename = "o")]
124 pub open: f64,
125 #[serde(rename = "h")]
127 pub high: f64,
128 #[serde(rename = "l")]
130 pub low: f64,
131 #[serde(rename = "c")]
133 pub close: f64,
134 #[serde(rename = "v")]
136 pub volume: f64,
137 #[serde(rename = "vw")]
139 pub vwap: Option<f64>,
140 #[serde(rename = "t")]
142 pub timestamp: i64,
143 #[serde(rename = "n")]
145 pub transactions: Option<u64>,
146 #[serde(rename = "otc")]
148 pub otc: Option<bool>,
149}
150
151#[derive(Debug, Clone, Serialize, Deserialize)]
153#[non_exhaustive]
154pub struct AggregateResponse {
155 pub ticker: Option<String>,
157 pub status: Option<String>,
159 pub adjusted: Option<bool>,
161 #[serde(rename = "resultsCount")]
163 pub results_count: Option<usize>,
164 #[serde(rename = "queryCount")]
166 pub query_count: Option<usize>,
167 pub request_id: Option<String>,
169 pub results: Option<Vec<AggBar>>,
171 pub next_url: Option<String>,
173}
174
175#[derive(Debug, Clone, Serialize, Deserialize)]
177#[non_exhaustive]
178pub struct DailyOpenClose {
179 pub symbol: Option<String>,
181 pub from: Option<String>,
183 pub open: Option<f64>,
185 pub high: Option<f64>,
187 pub low: Option<f64>,
189 pub close: Option<f64>,
191 pub volume: Option<f64>,
193 #[serde(rename = "afterHours")]
195 pub after_hours: Option<f64>,
196 #[serde(rename = "preMarket")]
198 pub pre_market: Option<f64>,
199}
200
201#[derive(Debug, Clone, Serialize, Deserialize)]
207#[non_exhaustive]
208pub struct Trade {
209 pub conditions: Option<Vec<i32>>,
211 pub correction: Option<i32>,
213 pub exchange: Option<i32>,
215 pub id: Option<String>,
217 pub participant_timestamp: Option<i64>,
219 pub price: Option<f64>,
221 pub sequence_number: Option<i64>,
223 pub sip_timestamp: Option<i64>,
225 pub size: Option<f64>,
227 pub tape: Option<i32>,
229 pub trf_id: Option<i32>,
231 pub trf_timestamp: Option<i64>,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
237#[non_exhaustive]
238pub struct LastTrade {
239 #[serde(rename = "T")]
241 pub ticker: Option<String>,
242 pub conditions: Option<Vec<i32>>,
244 pub correction: Option<i32>,
246 pub exchange: Option<i32>,
248 pub id: Option<String>,
250 pub participant_timestamp: Option<i64>,
252 pub price: Option<f64>,
254 pub sequence_number: Option<i64>,
256 pub sip_timestamp: Option<i64>,
258 pub size: Option<f64>,
260 pub tape: Option<i32>,
262 pub trf_id: Option<i32>,
264 pub trf_timestamp: Option<i64>,
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize)]
270#[non_exhaustive]
271pub struct Quote {
272 pub ask_exchange: Option<i32>,
274 pub ask_price: Option<f64>,
276 pub ask_size: Option<f64>,
278 pub bid_exchange: Option<i32>,
280 pub bid_price: Option<f64>,
282 pub bid_size: Option<f64>,
284 pub conditions: Option<Vec<i32>>,
286 pub indicators: Option<Vec<i32>>,
288 pub participant_timestamp: Option<i64>,
290 pub sequence_number: Option<i64>,
292 pub sip_timestamp: Option<i64>,
294 pub tape: Option<i32>,
296 pub trf_timestamp: Option<i64>,
298}
299
300#[derive(Debug, Clone, Serialize, Deserialize)]
302#[non_exhaustive]
303pub struct LastQuoteResponse {
304 pub request_id: Option<String>,
306 pub status: Option<String>,
308 pub results: Option<Quote>,
310}
311
312#[derive(Debug, Clone, Serialize, Deserialize)]
314#[non_exhaustive]
315pub struct LastTradeResponse {
316 pub request_id: Option<String>,
318 pub status: Option<String>,
320 pub results: Option<LastTrade>,
322}
323
324#[derive(Debug, Clone, Serialize, Deserialize)]
330#[non_exhaustive]
331pub struct SnapshotAgg {
332 #[serde(rename = "o")]
334 pub open: Option<f64>,
335 #[serde(rename = "h")]
337 pub high: Option<f64>,
338 #[serde(rename = "l")]
340 pub low: Option<f64>,
341 #[serde(rename = "c")]
343 pub close: Option<f64>,
344 #[serde(rename = "v")]
346 pub volume: Option<f64>,
347 #[serde(rename = "vw")]
349 pub vwap: Option<f64>,
350 #[serde(rename = "t")]
352 pub timestamp: Option<i64>,
353 #[serde(rename = "n")]
355 pub transactions: Option<u64>,
356}
357
358#[derive(Debug, Clone, Serialize, Deserialize)]
360#[non_exhaustive]
361pub struct TickerSnapshot {
362 pub ticker: Option<String>,
364 #[serde(rename = "todaysChange")]
366 pub todays_change: Option<f64>,
367 #[serde(rename = "todaysChangePerc")]
369 pub todays_change_perc: Option<f64>,
370 pub updated: Option<i64>,
372 pub day: Option<SnapshotAgg>,
374 #[serde(rename = "prevDay")]
376 pub prev_day: Option<SnapshotAgg>,
377 #[serde(rename = "lastTrade")]
379 pub last_trade: Option<LastTrade>,
380 #[serde(rename = "lastQuote")]
382 pub last_quote: Option<Quote>,
383 pub min: Option<SnapshotAgg>,
385}
386
387#[derive(Debug, Clone, Serialize, Deserialize)]
389#[non_exhaustive]
390pub struct SingleSnapshotResponse {
391 pub request_id: Option<String>,
393 pub status: Option<String>,
395 pub ticker: Option<TickerSnapshot>,
397}
398
399#[derive(Debug, Clone, Serialize, Deserialize)]
401#[non_exhaustive]
402pub struct SnapshotsResponse {
403 pub status: Option<String>,
405 pub request_id: Option<String>,
407 pub count: Option<usize>,
409 pub tickers: Option<Vec<TickerSnapshot>>,
411}
412
413#[derive(Debug, Clone, Serialize, Deserialize)]
419#[non_exhaustive]
420pub struct IndicatorValue {
421 pub timestamp: Option<i64>,
423 pub value: Option<f64>,
425 pub signal: Option<f64>,
427 pub histogram: Option<f64>,
429}
430
431#[derive(Debug, Clone, Serialize, Deserialize)]
433#[non_exhaustive]
434pub struct IndicatorResponse {
435 pub status: Option<String>,
437 pub request_id: Option<String>,
439 pub results: Option<IndicatorResults>,
441 pub next_url: Option<String>,
443}
444
445#[derive(Debug, Clone, Serialize, Deserialize)]
447#[non_exhaustive]
448pub struct IndicatorResults {
449 pub underlying: Option<IndicatorUnderlying>,
451 pub values: Option<Vec<IndicatorValue>>,
453}
454
455#[derive(Debug, Clone, Serialize, Deserialize)]
457#[non_exhaustive]
458pub struct IndicatorUnderlying {
459 pub url: Option<String>,
461 pub aggregates: Option<Vec<AggBar>>,
463}
464
465#[derive(Debug, Clone, Default)]
471pub struct AggregateParams {
472 pub adjusted: Option<bool>,
474 pub sort: Option<Sort>,
476 pub limit: Option<u32>,
478}