Files
trading_bot_v4/docs/CRITICAL_1MIN_WEBHOOK_FIX.md
mindesbunister 75069802bf docs: CRITICAL - Document 1-minute webhook misconfiguration fix
Issue: 1-minute data alerts using wrong webhook (tradingview-bot-v4)
Impact: Triggered Money Machine trading workflow every minute
Solution: Need dedicated market_data_handler webhook
Status: Alerts paused, awaiting correct webhook URL from n8n
2025-11-27 09:27:36 +01:00

198 lines
5.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CRITICAL: 1-Minute Alert Webhook Fix
**Date:** November 27, 2025
**Issue:** 1-minute data alerts triggering actual trade executions
**Severity:** HIGH - Caused unintended real money trades
---
## Problem
The 1-minute market data alerts were configured with the **wrong webhook URL**, causing them to trigger the **Money Machine trading workflow** instead of just collecting data.
### Root Cause
- **Incorrect webhook:** `https://flow.egonetix.de/webhook/tradingview-bot-v4`
- **This webhook triggers:** Money Machine workflow (executes real trades)
- **Should trigger:** Market data collection workflow (data only, no trades)
### Impact
- 1-minute alerts fired every 60 seconds
- Each alert triggered Money Machine workflow
- Trading signals executed (SOL/ETH/BTC positions opened)
- **This was NOT the intended behavior** - should only collect market data
---
## Solution: Create Dedicated Market Data Webhook
### Option 1: Use n8n API to Create New Webhook (RECOMMENDED)
You need to create a **separate n8n workflow** with its own webhook path for market data collection.
**Steps:**
1. **Import the market_data_handler.json workflow to n8n:**
```bash
# The workflow file is ready at:
/home/icke/traderv4/workflows/trading/market_data_handler.json
```
2. **In n8n UI:**
- Go to Workflows → Import from File
- Select `market_data_handler.json`
- **Activate the workflow**
3. **Get the webhook URL:**
- Open the imported workflow
- Click the "Webhook" node
- Copy the **Test URL** (will look like: `https://flow.egonetix.de/webhook/UNIQUE_ID`)
- This is your market data webhook URL
4. **Update TradingView alerts:**
- Edit SOL-PERP 1min Data Feed alert
- Change webhook from `tradingview-bot-v4` to the new URL
- Repeat for ETH-PERP and BTC-PERP alerts
### Option 2: Manual n8n Workflow Configuration
If importing doesn't work, create workflow manually:
1. **Create new workflow** in n8n: "Market Data Collection - 1min"
2. **Add Webhook node:**
- HTTP Method: POST
- Path: `market-data-1min` (custom unique path)
- Get the full webhook URL from n8n
3. **Add IF node: "Is 1min Data?"**
- Condition: `{{ $json.body.action }}` equals `market_data_1min`
4. **Add HTTP Request node: "Forward to Bot"**
- Method: POST
- URL: `http://trading-bot-v4:3000/api/trading/market-data`
- Send Body: JSON
- JSON Body: `{{ $json.body }}`
5. **Connect nodes:** Webhook → IF → HTTP Request
6. **Activate workflow**
7. **Copy webhook URL** from Webhook node
---
## Correct Webhook URLs
### Trading Execution (Money Machine)
```
https://flow.egonetix.de/webhook/tradingview-bot-v4
```
**Purpose:** Execute real trades (5min/15min signals)
**Used by:** Money Machine workflow
**Action:** Opens positions on Drift Protocol
### Market Data Collection (NEW - Needed)
```
https://flow.egonetix.de/webhook/UNIQUE_ID_HERE
```
**Purpose:** Collect 1-minute market data only
**Used by:** Market Data Handler workflow
**Action:** Updates cache, NO trades executed
---
## TradingView Alert Configuration (CORRECTED)
### Alert Settings Tab
- **Condition:** "Money Line - 1min Data Feed" > "Any alert() function call"
- **Interval:** 1m
- **Expiration:** Open-ended
### Alert Message Tab
- **Alert name:** `SOL-PERP 1min Data Feed`
- **Message:** Leave blank (indicator sends JSON)
- **Webhook URL:** `https://flow.egonetix.de/webhook/NEW_MARKET_DATA_URL` ← **NOT tradingview-bot-v4!**
- ✅ Check "Webhook URL"
---
## Verification After Fix
### 1. Check n8n Workflow Execution Count
```bash
# Market Data Handler should show 180 executions/hour (3 symbols × 60/hour)
# Money Machine should show 0 executions from 1-minute alerts
```
### 2. Monitor Bot Logs
```bash
docker logs trading-bot-v4 -f | grep "Market data updated"
# Should see: "✅ Market data updated for SOL-PERP: ADX 26.5..."
# Should NOT see: "🎯 POSITION OPENED" from 1-minute alerts
```
### 3. Check Open Positions
```bash
# Should see only legitimate trading signals (5min/15min charts)
# NOT 1-minute candle opens
```
### 4. Verify Cache Updates
```bash
curl -s http://localhost:3001/api/trading/market-data | jq '.["SOL-PERP"]'
# Expected: Fresh data (<60s old), adx/atr/rsi values populated
```
---
## Prevention
**Before creating ANY new TradingView alert:**
1. ✅ Verify which webhook URL to use
2. ✅ Data collection = Market data webhook (NEW)
3. ✅ Trading signals = Money Machine webhook (tradingview-bot-v4)
4. ✅ Test with 1-2 alerts first before creating all 3 symbols
**Rule:** Different purposes = different webhooks!
---
## Next Steps
1. **IMMEDIATE:** Delete or pause the 3 incorrectly configured 1-minute alerts in TradingView
2. **Import/Create** market data handler workflow in n8n (get unique webhook URL)
3. **Recreate alerts** with correct webhook URL
4. **Test** for 5-10 minutes (should see cache updates, NO trades)
5. **Validate** for 24 hours before considering it production-ready
---
## Files Affected
- `/home/icke/traderv4/docs/1MIN_ALERTS_SETUP.md` - Needs webhook URL correction
- `/home/icke/traderv4/workflows/trading/market_data_handler.json` - Import this to n8n
- TradingView alerts: SOL-PERP, ETH-PERP, BTC-PERP 1min Data Feed (need recreation)
---
## Lesson Learned
**Always verify webhook routing before deploying alerts that fire every minute.**
With 180 alerts/hour, a misconfigured webhook can:
- Execute 180 unintended trades/hour
- Drain capital rapidly
- Create massive position exposure
- Trigger rate limits
**Test with 1 alert first, verify behavior, then scale to all symbols.**