fmp_rs/models/
technical_indicators.rs

1//! Models for technical indicators endpoints
2
3use serde::{Deserialize, Serialize};
4
5/// Technical indicator data point
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct TechnicalIndicator {
9    /// Date
10    pub date: String,
11    /// Indicator value
12    #[serde(flatten)]
13    pub values: std::collections::HashMap<String, f64>,
14}
15
16/// Simple Moving Average (SMA) data
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct SmaData {
20    /// Date
21    pub date: String,
22    /// SMA value
23    pub sma: Option<f64>,
24}
25
26/// Exponential Moving Average (EMA) data
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct EmaData {
30    /// Date
31    pub date: String,
32    /// EMA value
33    pub ema: Option<f64>,
34}
35
36/// Weighted Moving Average (WMA) data
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(rename_all = "camelCase")]
39pub struct WmaData {
40    /// Date
41    pub date: String,
42    /// WMA value
43    pub wma: Option<f64>,
44}
45
46/// Double Exponential Moving Average (DEMA) data
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49pub struct DemaData {
50    /// Date
51    pub date: String,
52    /// DEMA value
53    pub dema: Option<f64>,
54}
55
56/// Triple Exponential Moving Average (TEMA) data
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(rename_all = "camelCase")]
59pub struct TemaData {
60    /// Date
61    pub date: String,
62    /// TEMA value
63    pub tema: Option<f64>,
64}
65
66/// Relative Strength Index (RSI) data
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(rename_all = "camelCase")]
69pub struct RsiData {
70    /// Date
71    pub date: String,
72    /// RSI value (0-100)
73    pub rsi: Option<f64>,
74}
75
76/// Average Directional Index (ADX) data
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct AdxData {
80    /// Date
81    pub date: String,
82    /// ADX value
83    pub adx: Option<f64>,
84}
85
86/// Standardized data structure for technical indicators
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(rename_all = "camelCase")]
89pub struct StandardizedIndicator {
90    /// Date
91    pub date: String,
92    /// Open price
93    pub open: Option<f64>,
94    /// High price
95    pub high: Option<f64>,
96    /// Low price
97    pub low: Option<f64>,
98    /// Close price
99    pub close: Option<f64>,
100    /// Volume
101    pub volume: Option<f64>,
102}
103
104/// Williams %R indicator data
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(rename_all = "camelCase")]
107pub struct WilliamsRData {
108    /// Date
109    pub date: String,
110    /// Williams %R value (-100 to 0)
111    pub williams_r: Option<f64>,
112}
113
114/// Commodity Channel Index (CCI) data
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(rename_all = "camelCase")]
117pub struct CciData {
118    /// Date
119    pub date: String,
120    /// CCI value
121    pub cci: Option<f64>,
122}
123
124/// MACD (Moving Average Convergence Divergence) data
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(rename_all = "camelCase")]
127pub struct MacdData {
128    /// Date
129    pub date: String,
130    /// MACD line
131    pub macd: Option<f64>,
132    /// Signal line
133    pub signal: Option<f64>,
134    /// Histogram
135    pub histogram: Option<f64>,
136}
137
138/// Stochastic Oscillator data
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(rename_all = "camelCase")]
141pub struct StochasticData {
142    /// Date
143    pub date: String,
144    /// %K value
145    pub slow_k: Option<f64>,
146    /// %D value
147    pub slow_d: Option<f64>,
148}
149
150/// Bollinger Bands data
151#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(rename_all = "camelCase")]
153pub struct BollingerBandsData {
154    /// Date
155    pub date: String,
156    /// Upper band
157    pub upper_band: Option<f64>,
158    /// Middle band (SMA)
159    pub middle_band: Option<f64>,
160    /// Lower band
161    pub lower_band: Option<f64>,
162}
163
164/// Average True Range (ATR) data
165#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(rename_all = "camelCase")]
167pub struct AtrData {
168    /// Date
169    pub date: String,
170    /// ATR value
171    pub atr: Option<f64>,
172}
173
174/// Aroon Indicator data
175#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(rename_all = "camelCase")]
177pub struct AroonData {
178    /// Date
179    pub date: String,
180    /// Aroon Up
181    pub aroon_up: Option<f64>,
182    /// Aroon Down
183    pub aroon_down: Option<f64>,
184}