Expand description
Indicator registry — create indicators by name at runtime.
Mirrors indicators/registry.py and indicators/factory.py:
IndicatorRegistry↔class IndicatorRegistryregister!macro ↔@register_indicatordecoratorIndicatorFactory::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§
- Indicator
Registry - 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
f64from the params map with a default fallback. - param_
str - Parse a
Stringparam with a default fallback. - param_
usize - Parse a
usizefrom the params map with a default fallback. - registry
- Get (or lazily init) the global registry.
Type Aliases§
- Indicator
Factory - A function that constructs a
Box<dyn Indicator>from a string param map.