pub struct IndicatorRegistry { /* private fields */ }Expand description
A registry that owns a collection of Indicator trait objects and
provides batch operations (calculate all, clear, etc.).
Use the registry when you want to manage multiple indicators as a group and recalculate them together whenever the underlying bar data changes.
§Example
use egui_charts::studies::{IndicatorRegistry, SMA, EMA};
let mut registry = IndicatorRegistry::new();
registry.add(Box::new(SMA::new(20)));
registry.add(Box::new(EMA::new(50)));
registry.calculate_all(&bars);
for indicator in registry.indicators() {
println!("{}: {} values", indicator.name(), indicator.values().len());
}Implementations§
Source§impl IndicatorRegistry
impl IndicatorRegistry
Sourcepub fn add_indicator(&mut self, indicator: Box<dyn Indicator>)
pub fn add_indicator(&mut self, indicator: Box<dyn Indicator>)
Append a boxed indicator to the registry.
Sourcepub fn add(&mut self, indicator: Box<dyn Indicator>)
pub fn add(&mut self, indicator: Box<dyn Indicator>)
Alias for add_indicator for brevity.
Sourcepub fn remove_indicator(&mut self, index: usize) -> Option<Box<dyn Indicator>>
pub fn remove_indicator(&mut self, index: usize) -> Option<Box<dyn Indicator>>
Remove and return the indicator at index, or None if out of bounds.
Sourcepub fn indicators(&self) -> &[Box<dyn Indicator>]
pub fn indicators(&self) -> &[Box<dyn Indicator>]
Return a shared slice of all registered indicators.
Sourcepub fn indicators_mut(&mut self) -> &mut [Box<dyn Indicator>]
pub fn indicators_mut(&mut self) -> &mut [Box<dyn Indicator>]
Return a mutable slice of all registered indicators.
Sourcepub fn calculate_all(&mut self, data: &[Bar])
pub fn calculate_all(&mut self, data: &[Bar])
Recalculate every indicator against the provided bar data.
This iterates through all registered indicators and calls
Indicator::calculate on each one.
Sourcepub fn update_all(&mut self, data: &[Bar], from: usize)
pub fn update_all(&mut self, data: &[Bar], from: usize)
Bring every indicator up to date after data[from..] changed or grew,
given that data[..from] is unchanged since the previous call.
Calls Indicator::update on each one; studies that are not
incremental recompute in full.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for IndicatorRegistry
impl !Sync for IndicatorRegistry
impl !UnwindSafe for IndicatorRegistry
impl Freeze for IndicatorRegistry
impl Send for IndicatorRegistry
impl Unpin for IndicatorRegistry
impl UnsafeUnpin for IndicatorRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more