Skip to main content

fmp_rust_sdk/models/
prices.rs

1//! End-of-day and intraday price series.
2
3use chrono::{NaiveDate, NaiveDateTime};
4use serde::{Deserialize, Serialize};
5
6/// A daily OHLCV bar from `historical-price-eod/full`; prices are split-adjusted.
7#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct HistoricalPrice {
10    #[serde(deserialize_with = "super::non_empty_string")]
11    pub symbol: String,
12    pub date: NaiveDate,
13    pub open: f64,
14    pub high: f64,
15    pub low: f64,
16    pub close: f64,
17    pub volume: f64,
18    pub change: Option<f64>,
19    pub change_percent: Option<f64>,
20    pub vwap: Option<f64>,
21}
22
23/// A daily close from `historical-price-eod/light`.
24#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
25pub struct HistoricalPriceLight {
26    #[serde(deserialize_with = "super::non_empty_string")]
27    pub symbol: String,
28    pub date: NaiveDate,
29    pub price: f64,
30    pub volume: Option<f64>,
31}
32
33/// An intraday OHLCV bar from `historical-chart/{interval}`.
34#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
35pub struct IntradayPrice {
36    /// The provider's timestamp has no timezone offset.
37    #[serde(with = "super::timestamp")]
38    pub date: NaiveDateTime,
39    pub open: f64,
40    pub high: f64,
41    pub low: f64,
42    pub close: f64,
43    pub volume: f64,
44}