POST /ch/api/order accepts {api_key, member_id, symbol, side, quantity, price}
for programmatic order placement by external services like Soci agents.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per-member AI model switching: right-click Type badge to change LLM/NN1/NN2
Replace global strategy system with per-member assignment map.
Default: USR01-04 LLM, USR05-07 NN1, USR08-10 NN2.
Right-click any member's Type badge in the leaderboard to change
their individual AI model. Human members (logged in) show Human
badge and skip the context menu.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add runtime NN model switching: LLM, NN1 (Adilbai), NN2 (RayMelius)
Support dual NN model slots in ch_rl_trader with lazy loading per slot.
Six strategies: hybrid (USR01-04 LLM, USR05-07 NN1, USR08-10 NN2),
hybrid-nn1, hybrid-nn2, nn1, nn2, llm. Right-click context menu and
badges updated for NN1/NN2 distinction.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add real ATHEX/NYSE/Euronext prices, OHLCV data for RL agent, merge shared_data into shared/data
- Type column shows NN (green) or LLM (purple) per member instead of generic AI
- AI decision history badges: RL source shown as NN
- Right-click leaderboard table opens context menu to switch strategy
(hybrid/rl/llm) at runtime via POST /ch/api/strategy
- Current strategy highlighted with checkmark in context menu
- Leaderboard auto-refreshes after strategy switch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Integrate Adilbai/stock-trading-rl-agent PPO model as alternative CH
trading strategy (new ch_rl_trader.py)
- CH_AI_STRATEGY: llm/rl/hybrid (default hybrid, dynamically switchable
via POST /ch/api/strategy)
- MDF now uses regime-driven price dynamics (trending/mean-reverting/
volatile/calm) producing meaningful SMA, EMA, MACD, RSI, Bollinger
Band signals embedded in snapshots
- Rename source CLEARINGHOUSE → CLRH in order messages
- Add stable-baselines3, pandas, scikit-learn, huggingface_hub to Docker
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix MDF order book depth and CH AI reference price fallback
MDF now places 3 levels of resting bids and asks per symbol each cycle,
ensuring order books always have liquidity. CH AI trader falls back to
securities.txt reference prices when books are empty. CH daily obligation
raised to 20.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use Groq on HF Spaces, prefer fine-tuned Ollama model locally
- Notebook: merge LoRA adapter into base model on CPU and push complete
weights so stockex-ch-trader works via HF Inference Router API
- CH AI Trader: revert default HF_MODEL to RayMelius/stockex-ch-trader
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix CH AI trader: use real LLM model and balance BUY/SELL fallback
- Default HF model changed from LoRA adapter (stockex-ch-trader, not
servable via HF Router API) to Qwen/Qwen2.5-7B-Instruct
- New env var CH_HF_MODEL for CH-specific model override
- Rebalanced fallback logic: SELL weight increases as holdings grow
(was always BUY when holdings < 30% of net worth)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add AI reasoning history to CH member detail panel
- New ch_ai_decisions table stores LLM responses and parsed orders
- AI trader logs every decision: LLM response, fallback, invalid parse
- Member detail API returns last 10 AI decisions
- Detail panel shows AI Reasoning section with:
- LLM/Fallback/Invalid badges
- Parsed order (side, qty, symbol, price)
- Raw LLM response in scrollable monospace box
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Click any row on /ch/ to see a slide-out panel with:
- Capital, holdings value, total value, P&L stats
- Full holdings table with current prices and unrealized P&L
- Last 20 trades with time, symbol, side, qty, price, value
- New API endpoint: GET /ch/api/member/<member_id>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix CH portfolio: increase reload delay and enable auto-refresh
- Increase post-order reload from 1.5s to 4s to allow Kafka round-trip
(order → matcher → trade → CH consumer → DB) to complete
- Fix auto-refresh: was fetching data but not updating the page;
now reloads every 10s so trades are reflected promptly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix AI Analyst duplicate output and CH trade attribution
- Dashboard: remove direct SSE broadcast from _generate_and_broadcast(),
let Kafka consumer handle it (was causing every insight to appear twice)
- CH trade consumer: match matcher's field names (buy_id/sell_id) instead
of buy_order_id/sell_order_id, so trades are actually attributed to members
- Notebook: support both Kaggle (dataset) and Colab (Drive) checkpoints,
set SAVE_STEPS=10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix HF 410: always use router.huggingface.co for all models
api-inference.huggingface.co is deprecated (HTTP 410).
All three services (ai_analyst, ch_ai_trader, dashboard) now
route every model through router.huggingface.co.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add CH trader fine-tuning notebook and update default model
- notebooks/ch_trader_finetune.ipynb: QLoRA fine-tunes Qwen2.5-7B-Instruct
on 2500 synthetic clearing house trading scenarios (Colab A100-ready)
- Generates diverse examples: varied capital, holdings, obligation levels
- Trains with SFTTrainer + chat template formatting, merges and pushes
the model to RayMelius/stockex-ch-trader on HuggingFace Hub
- ch_ai_trader.py + docker-compose: default HF_MODEL updated to
RayMelius/stockex-ch-trader (override via HF_MODEL env var)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use RayMelius/stockex-analyst as default LLM for CH AI trader
Matches the model already used by the AI Analyst service.
A CH-specific fine-tuned model can replace it later via HF_MODEL env var.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add navigation links between Dashboard and Clearing House
- Dashboard header: green "Clearing House" button linking to /ch/
- Clearing House nav: "← Main Dashboard" link back to /
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add clearing house simulation with 10 members (USR01-USR10)
- New clearing_house/ Flask service (port 5004) with dedicated dark-themed portal
- SQLite persistence: member capital, holdings, daily trade counters, settlements
- Members start with €100,000; must trade ≥10 securities per trading day
- Password = member ID (e.g. USR01 logs in with password USR01)
- Real users log in to trade manually; AI (LLM via Groq→HF→Ollama) simulates unoccupied members
- Trade attribution via Kafka trades consumer — detects USRxx- cl_ord_id prefix
- EOD settlement triggered by dashboard session end; calculates unrealized P&L
- Leaderboard at /ch/ with real-time auto-refresh and Human/AI badges
- Member portfolio view: holdings, order entry, trade history, settlement history
- Integrated into nginx (/ch/), entrypoint.sh, docker-compose, and HF Dockerfile
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>