How 0xemmkty/quantmuse works
Project type and purpose
• This is a full-stack, production-ready quantitative trading system.
• It combines a Python “data_service” layer (data fetching, factor analysis, AI/ML, storage, backtesting, strategies, dashboards, and web APIs) with a high-performance C++ core engine for order execution, risk management, and strategy execution.
File structure
• Top-level:
• backend/ (C++ core engine)
• data_service/ (Python service layer)
• static/ (HTML/CSS/JS front-end assets)
• scripts (main.py, run_*.py, examples/)
• The Python layer is organized into sub-packages: fetchers, ai, backtest, factors, ml, processors, realtime, storage, strategies, visualization, web, utils, vector_db, dashboard.
• The C++ backend follows a CMake project with includes (data_loader, strategy, order_executor, risk_manager) and src files.
Key insights from README
• Python layer exposes:
• Data ingestion (multi-source fetchers, real-time via WebSocket)
• Data processing & feature engineering
• Multi-factor models & backtesting
• AI/LLM integration (LangChain, GPT)
• Strategy framework (registry, runner, optimizer)
• Storage (SQLite/Postgres, Redis cache)
• Visualization (Plotly, Streamlit)
• Web API & dashboard (FastAPI)
• C++ layer: low-latency order execution, risk controls, portfolio management.
Main components & their relationships
a. Components:
1. Python Data Service
– Fetchers (Binance, Yahoo, Alpha)
– Realtime Module (WebSocket client)
– Data Processor & Feature Engineering
– Storage Layer (DB + Cache)
– AI/ML Module (LLM, NLP, sentiment)
– Factor Analysis & Backtesting Engine (Python)
– Strategy Framework (registry, runner, optimizer)
– Visualization & Dashboard (Plotly, Streamlit)
– Web API (FastAPI)
2. C++ Core Engine
– Data Loader
– Strategy Engine
– Order Executor
– Risk Manager
– Portfolio/Performance Components
3. External Services & Datastores
– Exchanges (Binance, Yahoo Finance, Alpha Vantage)
– OpenAI GPT API
– Databases: PostgreSQL/SQLite
– Redis (cache)
4. Presentation Layer
– Streamlit Dashboard
– FastAPI Web UI + static frontend (HTML/CSS/JS)
b. Interactions:
– Fetchers ← external exchanges
– Realtime WebSocket feeds → Realtime Module → Data Processor
– Processed data → Storage (DB/Redis)
– AI/ML & factor modules read from Storage
– Strategy Framework & Backtester orchestrate strategies using processed data
– For live trading, Python → C++ engine calls (via native binding or subprocess) for low-latency execution
– C++ engine emits execution results & risk alerts → Python Service
– Frontend UIs poll or subscribe (WebSocket or REST) to Python Service for data & metrics
– Admin/user issues commands via UI → Python Service → C++ engine
c. Architectural patterns
– Layered architecture (Python service layer vs C++ engine)
– Pipeline pattern for data ingestion → processing → storage
– Strategy pattern (pluggable strategies, registry)
– Observer/Publisher-Subscriber (real-time feeds, alerts)
– Micro-modules within Python (semi-microservices)
– CI/CD via CMake/carbon for C++ and setuptools/pytest for Python
d. Key technologies
– Python 3.8+, FastAPI, Streamlit, Plotly, LangChain, OpenAI API, pytest
– C++17, CMake, high-performance algorithms
– SQLite/PostgreSQL, Redis
– WebSocket for real-time market data
– Static JS/CSS front-end