Skip to main content

Module registry

Module registry 

Source
Expand description

Indicator registry — create indicators by name at runtime.

Mirrors indicators/registry.py and indicators/factory.py:

  • IndicatorRegistryclass IndicatorRegistry
  • register! macro ↔ @register_indicator decorator
  • IndicatorFactory::create(name, params)IndicatorFactory.create(name, **params)

§Usage

use crate::registry::REGISTRY;

// list what's available
let names = REGISTRY.list();

// create by name with typed params map
let params = [("period", "20")].into();
let indicator = REGISTRY.create("sma", params).unwrap();
let output = indicator.calculate(&candles).unwrap();

Structs§

IndicatorRegistry
Runtime registry mapping indicator names to their factory functions.

Statics§

REGISTRY
Global indicator registry — the single source of truth for runtime creation.

Functions§

param_f64
Parse an f64 from the params map with a default fallback.
param_str
Parse a String param with a default fallback.
param_usize
Parse a usize from the params map with a default fallback.
registry
Get (or lazily init) the global registry.

Type Aliases§

IndicatorFactory
A function that constructs a Box<dyn Indicator> from a string param map.