Skip to content

Commit cbe4fe6

Browse files
committed
release: v0.2.0 — multi-broker execution, RL production system, microstructure features, portfolio optimizer, multi-LLM support
Major additions since v0.1.0: Broker abstraction - BrokerInterface ABC with unified models (UnifiedOrder, UnifiedBalance, etc.) - SmartOrderRouter: equities → Alpaca/IBKR fallback; futures → IBKR only - PreTradeRiskGate: 6 sequential checks before every order - KillSwitch: file-sentinel halt that survives restarts - FillTracker: thread-safe in-memory position/P&L with daily ledger - TCAEngine: Perold implementation shortfall with Almgren-Chriss market impact - AsyncExecutionLoop for non-blocking order processing - alpaca_mcp and ibkr_mcp: new FastMCP broker servers (11 tools each) RL production system - RLProductionConfig: versioned, env-driven (QUANTRL_ prefix) - Shadow mode on by default; PromotionGate validates before live deployment - OnlineAdapter: live trade → weight update with catastrophic forgetting guard - AlphaSelectionEnvironment + SizingEnvironment: production_mode guard + from_knowledge_store() factory methods replacing synthetic data - RLOrchestrator: accepts knowledge_store= for real data seeding Microstructure features - MicrostructureFeatureEngine: OFI, Kyle's Lambda, VPIN, Roll spread from ticks - OrderBookReconstructor from TradeTick + QuoteTick streams Portfolio optimization - MeanVarianceOptimizer: Ledoit-Wolf shrinkage, MAX_SHARPE/MIN_VARIANCE/ RISK_PARITY/MAX_DIVERSIFICATION, sector constraints, turnover penalty Multi-LLM provider support - 12 providers across 3 tiers (bedrock/anthropic/openai/vertex/gemini + azure/groq/together_ai/fireworks_ai/mistral + ollama/custom_openai) - LLM_FALLBACK_CHAIN for automatic failover - Per-tier overrides: LLM_MODEL_IC, LLM_MODEL_POD, LLM_MODEL_ASSISTANT QuantPod overhaul - api/, audit/, guardrails/, monitoring/ subsystems - DuckDB-backed Blackboard (replaces markdown; O(log n) SQL reads) - SkillTracker: IC and ICIR metrics alongside win-rate - llm_config.py, db.py, context.py (TradingContext DI container) - Alpha signals IC group: news_sentiment_ic, options_flow_ic, fundamentals_ic - portfolio_optimizer_agent, microstructure_signal_agent - IntraDayMonitorFlow, StrategyValidationFlow, DecoderCrew - mcp/models.py + mcp/allocation.py QuantArena enhancements - SimulationResult: Sharpe CI, Calmar, benchmark comparison (alpha/beta/IR), overfitting verdict, TCA report, walk-forward summary - HistoricalConfig: benchmark_symbol, max_portfolio_correlation, walk_forward_mode - SimBroker: daily loss limit enforced; Almgren-Chriss slippage on volumes; audit trail - CPCVEvaluator + OverfittingReport in research/walkforward.py - Extended Timeframe enum: M30, M15, M5, M1, S5 with tuned TimeframeParams Settings refactor - Nested AlpacaSettings, PolygonSettings, IBKRSettings (isolated env prefixes) - data_provider_priority field; data_end_date defaults to today Infrastructure - Dockerfile, docker-compose.yml, .github/workflows/ci.yml - scripts/scheduler.py (APScheduler daily session triggers) - .claude/ memory + skills committed - .env.example fully overhauled with all 12 LLM providers documented Docs - CHANGELOG.md: full 0.2.0 entry - docs/architecture/: quantcore, quant_pod, quant_arena updated - docs/guides/deployment.md: ibkr-mcp + quantpod-api services added
1 parent 5be9447 commit cbe4fe6

File tree

188 files changed

