Skip to content

Commit 34a1e2b

Browse files
samuelvinay91claude
andcommitted
feat: quantitative learning engine — AI learns from its own trade numbers
New module: skopaq/learning/tracker.py - Signal accuracy tracking per symbol (win rate, avg P&L) - Confidence calibration (AI overconfident/underconfident detection) - Sector performance breakdown (IT, banking, energy, etc.) - Regime performance (high/low VIX, trending/ranging) - Time-of-day entry patterns (best hours for trades) - Stop-loss effectiveness analysis (too tight? too loose?) - Holding period optimization per symbol - generate_learning_insights() — comprehensive AI self-assessment New MCP tools (36 total): - get_learning_insights: Full learning report with all patterns - get_symbol_stats: Per-symbol AI performance stats Database: signal_records table (Fly.io Postgres) Docs: architecture/learning.md added The AI now knows its own strengths, weaknesses, and blind spots. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e040d3c commit 34a1e2b

5 files changed

Lines changed: 568 additions & 1 deletion

File tree

docs/architecture/learning.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Quantitative Learning Engine
2+
3+
The learning engine tracks every AI prediction and its outcome, building a data-driven understanding of what works and what doesn't.
4+
5+
## What It Tracks
6+
7+
| Metric | Question It Answers |
8+
|--------|-------------------|
9+
| **Symbol Accuracy** | Which stocks is the AI best/worst at? |
10+
| **Confidence Calibration** | When AI says 75%, does it win 75%? |
11+
| **Sector Performance** | Banking vs IT vs Energy — where's the edge? |
12+
| **Regime Performance** | High VIX vs low VIX — different strategies? |
13+
| **Timing Patterns** | Morning entries vs afternoon — which works? |
14+
| **Stop-Loss Analysis** | Are stops too tight (hit before recovery)? |
15+
| **Holding Period** | Optimal days to hold per stock? |
16+
17+
## How It Works
18+
19+
```
20+
Trade Executed → Record: symbol, confidence, entry, sector, regime, hour
21+
22+
Trade Closed → Update: exit price, P&L, won/lost, holding days
23+
24+
Learning Engine → Analyze patterns across all trades
25+
26+
Generate Insights → "OVERCONFIDENT on IT stocks", "Stops too tight on RELIANCE"
27+
28+
Inject into Agent → Next analysis uses these insights
29+
```
30+
31+
## MCP Tools
32+
33+
- `get_learning_insights` — Full learning report with all patterns
34+
- `get_symbol_stats RELIANCE` — Per-symbol performance stats
35+
36+
## Database Tables
37+
38+
- `signal_records` — Every signal with outcome (Fly.io Postgres)
39+
40+
## Self-Correction
41+
42+
The learning engine enables **self-correction**:
43+
44+
- If AI is overconfident (says 80% but wins 50%), it learns to lower confidence
45+
- If stops are hit 60% of the time, it widens stops automatically
46+
- If a sector consistently loses, the AI deprioritizes it in scans

skopaq/learning/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Quantitative Learning Engine — the AI learns from its own trading numbers.
2+
3+
Tracks signal accuracy, regime performance, confidence calibration,
4+
sector patterns, and timing — all fed back into the analysis pipeline.
5+
"""

0 commit comments

Comments
 (0)