Skip to main content

fmp_rust_sdk/models/
market.rs

1//! Analyst estimates, funds, economics, and market performance.
2
3use chrono::{NaiveDate, NaiveDateTime};
4use serde::{Deserialize, Serialize};
5
6/// Analyst projections from `analyst-estimates`.
7#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct AnalystEstimate {
10    #[serde(deserialize_with = "super::non_empty_string")]
11    pub symbol: String,
12    pub date: NaiveDate,
13    pub revenue_low: Option<f64>,
14    pub revenue_high: Option<f64>,
15    pub revenue_avg: Option<f64>,
16    pub ebitda_low: Option<f64>,
17    pub ebitda_high: Option<f64>,
18    pub ebitda_avg: Option<f64>,
19    pub ebit_low: Option<f64>,
20    pub ebit_high: Option<f64>,
21    pub ebit_avg: Option<f64>,
22    pub net_income_low: Option<f64>,
23    pub net_income_high: Option<f64>,
24    pub net_income_avg: Option<f64>,
25    pub sga_expense_low: Option<f64>,
26    pub sga_expense_high: Option<f64>,
27    pub sga_expense_avg: Option<f64>,
28    pub eps_avg: Option<f64>,
29    pub eps_high: Option<f64>,
30    pub eps_low: Option<f64>,
31    pub num_analysts_revenue: Option<u32>,
32    pub num_analysts_eps: Option<u32>,
33}
34
35/// Consensus price targets from `price-target-consensus`.
36#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
37#[serde(rename_all = "camelCase")]
38pub struct PriceTargetConsensus {
39    #[serde(deserialize_with = "super::non_empty_string")]
40    pub symbol: String,
41    pub target_high: Option<f64>,
42    pub target_low: Option<f64>,
43    pub target_consensus: Option<f64>,
44    pub target_median: Option<f64>,
45}
46
47/// Fundamental rating scores from `ratings-snapshot`.
48#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
49#[serde(rename_all = "camelCase")]
50pub struct RatingSnapshot {
51    #[serde(deserialize_with = "super::non_empty_string")]
52    pub symbol: String,
53    pub rating: String,
54    pub overall_score: Option<u8>,
55    pub discounted_cash_flow_score: Option<u8>,
56    pub return_on_equity_score: Option<u8>,
57    pub return_on_assets_score: Option<u8>,
58    pub debt_to_equity_score: Option<u8>,
59    pub price_to_earnings_score: Option<u8>,
60    pub price_to_book_score: Option<u8>,
61}
62
63/// A discounted cash flow valuation from `discounted-cash-flow`.
64#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
65pub struct DiscountedCashFlow {
66    #[serde(deserialize_with = "super::non_empty_string")]
67    pub symbol: String,
68    pub date: NaiveDate,
69    pub dcf: f64,
70    #[serde(rename = "Stock Price")]
71    pub stock_price: Option<f64>,
72}
73
74/// An underlying holding from `etf/holdings`.
75#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
76#[serde(rename_all = "camelCase")]
77pub struct EtfHolding {
78    #[serde(deserialize_with = "super::non_empty_string")]
79    pub symbol: String,
80    /// Underlying symbol; cash and other holdings can lack a ticker.
81    pub asset: String,
82    pub name: String,
83    pub isin: Option<String>,
84    pub security_cusip: Option<String>,
85    pub shares_number: Option<f64>,
86    pub weight_percentage: f64,
87    pub market_value: Option<f64>,
88    #[serde(default, with = "super::optional_timestamp")]
89    pub updated_at: Option<NaiveDateTime>,
90}
91
92/// A daily US Treasury yield observation from `treasury-rates`.
93#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
94pub struct TreasuryRate {
95    pub date: NaiveDate,
96    pub month1: Option<f64>,
97    pub month2: Option<f64>,
98    pub month3: Option<f64>,
99    pub month6: Option<f64>,
100    pub year1: Option<f64>,
101    pub year2: Option<f64>,
102    pub year3: Option<f64>,
103    pub year5: Option<f64>,
104    pub year7: Option<f64>,
105    pub year10: Option<f64>,
106    pub year20: Option<f64>,
107    pub year30: Option<f64>,
108}
109
110/// A value for an indicator requested through `economic-indicators`.
111#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
112pub struct EconomicIndicator {
113    #[serde(deserialize_with = "super::non_empty_string")]
114    pub name: String,
115    pub date: NaiveDate,
116    pub value: f64,
117}
118
119/// A scheduled or released data point from `economic-calendar`.
120#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
121#[serde(rename_all = "camelCase")]
122pub struct EconomicEvent {
123    #[serde(with = "super::timestamp")]
124    pub date: NaiveDateTime,
125    pub country: String,
126    #[serde(deserialize_with = "super::non_empty_string")]
127    pub event: String,
128    pub currency: Option<String>,
129    pub previous: Option<f64>,
130    pub estimate: Option<f64>,
131    pub actual: Option<f64>,
132    pub change: Option<f64>,
133    pub impact: Option<String>,
134    pub change_percentage: Option<f64>,
135    pub unit: Option<String>,
136}
137
138/// Average changes from `sector-performance-snapshot` or `historical-sector-performance`.
139#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
140#[serde(rename_all = "camelCase")]
141pub struct SectorPerformance {
142    pub date: NaiveDate,
143    #[serde(deserialize_with = "super::non_empty_string")]
144    pub sector: String,
145    pub exchange: String,
146    pub average_change: f64,
147}
148
149/// Average changes from `industry-performance-snapshot` or its historical endpoint.
150#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
151#[serde(rename_all = "camelCase")]
152pub struct IndustryPerformance {
153    pub date: NaiveDate,
154    #[serde(deserialize_with = "super::non_empty_string")]
155    pub industry: String,
156    pub exchange: String,
157    pub average_change: f64,
158}
159
160/// A company in the `biggest-gainers`, `biggest-losers`, or `most-actives` lists.
161#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
162#[serde(rename_all = "camelCase")]
163pub struct MarketMover {
164    #[serde(deserialize_with = "super::non_empty_string")]
165    pub symbol: String,
166    pub name: String,
167    pub price: f64,
168    pub change: Option<f64>,
169    pub changes_percentage: Option<f64>,
170    pub exchange: Option<String>,
171}