+40486
-1541
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+40486
-1541
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Agent Performance
2+
3+
> Last updated: 2026-03-15
4+
> Read at start of: /reflect, /meta
5+
> Update during: /reflect sessions
6+
7+
## IC Signal Quality
8+
9+
| IC | Regime | Accuracy (last 20) | Trend | Notes |
10+
|----|--------|-------------------|-------|-------|
11+
(minimum 10 trades before evaluating)
12+
13+
## Pod Compilation Quality
14+
15+
| Pod | Value Add | Notes |
16+
|-----|-----------|-------|
17+
(assessed during /reflect)
18+
19+
## Known Biases
20+
21+
(populated by /reflect when patterns emerge)

.claude/memory/regime_history.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Regime History
2+
3+
> Last updated: 2026-03-15
4+
> Read at start of: /trade, /meta, /workshop, /reflect
5+
> Update when: regime change detected in any session
6+
7+
## Current Regime
8+
9+
(populated after first get_regime or run_analysis call)
10+
11+
## Transition Log
12+
13+
| Date | Symbol | From | To | Confidence | Impact on Active Strategies |
14+
|------|--------|------|----|------------|----------------------------|
15+
(empty)
16+
17+
## Regime Duration Stats
18+
19+
(populated by /reflect after enough transitions)

.claude/memory/session_handoffs.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Session Handoffs
2+
3+
> Cross-session context + self-modification log
4+
> Read at start of: every session
5+
> Update: when context transfers needed, when any config/skill file modified
6+
7+
## Handoff Log
8+
9+
| Date | From Session | To Session | Key Context |
10+
|------|-------------|------------|-------------|
11+
(empty)
12+
13+
## Self-Modification Log
14+
15+
| Date | File Changed | What Changed | Why | Evidence |
16+
|------|-------------|-------------|-----|----------|
17+
| 2026-03-15 | (initial creation) | All config/memory/skill files | Phase 1 post-config setup | First-time system initialization |
18+
| 2026-03-15 | packages/quant_pod/mcp/server.py | Added IC output cache (_ic_output_cache, _ic_cache_set, _ic_cache_get, _populate_ic_cache_from_result) + 7 new MCP tools (list_ics, run_ic, run_pod, run_crew_subset, get_last_ic_output, get_fill_quality, get_position_monitor) | Enhancement 1 (Granular IC Access) + Enhancement 5 (Execution Feedback Loop) | 19 tests passing |
19+
| 2026-03-15 | .claude/skills/deep_analysis.md | Created new reference skill for QuantCore tool usage | Enhancement 2 (QuantCore integration) | New file, covers pre-trade/signal/risk enrichment categories |
20+
| 2026-03-15 | .claude/skills/trade.md | Added Steps 3.5 (targeted pre-screen), 4a (pre-trade intelligence), 4b (signal enrichment), 4c (risk enrichment) | Enhancements 2+3 (QuantCore integration + chained analysis) | Skills-based conditional logic chosen over MCP chain tool |
21+
| 2026-03-15 | .claude/skills/meta.md | Added Step 5a (cross-strategy correlation check) | Enhancement 2 (QuantCore integration for portfolio-level analysis) | Between multi-symbol analysis and conflict resolution |
22+
| 2026-03-15 | .claude/skills/review.md | Added Step 2a (position monitor via get_position_monitor), Step 9 (fill quality audit) | Enhancement 5 (execution feedback loop) | Weekly fill audit covers last 20 fills |
23+
| 2026-03-15 | scripts/scheduler.py | Created APScheduler-based session scheduler daemon | Enhancement 4 (scheduled session triggers) | 4 jobs: 9:15/12:30/15:45 Mon-Fri + 17:00 Fri; --dry-run/--cron/--run-now CLI flags |
24+
| 2026-03-15 | pyproject.toml | Added scheduler optional dependency (apscheduler>=3.10.0) | Enhancement 4 support | Optional install, not required by core system |
25+
| 2026-03-15 | CLAUDE.md | Added E1 (Granular IC Access) and E5 (Execution Feedback Loop) tool tables; added deep_analysis.md reference; added Automated Session Triggers table | Documentation for all 5 enhancements | Final CLAUDE.md reflects full Phase 1-6 tool inventory |
26+
| 2026-03-15 | tests/quant_pod/test_ic_access.py | Created 19 tests for E1+E5 enhancements | Test coverage for new MCP tools | All 19 passing; parameter order fix applied to get_last_ic_output |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Strategy Registry
2+
3+
> Last updated: 2026-03-15
4+
> Read at start of: /workshop, /decode, /meta, /trade, /reflect
5+
> Update after: /workshop, /decode, /reflect
6+
7+
## Active Strategies
8+
9+
| ID | Name | Type | Regime Fit | Status | Sharpe | Max DD | Source | Last Validated |
10+
|----|------|------|-----------|--------|--------|--------|--------|----------------|
11+
(empty — populated starting Phase 2)
12+
13+
## Retired Strategies
14+
15+
| ID | Name | Retired Date | Reason |
16+
|----|------|-------------|--------|
17+
(none yet)
18+
19+
## Notes
20+
21+
- Strategies must pass backtest + walk-forward before "forward_testing"
22+
- Minimum 3 weeks forward testing before promotion to "live"
23+
- Record retirement reasons — learning data for /reflect

