Manage Quanux Statistics
by quantDIY
Guide for developing and operating the QuanuX Statistics & Research Node.
Skill Details
Repository Files
6 files in this skill directory
name: manage-quanux-statistics description: Guide for developing and operating the QuanuX Statistics & Research Node.
QuanuX Statistics Node
The QuanuX Statistics Node (quanux_stats) is a purpose-built service for real-time market analysis and signal generation. It bridges the gap between raw market data and high-level strategy logic by providing pre-calculated metrics.
Capabilities
-
Online Statistics:
- Uses Welford's Algorithm to track Variance and Standard Deviation with $O(1)$ complexity/storage per tick.
- Tracks Z-scores relative to a rolling window (default 100 ticks).
- Calculates Pairwise Correlation matrices in real-time.
-
Data Persistence:
- Ingests
MARKET.*data from NATS (JSON format). - Writes to DuckDB (
market_stats.duckdb) for offline research and backtesting. - Future: Will support Parquet export for S3 archival.
- Ingests
-
Signal Publishing:
- Publishes derived metrics to
STATS.<SYMBOL>on NATS. - Format:
{"symbol": "ES", "volatility": 12.5, "z_score": 1.2, ...}
- Publishes derived metrics to
Architecture
- Language: C++20
- Core:
StatsEngineclass. - Storage:
stats_map_(Red-Black Tree) for per-symbol state. - Concurrency: Single-threaded NATS consumer (for now) protected by
std::mutexfor future expansion.
Development Guide
Adding a New Metric
- Update
InstrumentStatsininclude/stats_engine.h: Add a new accumulator (e.g.,double sum_log_return). - Update
update()insrc/stats_engine.cpp: Implement the online update formula. - Publish:
Add the new field to the
json derivedobject in the NATS callback.
Running Locally
# Build
cd QuanuX-Statistics/cpp/build
make quanux_stats
# Run (Ensure NATS is up)
./quanux_stats
Dependencies
- DuckDB: Embedded DB for storage.
- NATS C Client: High-performance messaging.
- Eigen: Linear algebra (Matrix operations).
- nlohmann/json: Serialization.
Related Skills
Attack Tree Construction
Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.
Grafana Dashboards
Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.
Matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
Scientific Visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Seaborn
Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.
Shap
Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Query Writing
For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Scientific Visualization
Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.
