Skip to main content

finance_query/models/market/
performance.rs

1//! Market-wide performance models.
2//!
3//! Returned by the [`Capability::MARKET`](crate::Capability::MARKET) route via
4//! [`Providers::market`](crate::Providers::market).
5
6use serde::{Deserialize, Serialize};
7
8/// Which set of market movers to fetch.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10#[non_exhaustive]
11pub enum MoverDirection {
12    /// Largest percentage gainers.
13    Gainers,
14    /// Largest percentage losers.
15    Losers,
16    /// Highest traded volume.
17    MostActive,
18}
19
20/// A sector's aggregate performance.
21#[derive(Debug, Clone, Default, Serialize, Deserialize)]
22#[non_exhaustive]
23pub struct SectorPerformance {
24    /// Sector name (e.g. `"Technology"`).
25    pub sector: String,
26    /// Exchange the average was computed over (e.g. `"NASDAQ"`). Providers
27    /// report one row per sector per exchange.
28    pub exchange: Option<String>,
29    /// Percentage change, as a number (e.g. `1.23` for `"1.23%"`).
30    pub change_percent: Option<f64>,
31}
32
33/// One day of aggregate performance across every sector and exchange.
34#[derive(Debug, Clone, Default, Serialize, Deserialize)]
35#[non_exhaustive]
36pub struct SectorPerformanceHistory {
37    /// Date (`YYYY-MM-DD`).
38    pub date: Option<String>,
39    /// Per-sector percentage change on that date, one entry per
40    /// (sector, exchange) pair.
41    pub sectors: Vec<SectorPerformance>,
42}
43
44/// A sector's aggregate price/earnings ratio.
45#[derive(Debug, Clone, Default, Serialize, Deserialize)]
46#[non_exhaustive]
47pub struct SectorPe {
48    /// Sector name.
49    pub sector: String,
50    /// Exchange the ratio was computed over.
51    pub exchange: Option<String>,
52    /// Price/earnings ratio.
53    pub pe: Option<f64>,
54    /// As-of date (`YYYY-MM-DD`).
55    pub date: Option<String>,
56}
57
58/// An industry's aggregate price/earnings ratio.
59#[derive(Debug, Clone, Default, Serialize, Deserialize)]
60#[non_exhaustive]
61pub struct IndustryPe {
62    /// Industry name.
63    pub industry: String,
64    /// Exchange the ratio was computed over.
65    pub exchange: Option<String>,
66    /// Price/earnings ratio.
67    pub pe: Option<f64>,
68    /// As-of date (`YYYY-MM-DD`).
69    pub date: Option<String>,
70}
71
72/// A symbol appearing in a market-movers list.
73#[derive(Debug, Clone, Default, Serialize, Deserialize)]
74#[non_exhaustive]
75pub struct MoverQuote {
76    /// Ticker symbol.
77    pub symbol: String,
78    /// Company name.
79    pub name: Option<String>,
80    /// Latest price.
81    pub price: Option<f64>,
82    /// Absolute price change.
83    pub change: Option<f64>,
84    /// Percentage price change.
85    pub change_percent: Option<f64>,
86    /// Exchange the symbol trades on.
87    pub exchange: Option<String>,
88}