finance-query 2.5.1

A Rust library for querying financial data
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
//! Indicators summary module.
//!
//! Provides the `IndicatorsSummary` type which calculates and returns the latest
//! values for all 52+ technical indicators at once.
//!
//! This module reuses the main indicator implementations and extracts the last value,
//! ensuring consistency and eliminating code duplication.

use super::last_value;
use crate::Candle;
use crate::indicators::{
    accumulation_distribution, adx, alma, aroon, atr, atr::atr_raw, awesome_oscillator,
    balance_of_power, bollinger_bands, bull_bear_power, cci, chaikin_oscillator, choppiness_index,
    cmf, cmo, coppock_curve, dema, donchian_channels, elder_ray, ema::ema_raw, hma, ichimoku,
    keltner_channels::keltner_with_atr_dense, macd, mcginley_dynamic, mfi, momentum, obv,
    parabolic_sar, roc, rsi::rsi_raw, sma::sma_raw, stochastic,
    stochastic_rsi::stochastic_rsi_from_rsi_dense, supertrend::supertrend_with_atr_dense, tema,
    true_range, vwap, vwma, williams_r, wma::wma_raw,
};

/// Helper to extract last value from Result-returning indicators
#[inline]
fn last_from_result(result: crate::indicators::Result<Vec<Option<f64>>>) -> Option<f64> {
    result.ok().and_then(|v| last_value(&v))
}

