pub struct IndicatorFactory { /* private fields */ }Expand description
A factory that creates Indicator instances by name.
On construction, catalogue studies are registered under their canonical
Indicator::name (e.g. "SMA", "RSI", "MACD", "SuperTrend") using
its conventional default parameters. Each name selects a distinct calculation
or source range. Additional indicators can be registered at runtime with
register.
create and has also resolve the names of seven exported
studies the catalogue leaves out, so that a template, a copied study or a saved layout of
one is recreated: CVD, C2C Vol, HL2, HLC3, Price Channel, Ehlers Fisher and
MA Combination, which creates MACombination::ribbon for its inputs to reshape. They have
no category and are not in list or count.
Implementations§
Source§impl IndicatorFactory
impl IndicatorFactory
Sourcepub const PERSONAL: &'static str = "Personal"
pub const PERSONAL: &'static str = "Personal"
The category of the user’s own studies, such as scripts the host compiles or imports; a study browser lists them as the user’s scripts.
Sourcepub const COMMUNITY: &'static str = "Community"
pub const COMMUNITY: &'static str = "Community"
The category of studies the host obtains from other users.
Sourcepub const PROFILES: &'static str = "Profiles"
pub const PROFILES: &'static str = "Profiles"
The category of the built-in volume and time price profiles.
Sourcepub const ORDER_FLOW: &'static str = "Order flow"
pub const ORDER_FLOW: &'static str = "Order flow"
The category of studies computed from trades, quotes or the order book.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a factory with the built-in catalogue enabled by the current features.
Sourcepub fn register<F>(&mut self, name: impl Into<String>, constructor: F) -> bool
pub fn register<F>(&mut self, name: impl Into<String>, constructor: F) -> bool
Register a named indicator constructor in the CUSTOM category.
A constructor already registered under name, a built-in included, is replaced. Returns
false, registering nothing, when name is empty or only whitespace.
§Arguments
name– The lookup key (e.g."MySMA").constructor– A closure that returns a new boxed indicator.
Sourcepub fn register_in<F>(
&mut self,
category: &'static str,
name: impl Into<String>,
constructor: F,
) -> bool
pub fn register_in<F>( &mut self, category: &'static str, name: impl Into<String>, constructor: F, ) -> bool
Register a named indicator constructor in category, such as PERSONAL
for a script the user imported, COMMUNITY or
PROFILES or ORDER_FLOW.
A constructor already registered under name, a built-in included, is replaced. Returns
false, registering nothing, when name is empty or only whitespace.
Sourcepub fn create(&self, name: &str) -> Option<Box<dyn Indicator>>
pub fn create(&self, name: &str) -> Option<Box<dyn Indicator>>
Create an indicator by its registered name, or None if not found.
Sourcepub fn list(&self) -> Vec<String>
pub fn list(&self) -> Vec<String>
The names a study picker offers, unordered: every registered name except the exported studies outside the catalogue.
Sourcepub fn unregister(&mut self, name: &str) -> bool
pub fn unregister(&mut self, name: &str) -> bool
Remove the indicator registered under name.
Returns true if it was present and removed, false otherwise.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for IndicatorFactory
impl !UnwindSafe for IndicatorFactory
impl Freeze for IndicatorFactory
impl Send for IndicatorFactory
impl Sync for IndicatorFactory
impl Unpin for IndicatorFactory
impl UnsafeUnpin for IndicatorFactory
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