pub struct BollingerBands { /* private fields */ }Expand description
Bollinger Bands indicator.
Bollinger Bands consist of:
- Middle band: Simple Moving Average
- Upper band: Middle + (multiplier * standard deviation)
- Lower band: Middle - (multiplier * standard deviation)
§Standard Parameters
- Period: 20
- Multiplier: 2.0
§Example
use quant_indicators::BollingerBands;
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let bb = BollingerBands::new(20, dec!(2)).unwrap();
let result = bb.compute(&candles).unwrap();
// result.upper, result.middle, result.lowerImplementations§
Source§impl BollingerBands
impl BollingerBands
Sourcepub fn standard() -> Result<Self, IndicatorError>
pub fn standard() -> Result<Self, IndicatorError>
Create Bollinger Bands with standard parameters (20, 2).
Sourcepub fn warmup_period(&self) -> usize
pub fn warmup_period(&self) -> usize
Minimum number of candles required.
Sourcepub fn compute(
&self,
candles: &[Candle],
) -> Result<BollingerResult, IndicatorError>
pub fn compute( &self, candles: &[Candle], ) -> Result<BollingerResult, IndicatorError>
Compute Bollinger Bands from candle data.
Returns a BollingerResult with upper, middle, and lower bands.
Trait Implementations§
Source§impl Clone for BollingerBands
impl Clone for BollingerBands
Source§fn clone(&self) -> BollingerBands
fn clone(&self) -> BollingerBands
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BollingerBands
impl RefUnwindSafe for BollingerBands
impl Send for BollingerBands
impl Sync for BollingerBands
impl Unpin for BollingerBands
impl UnsafeUnpin for BollingerBands
impl UnwindSafe for BollingerBands
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more