/// Calculate all technical indicators from candle data.
///
/// Returns the latest values for all implemented indicators.
/// Reuses the main indicator implementations for consistency.
pub(crate) fn calculate_indicators(candles: &[Candle]) -> IndicatorsSummary {
    if candles.is_empty() {
        return IndicatorsSummary::default();
    }

    // Extract price data from candles in a single pass (avoids 5 separate iterations)
    let len = candles.len();
    let mut closes = Vec::with_capacity(len);
    let mut highs = Vec::with_capacity(len);
    let mut lows = Vec::with_capacity(len);
    let mut opens = Vec::with_capacity(len);
    let mut volumes = Vec::with_capacity(len);
    for c in candles {
        closes.push(c.close);
        highs.push(c.high);
        lows.push(c.low);
        opens.push(c.open);
        volumes.push(c.volume as f64);
    }

    // Pre-compute shared intermediates (avoids redundant passes)
    let rsi_14_dense = rsi_raw(&closes, 14).ok();
    let atr_10_dense = atr_raw(&highs, &lows, &closes, 10).ok();

    IndicatorsSummary {
        // === MOVING AVERAGES ===
        sma_10: sma_raw(&closes, 10).last().copied(),
        sma_20: sma_raw(&closes, 20).last().copied(),
        sma_50: sma_raw(&closes, 50).last().copied(),
        sma_100: sma_raw(&closes, 100).last().copied(),
        sma_200: sma_raw(&closes, 200).last().copied(),

        ema_10: ema_raw(&closes, 10).last().copied(),
        ema_20: ema_raw(&closes, 20).last().copied(),
        ema_50: ema_raw(&closes, 50).last().copied(),
        ema_100: ema_raw(&closes, 100).last().copied(),
        ema_200: ema_raw(&closes, 200).last().copied(),

        wma_10: wma_raw(&closes, 10).last().copied(),
        wma_20: wma_raw(&closes, 20).last().copied(),
        wma_50: wma_raw(&closes, 50).last().copied(),
        wma_100: wma_raw(&closes, 100).last().copied(),
        wma_200: wma_raw(&closes, 200).last().copied(),

        // Advanced Moving Averages (Result types)
        dema_20: dema(&closes, 20).ok().and_then(|v| last_value(&v)),
        tema_20: tema(&closes, 20).ok().and_then(|v| last_value(&v)),
        hma_20: hma(&closes, 20).ok().and_then(|v| last_value(&v)),
        vwma_20: vwma(&closes, &volumes, 20)
            .ok()
            .and_then(|v| last_value(&v)),
        alma_9: alma(&closes, 9, 0.85, 6.0)
            .ok()
            .and_then(|v| last_value(&v)),
        mcginley_dynamic_20: mcginley_dynamic(&closes, 20)
            .ok()
            .and_then(|v| last_value(&v)),

        // === MOMENTUM OSCILLATORS ===
        rsi_14: rsi_14_dense.as_deref().and_then(|v| v.last().copied()),
        stochastic: {
            stochastic(&highs, &lows, &closes, 14, 1, 3)
                .ok()
                .map(|result| StochasticData {
                    k: last_value(&result.k),
                    d: last_value(&result.d),
                })
        },
        stochastic_rsi: {
            rsi_14_dense.as_deref().and_then(|rsi_dense| {
                stochastic_rsi_from_rsi_dense(rsi_dense, len, 14, 14, 3, 3)
                    .ok()
                    .map(|result| StochasticData {
                        k: last_value(&result.k),
                        d: last_value(&result.d),
                    })
            })
        },
        cci_20: last_from_result(cci(&highs, &lows, &closes, 20)),
        williams_r_14: last_from_result(williams_r(&highs, &lows, &closes, 14)),
        roc_12: last_from_result(roc(&closes, 12)),
        momentum_10: last_from_result(momentum(&closes, 10)),
        cmo_14: last_from_result(cmo(&closes, 14)),
        awesome_oscillator: last_from_result(awesome_oscillator(&highs, &lows, 5, 34)),
        coppock_curve: last_from_result(coppock_curve(&closes, 14, 11, 10)),

        // === TREND INDICATORS ===
        macd: {
            macd(&closes, 12, 26, 9).ok().map(|result| MacdData {
                macd: last_value(&result.macd_line),
                signal: last_value(&result.signal_line),
                histogram: last_value(&result.histogram),
            })
        },
        adx_14: last_from_result(adx(&highs, &lows, &closes, 14)),
        aroon: {
            aroon(&highs, &lows, 25).ok().map(|result| AroonData {
                aroon_up: last_value(&result.aroon_up),
                aroon_down: last_value(&result.aroon_down),
            })
        },
        supertrend: {
            atr_10_dense.as_deref().and_then(|atr_dense| {
                supertrend_with_atr_dense(&highs, &lows, &closes, atr_dense, 10, 3.0)
                    .ok()
                    .map(|result| SuperTrendData {
                        value: last_value(&result.value),
                        trend: result.is_uptrend.last().and_then(|&v| v).map(|v| {
                            if v {
                                "up".to_string()
                            } else {
                                "down".to_string()
                            }
                        }),
                    })
            })
        },
        ichimoku: {
            ichimoku(&highs, &lows, &closes, 9, 26, 26, 26)
                .ok()
                .map(|result| IchimokuData {
                    conversion_line: last_value(&result.conversion_line),
                    base_line: last_value(&result.base_line),
                    leading_span_a: last_value(&result.leading_span_a),
                    leading_span_b: last_value(&result.leading_span_b),
                    lagging_span: last_value(&result.lagging_span),
                })
        },
        parabolic_sar: last_from_result(parabolic_sar(&highs, &lows, &closes, 0.02, 0.2)),
        bull_bear_power: {
            bull_bear_power(&highs, &lows, &closes, 13)
                .ok()
                .map(|result| BullBearPowerData {
                    bull_power: last_value(&result.bull_power),
                    bear_power: last_value(&result.bear_power),
                })
        },
        elder_ray_index: {
            elder_ray(&highs, &lows, &closes, 13)
                .ok()
                .map(|result| ElderRayData {
                    bull_power: last_value(&result.bull_power),
                    bear_power: last_value(&result.bear_power),
                })
        },

        // === VOLATILITY INDICATORS ===
        bollinger_bands: {
            bollinger_bands(&closes, 20, 2.0)
                .ok()
                .map(|result| BollingerBandsData {
                    upper: last_value(&result.upper),
                    middle: last_value(&result.middle),
                    lower: last_value(&result.lower),
                })
        },
        keltner_channels: {
            atr_10_dense.as_deref().and_then(|atr_dense| {
                keltner_with_atr_dense(&closes, 20, atr_dense, 10, 2.0)
                    .ok()
                    .map(|result| KeltnerChannelsData {
                        upper: last_value(&result.upper),
                        middle: last_value(&result.middle),
                        lower: last_value(&result.lower),
                    })
            })
        },
        donchian_channels: {
            donchian_channels(&highs, &lows, 20)
                .ok()
                .map(|result| DonchianChannelsData {
                    upper: last_value(&result.upper),
                    middle: last_value(&result.middle),
                    lower: last_value(&result.lower),
                })
        },
        atr_14: last_from_result(atr(&highs, &lows, &closes, 14)),
        true_range: last_from_result(true_range(&highs, &lows, &closes)),
        choppiness_index_14: last_from_result(choppiness_index(&highs, &lows, &closes, 14)),

        // === VOLUME INDICATORS ===
        obv: last_from_result(obv(&closes, &volumes)),
        mfi_14: last_from_result(mfi(&highs, &lows, &closes, &volumes, 14)),
        cmf_20: last_from_result(cmf(&highs, &lows, &closes, &volumes, 20)),
        chaikin_oscillator: last_from_result(chaikin_oscillator(&highs, &lows, &closes, &volumes)),
        accumulation_distribution: last_from_result(accumulation_distribution(
            &highs, &lows, &closes, &volumes,
        )),
        vwap: last_from_result(vwap(&highs, &lows, &closes, &volumes)),
        balance_of_power: last_from_result(balance_of_power(&opens, &highs, &lows, &closes, None)),
    }
}

