Skip to main content

IndicatorFactory

Struct IndicatorFactory 

Source
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

Source

pub const CUSTOM: &'static str = "Custom"

The category of every indicator added with register.

Source

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.

Source

pub const COMMUNITY: &'static str = "Community"

The category of studies the host obtains from other users.

Source

pub const PROFILES: &'static str = "Profiles"

The category of the built-in volume and time price profiles.

Source

pub const PATTERNS: &'static str = "Patterns"

The category of the built-in pattern detectors.

Source

pub const ORDER_FLOW: &'static str = "Order flow"

The category of studies computed from trades, quotes or the order book.

Source

pub fn new() -> Self

Create a factory with the built-in catalogue enabled by the current features.

Source

pub fn register<F>(&mut self, name: impl Into<String>, constructor: F) -> bool
where F: Fn() -> Box<dyn Indicator> + Send + Sync + 'static,

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.
Source

pub fn register_in<F>( &mut self, category: &'static str, name: impl Into<String>, constructor: F, ) -> bool
where F: Fn() -> Box<dyn Indicator> + Send + Sync + 'static,

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.

Source

pub fn create(&self, name: &str) -> Option<Box<dyn Indicator>>

Create an indicator by its registered name, or None if not found.

Source

pub fn category(&self, name: &str) -> Option<&'static str>

The category of the indicator registered under name, such as "Momentum" or "Volume" for a built-in and CUSTOM for one added with register, or None if not found or left out of the catalogue.

Source

pub fn list(&self) -> Vec<String>

The names a study picker offers, unordered: every registered name except the exported studies outside the catalogue.

Source

pub fn has(&self, name: &str) -> bool

Whether create resolves name, also one that list leaves out.

Source

pub fn unregister(&mut self, name: &str) -> bool

Remove the indicator registered under name.

Returns true if it was present and removed, false otherwise.

Source

pub fn clear(&mut self)

Remove all registered indicators, including built-ins.

Source

pub fn count(&self) -> usize

The number of names in list.

Trait Implementations§

Source§

impl Default for IndicatorFactory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.