docs: Add 1-minute simplified price feed to reduce TradingView alert queue pressure

- Create moneyline_1min_price_feed.pinescript (70% smaller payload)
- Remove ATR/ADX/RSI/VOL/POS from 1-minute alerts (not used for decisions)
- Keep only price + symbol + timeframe for market data cache
- Document rationale in docs/1MIN_SIMPLIFIED_FEED.md
- Fix: 5-minute trading signals being dropped due to 1-minute flood (60/hour)
- Impact: Preserve priority for actual trading signals
This commit is contained in:
mindesbunister
2025-12-04 11:19:04 +01:00
parent 4c36fa2bc3
commit dc674ec6d5
12 changed files with 2476 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
# 1-Minute Simplified Price Feed (Dec 4, 2025)
## Problem Statement
**Issue:** TradingView alert queue getting overwhelmed by 1-minute signal flood
- **Volume:** 60 alerts/hour (one per minute) from 1-minute data feed
- **Impact:** 5-minute trading signals occasionally skipped (happened 2× so far)
- **Root cause:** 1-minute alerts sending full trading signal format with all indicators
## Solution: Lightweight Price-Only Feed
**Change:** Reduce 1-minute alert payload by ~70%
### Before (Full Format)
```
SOLUSDT buy 1 @ 142.08 | ATR:0.65 | ADX:14.3 | RSI:51.3 | VOL:0.87 | POS:59.3 | IND:v9
```
**Size:** ~80 characters
**Processing:** n8n parses 7 fields, bot calculates quality score, saves to BlockedSignal + MarketData
### After (Minimal Format)
```
SOLUSDT buy 1 @ 142.08
```
**Size:** ~22 characters (~73% reduction)
**Processing:** n8n parses 3 fields (symbol/timeframe/price), bot routes to BlockedSignal only
## Why This Works
### What We Actually Need from 1-Minute Data
1.**Price updates** - For market data cache (5-minute expiry)
2.**Symbol identification** - Routing to correct market
3.**Timeframe marker** - `timeframe="1"` triggers data collection path
4.**ATR/ADX/RSI/VOL/POS** - NOT used in real-time (recalculated from DB if needed)
5.**Direction** - Meaningless for data-only signals (see copilot-instructions.md)
### What We Already Have
- **5-minute signals** include full indicator context for trading decisions
- **BlockedSignalTracker** recalculates TP1/TP2/SL from database data (not live indicators)
- **Market data cache** only needs `currentPrice` + `timestamp` for validation (5-minute expiry)
- **MarketData table** can store NULL for indicators (not critical for analysis)
### What Gets Removed
```typescript
// OLD: Execute endpoint saves full metrics to MarketData table
await prisma.marketData.create({
data: {
atr: Number(body.atr) || 0, // ❌ Remove
adx: Number(body.adx) || 0, // ❌ Remove
rsi: Number(body.rsi) || 50, // ❌ Remove
volumeRatio: Number(body.volumeRatio) || 1.0, // ❌ Remove
pricePosition: Number(body.pricePosition) || 50, // ❌ Remove
maGap: Number(body.maGap) || undefined, // ❌ Remove
// Keep essentials
symbol: driftSymbol, // ✅ Keep
timeframe: '1', // ✅ Keep
price: currentPrice, // ✅ Keep
timestamp: new Date() // ✅ Keep (auto-generated)
}
})
```
## Implementation Plan
### Phase 1: Update TradingView Alert (IMMEDIATE)
1. Replace `moneyline_1min_data_feed.pinescript` with `moneyline_1min_price_feed.pinescript`
2. Update TradingView alert to use new script
3. Test: Verify alerts still route to BlockedSignal correctly
### Phase 2: Update Execute Endpoint (OPTIONAL)
Since we're only sending price, make execute endpoint resilient to missing fields:
```typescript
// Lines 193-207: MarketData.create()
// Change required fields to optional with safe defaults
atr: Number(body.atr) || null, // NULL if missing
adx: Number(body.adx) || null,
rsi: Number(body.rsi) || null,
// ... etc
```
### Phase 3: Monitor Results
- Track 5-minute signal reliability (should go from 98% → 100%)
- Verify 1-minute data still saves to BlockedSignal
- Check TradingView alert queue no longer shows congestion
## Expected Impact
### Benefits
1. **70% reduction** in TradingView alert payload size
2. **Priority preservation** - 5-minute trading signals less likely to be dropped
3. **Faster processing** - Less n8n parsing, less bot processing
4. **Same functionality** - No loss of critical features
### Tradeoffs
1. MarketData table will have NULL indicators (acceptable - not used for decisions)
2. Historical 1-minute indicator data less complete (acceptable - we have 5-minute full data)
### No Impact On
- ✅ 5-minute trading signals (still full format with all indicators)
- ✅ BlockedSignalTracker (calculates from price movements, not live indicators)
- ✅ Market data cache (only needs price + timestamp)
- ✅ Smart Entry Validation (uses 5-minute cached data, not 1-minute)
## Files Changed
### TradingView Pine Script
- **NEW:** `workflows/trading/moneyline_1min_price_feed.pinescript` - Simplified version
- **OLD:** `workflows/trading/moneyline_1min_data_feed.pinescript` - Full format (archived)
### n8n Workflow
- **UNCHANGED:** `workflows/trading/parse_signal_enhanced.json` - Already handles minimal format
- Extracts: `symbol`, `timeframe`, `signalPrice` (from `@ price` pattern)
- Defaults: ATR/ADX/RSI/etc to 0 if missing
### Bot Code
- **UNCHANGED:** `app/api/trading/execute/route.ts` - Already handles missing fields with fallbacks
- Lines 193-207: Uses `Number(body.field) || default` pattern
## Migration Steps
1.**Read this document** - Understand rationale
2.**Update TradingView alert** - Replace with `moneyline_1min_price_feed.pinescript`
3.**Test with 1-2 alerts** - Verify BlockedSignal still populates
4.**Monitor for 24 hours** - Check 5-minute signal reliability
5.**Archive old script** - Move `moneyline_1min_data_feed.pinescript` to archive/
## Rollback Plan
If issues arise:
1. Switch TradingView alert back to `moneyline_1min_data_feed.pinescript`
2. No code changes needed - bot handles both formats
## Decision Criteria
**Use simplified feed IF:**
- 5-minute signal drops are occurring regularly (2+ per week)
- TradingView alert queue shows congestion
- 1-minute indicator data not being used for analysis
**Keep full feed IF:**
- 5-minute signals are 100% reliable
- Future analysis requires minute-by-minute indicator tracking
- No performance issues observed
## Current Status (Dec 4, 2025)
- ✅ Simplified script created
- ⏳ TradingView alert update pending
- ⏳ Monitoring results pending
- **User decision:** Test simplified feed for 24-48 hours
## References
- Copilot Instructions: Section "1-Minute Data Collection System"
- Original Implementation: `docs/1MIN_DATA_COLLECTION_SIMPLE.md`
- BlockedSignalTracker: `lib/analysis/blocked-signal-tracker.ts`