/// Summary of all calculated technical indicators
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "dataframe", derive(crate::ToDataFrame))]
#[serde(rename_all = "camelCase")]
pub struct IndicatorsSummary {
    // === MOVING AVERAGES ===
    // Simple Moving Averages
    /// Simple Moving Average (10-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sma_10: Option<f64>,
    /// Simple Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sma_20: Option<f64>,
    /// Simple Moving Average (50-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sma_50: Option<f64>,
    /// Simple Moving Average (100-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sma_100: Option<f64>,
    /// Simple Moving Average (200-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sma_200: Option<f64>,

    // Exponential Moving Averages
    /// Exponential Moving Average (10-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ema_10: Option<f64>,
    /// Exponential Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ema_20: Option<f64>,
    /// Exponential Moving Average (50-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ema_50: Option<f64>,
    /// Exponential Moving Average (100-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ema_100: Option<f64>,
    /// Exponential Moving Average (200-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ema_200: Option<f64>,

    // Weighted Moving Averages
    /// Weighted Moving Average (10-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wma_10: Option<f64>,
    /// Weighted Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wma_20: Option<f64>,
    /// Weighted Moving Average (50-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wma_50: Option<f64>,
    /// Weighted Moving Average (100-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wma_100: Option<f64>,
    /// Weighted Moving Average (200-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wma_200: Option<f64>,

    // Advanced Moving Averages
    /// Double Exponential Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dema_20: Option<f64>,
    /// Triple Exponential Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tema_20: Option<f64>,
    /// Hull Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hma_20: Option<f64>,
    /// Volume Weighted Moving Average (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vwma_20: Option<f64>,
    /// Arnaud Legoux Moving Average (9-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alma_9: Option<f64>,
    /// McGinley Dynamic (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mcginley_dynamic_20: Option<f64>,

    // === MOMENTUM OSCILLATORS ===
    /// Relative Strength Index (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rsi_14: Option<f64>,
    /// Stochastic Oscillator (14, 3, 3)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stochastic: Option<StochasticData>,
    /// Commodity Channel Index (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cci_20: Option<f64>,
    /// Williams %R (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub williams_r_14: Option<f64>,
    /// Stochastic RSI (14, 14)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stochastic_rsi: Option<StochasticData>,
    /// Rate of Change (12-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub roc_12: Option<f64>,
    /// Momentum (10-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub momentum_10: Option<f64>,
    /// Chande Momentum Oscillator (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cmo_14: Option<f64>,
    /// Awesome Oscillator (5, 34)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub awesome_oscillator: Option<f64>,
    /// Coppock Curve (10, 11, 14)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coppock_curve: Option<f64>,

