Update copilot instructions with signal quality versioning
- Added signalQualityVersion field documentation (v1/v2/v3 tracking) - Documented /api/analytics/version-comparison endpoint - Added Prisma Decimal type handling pitfall (#18) - Added signal quality version tracking section to Development Roadmap - References SQL analysis file for version comparison queries Enables AI agents to understand the version tracking system for data-driven algorithm optimization.
This commit is contained in:
19
.github/copilot-instructions.md
vendored
19
.github/copilot-instructions.md
vendored
@@ -167,6 +167,11 @@ Without this, the SDK returns signatures for transactions that never execute, ca
|
||||
|
||||
**Important fields:**
|
||||
- `signalQualityScore` (Int?) - 0-100 score for data-driven optimization
|
||||
- `signalQualityVersion` (String?) - Tracks which scoring logic was used ('v1', 'v2', 'v3')
|
||||
- v1: Original logic (price position < 5% threshold)
|
||||
- v2: Added volume compensation for low ADX (2025-11-07)
|
||||
- v3: CURRENT - Stricter breakdown requirements: positions < 15% require (ADX > 18 AND volume > 1.2x) OR (RSI < 35 for shorts / RSI > 60 for longs)
|
||||
- All new trades tagged with current version for comparative analysis
|
||||
- `maxFavorableExcursion` / `maxAdverseExcursion` - Track best/worst P&L during trade lifetime
|
||||
- `maxFavorablePrice` / `maxAdversePrice` - Track prices at MFE/MAE points
|
||||
- `configSnapshot` (Json) - Stores Position Manager state for crash recovery
|
||||
@@ -219,6 +224,7 @@ const driftSymbol = normalizeTradingViewSymbol(body.symbol)
|
||||
- `/api/trading/positions` - Query open positions from Drift
|
||||
- `/api/settings` - Get/update config (writes to .env file, **includes per-symbol settings**)
|
||||
- `/api/analytics/last-trade` - Fetch most recent trade details for dashboard (includes quality score)
|
||||
- `/api/analytics/version-comparison` - Compare performance across signal quality logic versions (v1/v2/v3)
|
||||
- `/api/restart` - Create restart flag for watch-restart.sh script
|
||||
|
||||
## Critical Workflows
|
||||
@@ -412,6 +418,13 @@ docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c "\dt"
|
||||
- Bot's quality scoring provides second-layer filtering with context-aware metrics
|
||||
- Two-stage filtering (TradingView + bot) prevents both overtrading and missing valid signals
|
||||
|
||||
18. **Prisma Decimal type handling:** Raw SQL queries return Prisma `Decimal` objects, not plain numbers:
|
||||
- Use `any` type for numeric fields in `$queryRaw` results: `total_pnl: any`
|
||||
- Convert with `Number()` before returning to frontend: `totalPnL: Number(stat.total_pnl) || 0`
|
||||
- Frontend uses `.toFixed()` which doesn't exist on Decimal objects
|
||||
- Applies to all aggregations: SUM(), AVG(), ROUND() - all return Decimal types
|
||||
- Example: `/api/analytics/version-comparison` converts all numeric fields
|
||||
|
||||
## File Conventions
|
||||
|
||||
- **API routes:** `app/api/[feature]/[action]/route.ts` (Next.js 15 App Router)
|
||||
@@ -477,6 +490,12 @@ See `POSITION_SCALING_ROADMAP.md` for planned optimizations:
|
||||
|
||||
**Data-driven approach:** Each phase requires validation through SQL analysis before implementation. No premature optimization.
|
||||
|
||||
**Signal Quality Version Tracking:** Database tracks `signalQualityVersion` field to compare algorithm performance:
|
||||
- Analytics dashboard shows version comparison: trades, win rate, P&L, extreme position stats
|
||||
- Focus on extreme positions (< 15% range) - v3 aims to reduce losses from weak ADX entries
|
||||
- SQL queries in `docs/analysis/SIGNAL_QUALITY_VERSION_ANALYSIS.sql` for deep-dive analysis
|
||||
- Need 20+ v3 trades before meaningful comparison vs v1/v2 data
|
||||
|
||||
## Integration Points
|
||||
|
||||
- **n8n:** Expects exact response format from `/api/trading/execute` (see n8n-complete-workflow.json)
|
||||
|
||||
Reference in New Issue
Block a user