AI-Powered Quantitative Crypto Trading Engine — 18 RAG Types, 10 Autonomous Agents, Evidence-First Signal Engine, Self-Learning Risk Management. Built on Freqtrade.
9
stars
140
commits
Python
primary language
May 31, 2026
updated
A cognitive trading organism for cryptocurrency markets.
HydraQuant trades crypto the way a brain does: by remembering, debating, and learning from every signal it sees. Under the hood it combines a rule-based signal engine, a multi-agent LLM debate, brain-inspired adaptive learning, and Bayesian position sizing into a single closed loop. It is built on top of the freqtrade execution framework, which handles exchange integration, candle streaming, and order persistence.
Unlike classical ML trading pipelines that retrain on a schedule and forget between runs, HydraQuant learns continuously. Every closed trade mutates an adaptive parameter organism: learning rates, risk thresholds, exit multipliers, and agent-selection weights all evolve based on outcomes.
The system runs entirely on free-tier LLM providers and free data sources. It is designed for Bybit and Binance testnet first, with a graduated autonomy ladder that scales position sizing only after sustained performance.
HydraQuant is organized in six layers:
A trading decision flows through the following stages:
populate_entry_trend callback.
The Evidence Engine is the core signal generator. It is rule-based and LLM-free, which makes it fast and deterministic.
It decomposes every trading decision into six sub-questions:
Each sub-question is scored independently, weights are regime-adaptive, and disagreement between sub-scores makes the final synthesis cautious rather than neutral. Sub-questions with missing data abstain explicitly; their weight is redistributed across the remaining sub-questions rather than defaulting to a neutral value that would pollute downstream statistics.
When Evidence Engine confidence is insufficient, HydraQuant convenes a multi-agent debate.
Twelve specialist agents are registered: TrendFollower, MeanReverter, MomentumRider, FundingContrarian, RiskMinimizer, DevilsAdvocate, EvidenceValidator, MacroCorrelator, TemporalAnalyst, ExploiterAgent, DefenderAgent, ReflectionAgent. Four to seven are selected per debate based on the current market regime (trending bull, trending bear, ranging, high-volatility, transitional).
The debate runs in three rounds:
Every debate is persisted: agent arguments go to the agent_memory table, quality scores go to argument_quality, and the full causal structure is written to the Grafeo graph. The argument-quality scores feed back into agent selection via a RLAIF loop.
Parameters that would be hardcoded constants in a traditional system — learning rates, risk thresholds, exit multipliers, weight coefficients — are represented in HydraQuant as neurons. Each neuron holds a Beta posterior, is sampled via Thompson draw when its value is needed, and is updated via BCM metaplasticity and STDP temporal credit when outcomes arrive.
Around these neurons the organism has seventeen biologically-inspired subsystems:
Coordination between modules is stigmergic. Instead of passing messages through locks, modules deposit signals into a shared pheromone field with leaky-integrate dynamics. Every reader sees a continuously decaying summary of recent activity, and no one blocks anyone.
HydraQuant runs entirely on free-tier LLM providers. Seven providers are supported — Gemini, Groq, Cerebras, DeepSeek, SambaNova, Mistral, and OpenRouter — with model slot expansion over multiple API keys.
The router uses Thompson sampling for exploration (a Beta posterior over success rate per slot) and a LinUCB contextual bandit for exploitation once a slot has accumulated enough samples. The context vector captures task type, prompt length, JSON requirement, market regime, and hour of day.
A circuit breaker on the Gemini path prevents cascade failures: ten failures within a sixty-second window opens the breaker for thirty seconds, and three consecutive successes close it again.
When a trade closes, the router walks back through every LLM call that fired during the trade's lifetime and applies a small retroactive reward to each contributing slot's LinUCB posterior. This closes the loop between LLM quality and realized PnL.
Position sizing uses a nine-stage pipeline: Beta posterior, Peters volatility drag, volatility-of-volatility shrinkage, Baker-McHale small-sample correction, trade-graduation scaling, effective-number-of-bets diversification, blended multiplier from CAAT / DualAxis / cerebellum / lifecycle, Constitution clamp, equal-risk cap, minimum-stake guard.
Graduated autonomy runs from L0 (nano-live trading at 3% Kelly fraction) up to L5 (75% Kelly fraction). Promotion requires sustained trade count, Sharpe ratio, maximum drawdown bound, and minimum time at each level.
A shadow Kelly ledger runs in parallel with the real ledger. Every decision that was considered but not executed — through confidence shortfall, minimum-stake guard, or Constitution block — is recorded. The shadow ledger calibrates thresholds (the Forgone Alpha Harvester auto-loosens per-pair thresholds when the foregone PnL is consistently positive) without contaminating live sizing.
Exits are confidence-adaptive Chandelier ATR trailing stops. High-confidence signals use tighter multipliers, low-confidence signals use wider ones. Hurst exponent scales the multiplier further in strongly trending markets. The Constitution enforces hard stops on drawdown, leverage, position concentration, and consecutive-loss streaks.
git clone https://github.com/ymcbzrgn/HydraQuant.git hydraquant
cd hydraquant
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -r requirements/requirements-phase27.txt
python user_data/scripts/download_models.py
Copy an example config and edit with your exchange and LLM API keys:
cp config_bybit_testnet_futures.json config.json
# Edit config.json with your API keys and pair whitelist
Environment variables live in .env:
GEMINI_API_KEY_1=...
GROQ_API_KEY=...
CEREBRAS_API_KEY=...
TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...
BYBIT_API_KEY=...
BYBIT_SECRET=...
HydraQuant runs as five processes:
python user_data/scripts/model_server.py & # embedding and reranker models
python user_data/scripts/rag_graph.py & # RAG orchestrator and MADAM
python user_data/scripts/api_ai.py & # FastAPI read surface
python user_data/scripts/scheduler.py & # periodic jobs
freqtrade trade --strategy HydraSizer --config config.json
Or using Docker Compose:
docker compose -f docker/docker-compose.ai.yml up -d
On a systemd-managed host, install the provided unit:
sudo cp docker/hydraquant.service.watchdog /etc/systemd/system/hydraquant.service
sudo systemctl daemon-reload
sudo systemctl enable --now hydraquant
user_data/scripts/ HydraQuant AI modules (Evidence Engine, MADAM, Organism, ...)
user_data/strategies/ HydraSizer strategy — the bridge to freqtrade
user_data/db/ SQLite (ai_data), LanceDB vector store, Grafeo graph store
tests/ Test suite
docs/ Architecture, design, and phase documents
frequi/ Vue 3 web dashboard (FreqUI fork with HydraQuant views)
docker/ Dockerfile.ai, docker-compose.ai.yml, systemd units
freqtrade/ Vendored freqtrade execution framework (GPL v3)
| Document | Scope |
|---|---|
| Architecture | Full technical architecture and signal flow |
| Neural Organism | Brain subsystems, BCM, STDP, hormones |
| Evidence Engine | Six sub-questions, regime weights, synthesis |
| LLM Routing | Thompson sampling, LinUCB, circuit breaker |
| Features | Full feature catalog with status markers |
| Deployment | Production setup, systemd, health dashboard |
| Roadmap | Phase 29 current sprint and forward plan |
| Changelog | Phase-by-phase release history |
PYTHONPATH=user_data/scripts python -m pytest tests/test_ai_scripts.py -v
A dedicated health-check script verifies system state after deploys:
python user_data/scripts/deploy_health_check.py
HydraQuant is in testnet alpha, actively shipping Phase 29: Sensory Expansion & Self-Falsification. The current PnL on live testnet is not yet positive — which is the reason Phase 29 exists. The fixes under way:
The graduated autonomy ladder (L0 → L5) is designed for exactly this stage. L0 trades at a 3% Kelly fraction while the organism learns its priors. Each promotion is gated on sustained Sharpe, maximum-drawdown bounds, and minimum time at level. No shortcut exists.
This is a research platform with live trading loops — not a finished product. Everything is open source, every phase is documented, every metric is honest. The public roadmap lives in docs/ROADMAP.md; what has shipped lives in docs/CHANGELOG.md.
See CONTRIBUTING.md for development setup, testing requirements, and code style.
HydraQuant is licensed under the GNU General Public License v3.0. This matches the license of the underlying freqtrade execution framework.
HydraQuant delegates exchange integration, order management, and candle streaming to freqtrade (GPL v3). Everything above that layer — the cognitive pipeline, the organism, the routing, the sizing, the risk engine — is HydraQuant's own work.
140 commits
Python
91.8%
Vue
4.3%
TypeScript
2.7%
AI-Powered Quantitative Crypto Trading Engine — 18 RAG Types, 10 Autonomous Agents, Evidence-First Signal Engine, Self-Learning Risk Management. Built on Freqtrade.
9
stars
140
commits
Python
primary language
May 31, 2026
updated
A cognitive trading organism for cryptocurrency markets.
HydraQuant trades crypto the way a brain does: by remembering, debating, and learning from every signal it sees. Under the hood it combines a rule-based signal engine, a multi-agent LLM debate, brain-inspired adaptive learning, and Bayesian position sizing into a single closed loop. It is built on top of the freqtrade execution framework, which handles exchange integration, candle streaming, and order persistence.
Unlike classical ML trading pipelines that retrain on a schedule and forget between runs, HydraQuant learns continuously. Every closed trade mutates an adaptive parameter organism: learning rates, risk thresholds, exit multipliers, and agent-selection weights all evolve based on outcomes.
The system runs entirely on free-tier LLM providers and free data sources. It is designed for Bybit and Binance testnet first, with a graduated autonomy ladder that scales position sizing only after sustained performance.
HydraQuant is organized in six layers:
A trading decision flows through the following stages:
populate_entry_trend callback.
The Evidence Engine is the core signal generator. It is rule-based and LLM-free, which makes it fast and deterministic.
It decomposes every trading decision into six sub-questions:
Each sub-question is scored independently, weights are regime-adaptive, and disagreement between sub-scores makes the final synthesis cautious rather than neutral. Sub-questions with missing data abstain explicitly; their weight is redistributed across the remaining sub-questions rather than defaulting to a neutral value that would pollute downstream statistics.
When Evidence Engine confidence is insufficient, HydraQuant convenes a multi-agent debate.
Twelve specialist agents are registered: TrendFollower, MeanReverter, MomentumRider, FundingContrarian, RiskMinimizer, DevilsAdvocate, EvidenceValidator, MacroCorrelator, TemporalAnalyst, ExploiterAgent, DefenderAgent, ReflectionAgent. Four to seven are selected per debate based on the current market regime (trending bull, trending bear, ranging, high-volatility, transitional).
The debate runs in three rounds:
Every debate is persisted: agent arguments go to the agent_memory table, quality scores go to argument_quality, and the full causal structure is written to the Grafeo graph. The argument-quality scores feed back into agent selection via a RLAIF loop.
Parameters that would be hardcoded constants in a traditional system — learning rates, risk thresholds, exit multipliers, weight coefficients — are represented in HydraQuant as neurons. Each neuron holds a Beta posterior, is sampled via Thompson draw when its value is needed, and is updated via BCM metaplasticity and STDP temporal credit when outcomes arrive.
Around these neurons the organism has seventeen biologically-inspired subsystems:
Coordination between modules is stigmergic. Instead of passing messages through locks, modules deposit signals into a shared pheromone field with leaky-integrate dynamics. Every reader sees a continuously decaying summary of recent activity, and no one blocks anyone.
HydraQuant runs entirely on free-tier LLM providers. Seven providers are supported — Gemini, Groq, Cerebras, DeepSeek, SambaNova, Mistral, and OpenRouter — with model slot expansion over multiple API keys.
The router uses Thompson sampling for exploration (a Beta posterior over success rate per slot) and a LinUCB contextual bandit for exploitation once a slot has accumulated enough samples. The context vector captures task type, prompt length, JSON requirement, market regime, and hour of day.
A circuit breaker on the Gemini path prevents cascade failures: ten failures within a sixty-second window opens the breaker for thirty seconds, and three consecutive successes close it again.
When a trade closes, the router walks back through every LLM call that fired during the trade's lifetime and applies a small retroactive reward to each contributing slot's LinUCB posterior. This closes the loop between LLM quality and realized PnL.
Position sizing uses a nine-stage pipeline: Beta posterior, Peters volatility drag, volatility-of-volatility shrinkage, Baker-McHale small-sample correction, trade-graduation scaling, effective-number-of-bets diversification, blended multiplier from CAAT / DualAxis / cerebellum / lifecycle, Constitution clamp, equal-risk cap, minimum-stake guard.
Graduated autonomy runs from L0 (nano-live trading at 3% Kelly fraction) up to L5 (75% Kelly fraction). Promotion requires sustained trade count, Sharpe ratio, maximum drawdown bound, and minimum time at each level.
A shadow Kelly ledger runs in parallel with the real ledger. Every decision that was considered but not executed — through confidence shortfall, minimum-stake guard, or Constitution block — is recorded. The shadow ledger calibrates thresholds (the Forgone Alpha Harvester auto-loosens per-pair thresholds when the foregone PnL is consistently positive) without contaminating live sizing.
Exits are confidence-adaptive Chandelier ATR trailing stops. High-confidence signals use tighter multipliers, low-confidence signals use wider ones. Hurst exponent scales the multiplier further in strongly trending markets. The Constitution enforces hard stops on drawdown, leverage, position concentration, and consecutive-loss streaks.
git clone https://github.com/ymcbzrgn/HydraQuant.git hydraquant
cd hydraquant
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install -r requirements/requirements-phase27.txt
python user_data/scripts/download_models.py
Copy an example config and edit with your exchange and LLM API keys:
cp config_bybit_testnet_futures.json config.json
# Edit config.json with your API keys and pair whitelist
Environment variables live in .env:
GEMINI_API_KEY_1=...
GROQ_API_KEY=...
CEREBRAS_API_KEY=...
TELEGRAM_BOT_TOKEN=...
TELEGRAM_CHAT_ID=...
BYBIT_API_KEY=...
BYBIT_SECRET=...
HydraQuant runs as five processes:
python user_data/scripts/model_server.py & # embedding and reranker models
python user_data/scripts/rag_graph.py & # RAG orchestrator and MADAM
python user_data/scripts/api_ai.py & # FastAPI read surface
python user_data/scripts/scheduler.py & # periodic jobs
freqtrade trade --strategy HydraSizer --config config.json
Or using Docker Compose:
docker compose -f docker/docker-compose.ai.yml up -d
On a systemd-managed host, install the provided unit:
sudo cp docker/hydraquant.service.watchdog /etc/systemd/system/hydraquant.service
sudo systemctl daemon-reload
sudo systemctl enable --now hydraquant
user_data/scripts/ HydraQuant AI modules (Evidence Engine, MADAM, Organism, ...)
user_data/strategies/ HydraSizer strategy — the bridge to freqtrade
user_data/db/ SQLite (ai_data), LanceDB vector store, Grafeo graph store
tests/ Test suite
docs/ Architecture, design, and phase documents
frequi/ Vue 3 web dashboard (FreqUI fork with HydraQuant views)
docker/ Dockerfile.ai, docker-compose.ai.yml, systemd units
freqtrade/ Vendored freqtrade execution framework (GPL v3)
| Document | Scope |
|---|---|
| Architecture | Full technical architecture and signal flow |
| Neural Organism | Brain subsystems, BCM, STDP, hormones |
| Evidence Engine | Six sub-questions, regime weights, synthesis |
| LLM Routing | Thompson sampling, LinUCB, circuit breaker |
| Features | Full feature catalog with status markers |
| Deployment | Production setup, systemd, health dashboard |
| Roadmap | Phase 29 current sprint and forward plan |
| Changelog | Phase-by-phase release history |
PYTHONPATH=user_data/scripts python -m pytest tests/test_ai_scripts.py -v
A dedicated health-check script verifies system state after deploys:
python user_data/scripts/deploy_health_check.py
HydraQuant is in testnet alpha, actively shipping Phase 29: Sensory Expansion & Self-Falsification. The current PnL on live testnet is not yet positive — which is the reason Phase 29 exists. The fixes under way:
The graduated autonomy ladder (L0 → L5) is designed for exactly this stage. L0 trades at a 3% Kelly fraction while the organism learns its priors. Each promotion is gated on sustained Sharpe, maximum-drawdown bounds, and minimum time at level. No shortcut exists.
This is a research platform with live trading loops — not a finished product. Everything is open source, every phase is documented, every metric is honest. The public roadmap lives in docs/ROADMAP.md; what has shipped lives in docs/CHANGELOG.md.
See CONTRIBUTING.md for development setup, testing requirements, and code style.
HydraQuant is licensed under the GNU General Public License v3.0. This matches the license of the underlying freqtrade execution framework.
HydraQuant delegates exchange integration, order management, and candle streaming to freqtrade (GPL v3). Everything above that layer — the cognitive pipeline, the organism, the routing, the sizing, the risk engine — is HydraQuant's own work.
140 commits
Python
91.8%
Vue
4.3%
TypeScript
2.7%