    // === TREND INDICATORS ===
    /// Moving Average Convergence Divergence (12, 26, 9)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub macd: Option<MacdData>,
    /// Average Directional Index (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub adx_14: Option<f64>,
    /// Aroon Indicator (25-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aroon: Option<AroonData>,
    /// SuperTrend Indicator (10, 3.0)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supertrend: Option<SuperTrendData>,
    /// Ichimoku Cloud (9, 26, 52, 26)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ichimoku: Option<IchimokuData>,
    /// Parabolic SAR (0.02, 0.2)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parabolic_sar: Option<f64>,
    /// Bull Bear Power (13-period EMA based)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bull_bear_power: Option<BullBearPowerData>,
    /// Elder Ray Index (13-period EMA based)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elder_ray_index: Option<ElderRayData>,

    // === VOLATILITY INDICATORS ===
    /// Bollinger Bands (20, 2.0)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bollinger_bands: Option<BollingerBandsData>,
    /// Average True Range (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub atr_14: Option<f64>,
    /// Keltner Channels (20, 10, 2.0)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub keltner_channels: Option<KeltnerChannelsData>,
    /// Donchian Channels (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub donchian_channels: Option<DonchianChannelsData>,
    /// True Range (current period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub true_range: Option<f64>,
    /// Choppiness Index (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub choppiness_index_14: Option<f64>,

    // === VOLUME INDICATORS ===
    /// On-Balance Volume
    #[serde(skip_serializing_if = "Option::is_none")]
    pub obv: Option<f64>,
    /// Money Flow Index (14-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mfi_14: Option<f64>,
    /// Chaikin Money Flow (20-period)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cmf_20: Option<f64>,
    /// Chaikin Oscillator (3, 10)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub chaikin_oscillator: Option<f64>,
    /// Accumulation/Distribution Line
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accumulation_distribution: Option<f64>,
    /// Volume Weighted Average Price
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vwap: Option<f64>,
    /// Balance of Power
    #[serde(skip_serializing_if = "Option::is_none")]
    pub balance_of_power: Option<f64>,
}

/// Stochastic Oscillator data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StochasticData {
    /// %K line value
    #[serde(rename = "%K", skip_serializing_if = "Option::is_none")]
    pub k: Option<f64>,
    /// %D line value
    #[serde(rename = "%D", skip_serializing_if = "Option::is_none")]
    pub d: Option<f64>,
}

/// MACD indicator data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MacdData {
    /// MACD line value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub macd: Option<f64>,
    /// Signal line value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub signal: Option<f64>,
    /// Histogram value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub histogram: Option<f64>,
}

/// Aroon indicator data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AroonData {
    /// Aroon Up value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aroon_up: Option<f64>,
    /// Aroon Down value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aroon_down: Option<f64>,
}

/// Bollinger Bands data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BollingerBandsData {
    /// Upper band value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub upper: Option<f64>,
    /// Middle band value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub middle: Option<f64>,
    /// Lower band value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lower: Option<f64>,
}

/// SuperTrend indicator data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SuperTrendData {
    /// SuperTrend value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<f64>,
    /// Trend direction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trend: Option<String>,
}

/// Ichimoku Cloud data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IchimokuData {
    /// Conversion line (Tenkan-sen)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conversion_line: Option<f64>,
    /// Base line (Kijun-sen)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub base_line: Option<f64>,
    /// Leading Span A (Senkou Span A)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub leading_span_a: Option<f64>,
    /// Leading Span B (Senkou Span B)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub leading_span_b: Option<f64>,
    /// Lagging Span (Chikou Span)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lagging_span: Option<f64>,
}

/// Keltner Channels data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct KeltnerChannelsData {
    /// Upper channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub upper: Option<f64>,
    /// Middle channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub middle: Option<f64>,
    /// Lower channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lower: Option<f64>,
}

/// Donchian Channels data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DonchianChannelsData {
    /// Upper channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub upper: Option<f64>,
    /// Middle channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub middle: Option<f64>,
    /// Lower channel value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lower: Option<f64>,
}

/// Bull Bear Power indicator data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BullBearPowerData {
    /// Bull power value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bull_power: Option<f64>,
    /// Bear power value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bear_power: Option<f64>,
}

/// Elder Ray Index data
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElderRayData {
    /// Bull power value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bull_power: Option<f64>,
    /// Bear power value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bear_power: Option<f64>,
}