.claude/memory/trade_journal.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Trade Journal
2+
3+
> Last updated: 2026-03-15
4+
> Read at start of: /trade, /review, /reflect
5+
> Update after: /trade, /meta
6+
7+
## Entry Format
8+
9+
- Date:
10+
- Symbol:
11+
- Direction:
12+
- Strategy ID:
13+
- Regime at entry:
14+
- DailyBrief confidence:
15+
- IC dissent notes:
16+
- Reasoning:
17+
- Entry price:
18+
- Exit price:
19+
- P&L:
20+
- Outcome notes:
21+
22+
## Recent Trades
23+
24+
(empty — populated starting Phase 3)
25+
26+
## Weekly Summaries
27+
28+
(generated during /reflect sessions)
29+
30+
## Recurring Patterns
31+
32+
(updated by /reflect — what keeps working, what keeps failing)

.claude/memory/workshop_lessons.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Workshop Lessons
2+
3+
> Accumulated R&D learnings — your research memory
4+
> Read at START of every /workshop session
5+
> Update after: /workshop, /reflect
6+
7+
## Backtesting Pitfalls
8+
9+
(e.g., "RSI strategies overfit with < 60 trades in sample")
10+
11+
## What Works in Each Regime
12+
13+
| Regime | Tends to Work | Tends to Fail | Confidence |
14+
|--------|--------------|---------------|------------|
15+
(accumulated from backtest and live results)
16+
17+
## Parameter Sensitivity
18+
19+
(e.g., "ATR multiplier > 2.5 degrades Sharpe in high vol")
20+
21+
## Failed Hypotheses (don't repeat these)
22+
23+
| Date | Hypothesis | Why It Failed | Regime | Takeaway |
24+
|------|-----------|---------------|--------|----------|
25+
(prevents wasting time retesting dead ends)

.claude/settings.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"mcpServers": {
3+
"quantpod": {
4+
"command": "quantpod-mcp",
5+
"type": "stdio"
6+
},
7+
"quantcore": {
8+
"command": "quantcore-mcp",
9+
"type": "stdio"
10+
}
11+
},
12+
"hooks": {
13+
"PostToolUse": [
14+
{
15+
"matcher": "run_analysis",
16+
"hooks": [
17+
{
18+
"type": "command",
19+
"command": "python3 scripts/validate_brief_quality.py",
20+
"timeout": 10
21+
}
22+
]
23+
},
24+
{
25+
"matcher": "execute_trade",
26+
"hooks": [
27+
{
28+
"type": "command",
29+
"command": "python3 scripts/log_decision.py",
30+
"timeout": 10
31+
},
32+
{
33+
"type": "command",
34+
"command": "python3 scripts/notify_discord.py",
35+
"timeout": 15
36+
}
37+
]
38+
}
39+
]
40+
}
41+
}

