| name | quanux-indicators |
| description | Modern C++20 Indicators Library (Lazy Evaluation, Policy-Based) |
Quanux Indicators (libquanux-indicators)
Overview
A high-performance, C++20 header-only library replacing TA-Lib. It supports Lazy Evaluation (via ranges) and Policy-Based Design (for Market Profile).
1. Standard Indicators (SMA, RSI, etc.)
A. Lazy Evaluation (The Pipe Syntax)
Use when: Building complex pipelines or needing zero-allocation loop fusion.
#include "quanux/indicators/view.hpp"
#include "quanux/indicators/sma.hpp"
auto view = prices | quanux::indicators::sma(10);
for (auto val : view) { ... }
B. Eager Evaluation (Traditional)
Use when: You just need a std::vector result immediately.
#include "quanux/indicators/sma.hpp"
std::vector<double> results = quanux::indicators::compute_sma(prices, 10);
WARNING: Eager evaluation allocates memory for the entire result vector.
2. Market & Volume Profile (Auction Market Theory)
This library uses Policy-Based Design to let you choose performance characteristics.
Storage Policies
- DenseStorage (
std::vector): Fast, contiguous memory. Use for tight price ranges (Futures, Equities).
- SparseStorage (
std::map): Infinite range, slower access. Use for Crypto or sparsely traded assets.
Usage
#include "quanux/indicators/market_profile.hpp"
#include "quanux/indicators/volume_profile.hpp"
using namespace quanux::indicators;
MarketProfile<DenseStorage> es_profile(0.25);
es_profile.process(price);
VolumeProfile<SparseStorage> btc_profile(0.01);
btc_profile.process(price, volume);
3. Extensibility (The Registry)
To add new indicators, do NOT modify the core.
- Drop header files into
server/indicators/include/contrib/<name>/.
- The build system automatically picks them up.
- Include them via
#include "contrib/<name>/my_indicator.hpp".
4. Best Practices for Agents
- Always prefer Lazy Evaluation for strategy chains to minimize memory bandwidth.
- Use Eager Wrappers only when interfacing with legacy code or Python bindings that expect vectors.
- Check inputs: The library assumes valid numeric inputs (
std::vector<double>, etc.).
- NaN Handling: The first
period - 1 values of extensive indicators (SMA, etc.) are NaN. Always check std::isnan() if iterating manually.
5. Integration with QuanuX Organism
The Indicator Engine is designed as a Core Subsystem but is physically decoupled.
- Execution Nodes: Consume indicators natively in C++ via the factory pattern.
- Backtester: Links directly against
libquanux-indicators for zero-latency execution.
- Execution Nodes: Compile strategies that inline these indicator views.
6. Lifecycle Management (quanuxctl)
This module strictly adheres to the QuanuX Modular Protocol. It can be removed or replaced at any time.
- Install Suite:
quanuxctl module install indicators
- Pulls source, configures CMake, builds tests.
- Uninstall Suite:
quanuxctl module remove indicators
- Wipes
server/indicators directory clean.
- Updates
CMakeLists.txt to remove the subdirectory.
- Verify Integrity:
quanuxctl module check indicators
- Runs the
test_registry and unit tests.
- Runs the
test_registry and unit tests.
7. Python Bindings
Python bindings (pybind11 / cython) allow the indicators to be accessed from Python environments.
setup.py: Standard setuptools configuration.
src/python_bindings.cpp: pybind11 wrapper linking indicator pointers to Python signatures.
import quanux_indicators as qi
sma_values = qi.compute_sma(prices_list, 10)
mp = qi.DenseMarketProfile(100.0, 0.25)
for price in ticks:
mp.process(price)
count = mp.query(100.0)