pub struct BollingerBands { /* private fields */ }Expand description
Bollinger Bands indicator.
Implementations§
Source§impl BollingerBands
impl BollingerBands
Sourcepub fn new(period: usize, multiplier: f64) -> Result<Self, SMAError>
pub fn new(period: usize, multiplier: f64) -> Result<Self, SMAError>
Creates a new BollingerBands indicator.
§Arguments
period- The number of values for the moving average and standard deviation.multiplier- The multiplier applied to the standard deviation to determine band width.
§Returns
Ok(BollingerBands)on success, orErr(SMAError)if the underlying SMA creation fails.
§Examples
use indexes_rs::v1::bollinger::main::BollingerBands;
let bb = BollingerBands::new(20, 2.0);
assert!(bb.is_ok());Sourcepub fn calculate(&mut self, price: f64) -> Option<BBResult>
pub fn calculate(&mut self, price: f64) -> Option<BBResult>
Calculates the Bollinger Bands for the given price.
The method updates the internal SMA and sliding window of prices.
It returns a BBResult containing the upper, middle, and lower bands when enough data is available.
§Arguments
price- The latest price.
§Returns
Some(BBResult)if enough data is available.Noneif not enough data has been collected.
Auto Trait Implementations§
impl Freeze for BollingerBands
impl RefUnwindSafe for BollingerBands
impl Send for BollingerBands
impl Sync for BollingerBands
impl Unpin 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