.claude/skills/decode.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
name: decode
3+
description: Reverse-engineer trading strategies from external signal history. Decode, formalize, backtest, and register.
4+
user_invocable: true
5+
---
6+
7+
# /decode — Strategy Decoder Session
8+
9+
## Purpose
10+
11+
Reverse-engineer a trading strategy from raw trade signals. Turn someone
12+
else's track record into a systematic, backtestable strategy definition.
13+
14+
## Workflow
15+
16+
### Step 0: Read Context
17+
- Read `.claude/memory/strategy_registry.md` — avoid decoding what we already have
18+
- Read `.claude/memory/workshop_lessons.md` — known pitfalls apply here too
19+
20+
### Step 1: Ingest Raw Signals
21+
Accept signals from one of:
22+
- **Manual paste:** user provides a list of trades
23+
- **File upload:** CSV/JSON with trade history
24+
- **`decode_from_trades`:** analyze our own closed_trades or fills
25+
26+
Each signal must have: `symbol`, `direction`, `entry_time`, `entry_price`,
27+
`exit_time`, `exit_price`. Optional: `size`, `notes`.
28+
29+
### Step 2: Clean and Normalize
30+
- Validate required fields are present
31+
- Parse timestamps (supports multiple formats)
32+
- Flag and report missing/invalid data
33+
- Minimum 20 signals recommended; warn if fewer
34+
35+
### Step 3: Decode via MCP
36+
Call `decode_strategy(signals, source_name)`.
37+
38+
Review the output:
39+
- **entry_trigger**: What timing and conditions drive entries?
40+
- **exit_trigger**: Time-based or target-based exits?
41+
- **timing_pattern**: Morning, midday, afternoon, or all-day?
42+
- **style**: Scalper, intraday, swing, or position?
43+
- **regime_affinity**: Which regimes favor this strategy?
44+
- **edge_hypothesis**: The one-sentence thesis
45+
46+
### Step 4: Evaluate the Decoded Strategy
47+
Ask yourself:
48+
- Does the edge hypothesis make sense from a market microstructure perspective?
49+
- Is the timing pattern exploitable systematically (or just coincidence)?
50+
- Is the win rate sustainable, or is it likely overstated by survivorship bias?
51+
- Is the sample size sufficient (>50 signals ideal)?
52+
53+
### Step 5: Formalize into StrategyDefinition
54+
Translate the decoded patterns into formal entry/exit rules:
55+
```json
56+
{
57+
"entry_rules": [
58+
{"indicator": "<indicator from decoded entry_trigger>",
59+
"condition": "<condition>", "value": <threshold>, "direction": "long"}
60+
],
61+
"exit_rules": [
62+
{"indicator": "<exit trigger indicator>",
63+
"condition": "<condition>", "value": <threshold>}
64+
],
65+
"parameters": {"<relevant indicator params>": <values>},
66+
"risk_params": {"stop_loss_atr": 2.0, "position_pct": 0.03}
67+
}
68+
```
69+
Set conservative risk params initially — decoded strategies have
70+
higher uncertainty than workshop strategies.
71+
72+
### Step 6: Register
73+
Call `register_strategy` with `source="decoded"`, `status="draft"`.
74+
75+
### Step 7: Backtest
76+
Call `run_backtest(strategy_id, symbol)`.
77+
Apply the same criteria as /workshop:
78+
- Sharpe > 1.0?
79+
- Max drawdown < 15%?
80+
- Total trades > 50?
81+
82+
### Step 8: Validate or Reject
83+
If backtest passes → `run_walkforward` → if passes:
84+
`update_strategy(status="forward_testing")`
85+
If fails → `update_strategy(status="failed")`
86+
87+
### Step 9: Update Memory
88+
- `.claude/memory/strategy_registry.md` — add decoded strategy
89+
- `.claude/memory/workshop_lessons.md` — new patterns discovered
90+
- `.claude/memory/session_handoffs.md` — notify /meta and /trade
91+
92+
## Notes
93+
- Decoded strategies should be treated with MORE skepticism than workshop
94+
strategies. The original trader may have had information we don't have.
95+
- Always check: is the edge in the timing, the signal, or the risk management?
96+
Timing edges are hardest to systematize.
97+
- Sample size matters enormously. 20 trades is the absolute minimum.
98+
50+ is preferred. 100+ is high confidence.

0 commit comments

Comments
 (0)