Skip to main content

fmp_rust_sdk/models/
quotes.rs

1//! Current and aftermarket market quotes.
2
3use serde::{Deserialize, Serialize};
4
5/// A full quote from `quote` or `batch-quote`, including supported non-stock symbols.
6#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct Quote {
9    #[serde(deserialize_with = "super::non_empty_string")]
10    pub symbol: String,
11    pub price: f64,
12    pub name: Option<String>,
13    pub change_percentage: Option<f64>,
14    pub change: Option<f64>,
15    pub volume: Option<f64>,
16    pub day_low: Option<f64>,
17    pub day_high: Option<f64>,
18    pub year_high: Option<f64>,
19    pub year_low: Option<f64>,
20    pub market_cap: Option<f64>,
21    #[serde(rename = "priceAvg50")]
22    pub price_avg_50: Option<f64>,
23    #[serde(rename = "priceAvg200")]
24    pub price_avg_200: Option<f64>,
25    pub exchange: Option<String>,
26    pub open: Option<f64>,
27    pub previous_close: Option<f64>,
28    /// Unix seconds, unlike aftermarket timestamps which are milliseconds.
29    pub timestamp: Option<u64>,
30}
31
32/// A compact quote from `quote-short` or `batch-quote-short`.
33#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
34pub struct ShortQuote {
35    #[serde(deserialize_with = "super::non_empty_string")]
36    pub symbol: String,
37    pub price: f64,
38    pub change: Option<f64>,
39    pub volume: Option<f64>,
40}
41
42/// An after-hours trade from `aftermarket-trade`.
43#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
44#[serde(rename_all = "camelCase")]
45pub struct AftermarketTrade {
46    #[serde(deserialize_with = "super::non_empty_string")]
47    pub symbol: String,
48    pub price: f64,
49    pub trade_size: Option<f64>,
50    /// Unix milliseconds.
51    pub timestamp: u64,
52}
53
54/// An after-hours bid/ask snapshot from `aftermarket-quote`.
55#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct AftermarketQuote {
58    #[serde(deserialize_with = "super::non_empty_string")]
59    pub symbol: String,
60    pub bid_size: Option<f64>,
61    pub bid_price: Option<f64>,
62    pub ask_size: Option<f64>,
63    pub ask_price: Option<f64>,
64    pub volume: Option<f64>,
65    /// Unix milliseconds.
66    pub timestamp: u64,
67}
68
69/// Price changes for the horizons returned by `stock-price-change`.
70#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
71pub struct PriceChange {
72    #[serde(deserialize_with = "super::non_empty_string")]
73    pub symbol: String,
74    #[serde(rename = "1D")]
75    pub one_day: Option<f64>,
76    #[serde(rename = "5D")]
77    pub five_days: Option<f64>,
78    #[serde(rename = "1M")]
79    pub one_month: Option<f64>,
80    #[serde(rename = "3M")]
81    pub three_months: Option<f64>,
82    #[serde(rename = "6M")]
83    pub six_months: Option<f64>,
84    #[serde(rename = "ytd")]
85    pub year_to_date: Option<f64>,
86    #[serde(rename = "1Y")]
87    pub one_year: Option<f64>,
88    #[serde(rename = "3Y")]
89    pub three_years: Option<f64>,
90    #[serde(rename = "5Y")]
91    pub five_years: Option<f64>,
92    #[serde(rename = "10Y")]
93    pub ten_years: Option<f64>,
94    #[serde(rename = "max")]
95    pub all_time: Option<f64>,
96}