Skip to main content

finance_query/models/indices/
mod.rs

1//! Stock market index data models.
2//!
3//! Canonical public types for index quotes and constituents,
4//! shared across Polygon and FMP providers.
5
6use serde::{Deserialize, Serialize};
7
8/// A stock market index quote (e.g., S&P 500, NASDAQ, Dow Jones).
9///
10/// Obtain via [`Ticker::quote`](crate::Ticker::quote) using the index symbol (e.g., `"^GSPC"`).
11#[derive(Debug, Clone, Serialize, Deserialize)]
12#[non_exhaustive]
13pub struct IndexQuote {
14    /// Index ticker symbol (e.g., `"^GSPC"`, `"^IXIC"`)
15    pub symbol: String,
16    /// Human-readable index name (e.g., `"S&P 500"`)
17    pub name: Option<String>,
18    /// Current index value
19    pub price: Option<f64>,
20    /// Price change
21    pub change: Option<f64>,
22    /// Price change percentage
23    pub change_percent: Option<f64>,
24    /// Unix timestamp of the last update
25    pub timestamp: Option<i64>,
26}
27
28/// A constituent (member) of a major stock market index.
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[non_exhaustive]
31#[allow(dead_code)]
32pub struct IndexConstituent {
33    /// Ticker symbol of the constituent company
34    pub symbol: String,
35    /// Company name
36    pub name: Option<String>,
37    /// Sector classification
38    pub sector: Option<String>,
39    /// Industry classification
40    pub industry: Option<String>,
41    /// Market capitalization
42    pub market_cap: Option<f64>,
43    /// Weight in the index
44    pub weight: Option<f64>,
45}