Skip to main content

finance_query/models/chart/
candle.rs

1use crate::Provider;
2/// Candle module
3///
4/// Contains the OHLCV candle/bar structure.
5use serde::{Deserialize, Serialize};
6
7/// A single OHLCV candle/bar
8///
9/// Note: This struct cannot be manually constructed - obtain via `Ticker::chart()`.
10#[non_exhaustive]
11#[derive(Debug, Clone, Default, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13#[cfg_attr(feature = "dataframe", derive(crate::ToDataFrame))]
14pub struct Candle {
15    /// Timestamp (Unix)
16    pub timestamp: i64,
17    /// Open price
18    pub open: f64,
19    /// High price
20    pub high: f64,
21    /// Low price
22    pub low: f64,
23    /// Close price
24    pub close: f64,
25    /// Volume
26    pub volume: i64,
27    /// Adjusted close (if available)
28    pub adj_close: Option<f64>,
29
30    /// Which data provider served this data (e.g., "yahoo", "polygon").
31    #[serde(skip_serializing_if = "Option::is_none", default)]
32    pub provider_id: Option<Provider>,
33}