#![allow(dead_code)]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PaginatedResponseDTO<T> {
pub results: Option<Vec<T>>,
pub status: Option<String>,
pub request_id: Option<String>,
#[serde(rename = "resultsCount")]
pub results_count: Option<usize>,
pub count: Option<usize>,
pub next_url: Option<String>,
pub ticker: Option<String>,
pub adjusted: Option<bool>,
#[serde(rename = "queryCount")]
pub query_count: Option<usize>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Timespan {
Second,
Minute,
Hour,
Day,
Week,
Month,
Quarter,
Year,
}
impl Timespan {
pub fn as_str(&self) -> &'static str {
match self {
Self::Second => "second",
Self::Minute => "minute",
Self::Hour => "hour",
Self::Day => "day",
Self::Week => "week",
Self::Month => "month",
Self::Quarter => "quarter",
Self::Year => "year",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Sort {
Asc,
Desc,
}
impl Sort {
pub fn as_str(&self) -> &'static str {
match self {
Self::Asc => "asc",
Self::Desc => "desc",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Order {
Asc,
Desc,
}
impl Order {
pub fn as_str(&self) -> &'static str {
match self {
Self::Asc => "asc",
Self::Desc => "desc",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AggBarDTO {
#[serde(rename = "o")]
pub open: f64,
#[serde(rename = "h")]
pub high: f64,
#[serde(rename = "l")]
pub low: f64,
#[serde(rename = "c")]
pub close: f64,
#[serde(rename = "v")]
pub volume: f64,
#[serde(rename = "vw")]
pub vwap: Option<f64>,
#[serde(rename = "t")]
pub timestamp: i64,
#[serde(rename = "n")]
pub transactions: Option<u64>,
#[serde(rename = "otc")]
pub otc: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct AggregateResponseDTO {
pub ticker: Option<String>,
pub status: Option<String>,
pub adjusted: Option<bool>,
#[serde(rename = "resultsCount")]
pub results_count: Option<usize>,
#[serde(rename = "queryCount")]
pub query_count: Option<usize>,
pub request_id: Option<String>,
pub results: Option<Vec<AggBarDTO>>,
pub next_url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DailyOpenCloseDTO {
pub symbol: Option<String>,
pub from: Option<String>,
pub open: Option<f64>,
pub high: Option<f64>,
pub low: Option<f64>,
pub close: Option<f64>,
pub volume: Option<f64>,
#[serde(rename = "afterHours")]
pub after_hours: Option<f64>,
#[serde(rename = "preMarket")]
pub pre_market: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TradeDTO {
pub conditions: Option<Vec<i32>>,
pub correction: Option<i32>,
pub exchange: Option<i32>,
pub id: Option<String>,
pub participant_timestamp: Option<i64>,
pub price: Option<f64>,
pub sequence_number: Option<i64>,
pub sip_timestamp: Option<i64>,
pub size: Option<f64>,
pub tape: Option<i32>,
pub trf_id: Option<i32>,
pub trf_timestamp: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LastTradeDTO {
#[serde(rename = "T")]
pub ticker: Option<String>,
pub conditions: Option<Vec<i32>>,
pub correction: Option<i32>,
pub exchange: Option<i32>,
pub id: Option<String>,
pub participant_timestamp: Option<i64>,
pub price: Option<f64>,
pub sequence_number: Option<i64>,
pub sip_timestamp: Option<i64>,
pub size: Option<f64>,
pub tape: Option<i32>,
pub trf_id: Option<i32>,
pub trf_timestamp: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct QuoteDTO {
pub ask_exchange: Option<i32>,
pub ask_price: Option<f64>,
pub ask_size: Option<f64>,
pub bid_exchange: Option<i32>,
pub bid_price: Option<f64>,
pub bid_size: Option<f64>,
pub conditions: Option<Vec<i32>>,
pub indicators: Option<Vec<i32>>,
pub participant_timestamp: Option<i64>,
pub sequence_number: Option<i64>,
pub sip_timestamp: Option<i64>,
pub tape: Option<i32>,
pub trf_timestamp: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LastQuoteResponseDTO {
pub request_id: Option<String>,
pub status: Option<String>,
pub results: Option<QuoteDTO>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct LastTradeResponseDTO {
pub request_id: Option<String>,
pub status: Option<String>,
pub results: Option<LastTradeDTO>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SnapshotAggDTO {
#[serde(rename = "o")]
pub open: Option<f64>,
#[serde(rename = "h")]
pub high: Option<f64>,
#[serde(rename = "l")]
pub low: Option<f64>,
#[serde(rename = "c")]
pub close: Option<f64>,
#[serde(rename = "v")]
pub volume: Option<f64>,
#[serde(rename = "vw")]
pub vwap: Option<f64>,
#[serde(rename = "t")]
pub timestamp: Option<i64>,
#[serde(rename = "n")]
pub transactions: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct TickerSnapshotDTO {
pub ticker: Option<String>,
#[serde(rename = "todaysChange")]
pub todays_change: Option<f64>,
#[serde(rename = "todaysChangePerc")]
pub todays_change_perc: Option<f64>,
pub updated: Option<i64>,
pub day: Option<SnapshotAggDTO>,
#[serde(rename = "prevDay")]
pub prev_day: Option<SnapshotAggDTO>,
#[serde(rename = "lastTrade")]
pub last_trade: Option<LastTradeDTO>,
#[serde(rename = "lastQuote")]
pub last_quote: Option<QuoteDTO>,
pub min: Option<SnapshotAggDTO>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SingleSnapshotResponseDTO {
pub request_id: Option<String>,
pub status: Option<String>,
pub ticker: Option<TickerSnapshotDTO>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct SnapshotsResponseDTO {
pub status: Option<String>,
pub request_id: Option<String>,
pub count: Option<usize>,
pub tickers: Option<Vec<TickerSnapshotDTO>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IndicatorValueDTO {
pub timestamp: Option<i64>,
pub value: Option<f64>,
pub signal: Option<f64>,
pub histogram: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IndicatorResponseDTO {
pub status: Option<String>,
pub request_id: Option<String>,
pub results: Option<IndicatorResultsDTO>,
pub next_url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IndicatorResultsDTO {
pub underlying: Option<IndicatorUnderlyingDTO>,
pub values: Option<Vec<IndicatorValueDTO>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IndicatorUnderlyingDTO {
pub url: Option<String>,
pub aggregates: Option<Vec<AggBarDTO>>,
}
#[derive(Debug, Clone, Default)]
pub struct AggregateParams {
pub adjusted: Option<bool>,
pub sort: Option<Sort>,
pub limit: Option<u32>,
}