finance_query/models/fundamentals/consensus.rs
1//! Aggregated analyst-consensus models.
2//!
3//! Served through the [`Capability::FUNDAMENTALS`](crate::Capability::FUNDAMENTALS)
4//! route; FMP is currently the only provider. These are provider-side rollups
5//! over the whole analyst panel — distinct from the raw per-analyst grade
6//! actions in [`UpgradeDowngradeHistory`](crate::UpgradeDowngradeHistory).
7
8use serde::{Deserialize, Serialize};
9
10/// Consensus analyst price target for a symbol.
11#[derive(Debug, Clone, Default, Serialize, Deserialize)]
12#[non_exhaustive]
13pub struct PriceTargetConsensus {
14 /// Ticker symbol.
15 pub symbol: Option<String>,
16 /// Highest price target across the analyst panel.
17 pub target_high: Option<f64>,
18 /// Lowest price target across the analyst panel.
19 pub target_low: Option<f64>,
20 /// Mean price target.
21 pub target_consensus: Option<f64>,
22 /// Median price target.
23 pub target_median: Option<f64>,
24}
25
26/// Price-target activity over trailing windows: how many targets were published
27/// and their average, per window.
28#[derive(Debug, Clone, Default, Serialize, Deserialize)]
29#[non_exhaustive]
30pub struct PriceTargetSummary {
31 /// Ticker symbol.
32 pub symbol: Option<String>,
33 /// Number of price targets published in the last month.
34 pub last_month_count: Option<i64>,
35 /// Average price target published in the last month.
36 pub last_month_avg: Option<f64>,
37 /// Number of price targets published in the last quarter.
38 pub last_quarter_count: Option<i64>,
39 /// Average price target published in the last quarter.
40 pub last_quarter_avg: Option<f64>,
41 /// Number of price targets published in the last year.
42 pub last_year_count: Option<i64>,
43 /// Average price target published in the last year.
44 pub last_year_avg: Option<f64>,
45 /// Number of price targets published all time.
46 pub all_time_count: Option<i64>,
47 /// Average price target published all time.
48 pub all_time_avg: Option<f64>,
49}
50
51/// Consensus rating rollup — the analyst panel's grade distribution plus the
52/// provider's headline recommendation.
53#[derive(Debug, Clone, Default, Serialize, Deserialize)]
54#[non_exhaustive]
55pub struct RatingConsensus {
56 /// Ticker symbol.
57 pub symbol: Option<String>,
58 /// Analysts rating the symbol a strong buy.
59 pub strong_buy: Option<i64>,
60 /// Analysts rating the symbol a buy.
61 pub buy: Option<i64>,
62 /// Analysts rating the symbol a hold.
63 pub hold: Option<i64>,
64 /// Analysts rating the symbol a sell.
65 pub sell: Option<i64>,
66 /// Analysts rating the symbol a strong sell.
67 pub strong_sell: Option<i64>,
68 /// Headline consensus label (e.g. `"Buy"`).
69 pub consensus: Option<String>,
70}