docs: Update n8n MCP token + Add comprehensive workflow documentation
- Updated MCP Bearer token in copilot-instructions.md (new token ending ...SQbRcoBo) - Created docs/N8N_WORKFLOW_DOCUMENTATION.md with complete Money Machine workflow docs - Smart Entry bypass for v11.2+ signals with indicatorScore >= 90 - Money_Machine.json formatting cleanup Files changed: - .github/copilot-instructions.md: MCP token update - docs/N8N_WORKFLOW_DOCUMENTATION.md: NEW comprehensive n8n docs - app/api/trading/execute/route.ts: Smart Entry bypass for high-quality signals - workflows/trading/Money_Machine.json: Telegram message formatting fixes
This commit is contained in:
390
docs/N8N_WORKFLOW_DOCUMENTATION.md
Normal file
390
docs/N8N_WORKFLOW_DOCUMENTATION.md
Normal file
@@ -0,0 +1,390 @@
|
||||
# n8n Workflow Documentation - Money Machine
|
||||
|
||||
**Last Updated:** January 1, 2025
|
||||
**Workflow ID:** gUDqTiHyHSfRUXv6
|
||||
**Status:** ✅ ACTIVE in Production
|
||||
|
||||
## Overview
|
||||
|
||||
The Money Machine workflow is the core automation pipeline connecting TradingView alerts to the Trading Bot v4 system. It handles signal parsing, risk validation, trade execution, and Telegram notifications.
|
||||
|
||||
---
|
||||
|
||||
## n8n Access Credentials
|
||||
|
||||
### REST API (for programmatic access)
|
||||
```bash
|
||||
# API Endpoint
|
||||
https://flow.egonetix.de/api/v1/
|
||||
|
||||
# API Key (X-N8N-API-KEY header)
|
||||
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1NzIxYWQ0OC03NDFjLTRmMDMtOWUxNS0zNDc4MTNiZDJhNmUiLCJpc3MiOiJuOG4iLCJhdWQiOiJwdWJsaWMtYXBpIiwiaWF0IjoxNzY1NjQxNTgzfQ.qcDc8W21GqG4jlfju3IOYlntAiBBfDCfA9tZh4TBNHQ
|
||||
```
|
||||
|
||||
### MCP Server (for AI/IDE integration)
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"n8n-mcp": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"supergateway",
|
||||
"--streamableHttp",
|
||||
"https://flow.egonetix.de/mcp-server/http",
|
||||
"--header",
|
||||
"authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1NzIxYWQ0OC03NDFjLTRmMDMtOWUxNS0zNDc4MTNiZDJhNmUiLCJpc3MiOiJuOG4iLCJhdWQiOiJtY3Atc2VydmVyLWFwaSIsImp0aSI6IjQ2MTQ0ZTNjLWEwMjctNDBiMS1iNTA0LTBhMGRlOGMzNWY4MiIsImlhdCI6MTc2NzI3NzkyOX0.49H7R-GijkrI-Ygthxjq7XowEVkFP8GiN2_SQbRcoBo"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Example API Calls
|
||||
```bash
|
||||
# List all workflows
|
||||
curl -s -X GET "https://flow.egonetix.de/api/v1/workflows" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>"
|
||||
|
||||
# Get specific workflow
|
||||
curl -s -X GET "https://flow.egonetix.de/api/v1/workflows/gUDqTiHyHSfRUXv6" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>"
|
||||
|
||||
# Get workflow executions
|
||||
curl -s -X GET "https://flow.egonetix.de/api/v1/executions?workflowId=gUDqTiHyHSfRUXv6" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Money Machine Workflow Structure
|
||||
|
||||
### Workflow Metadata
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| ID | gUDqTiHyHSfRUXv6 |
|
||||
| Name | Money Machine |
|
||||
| Active | ✅ true |
|
||||
| Node Count | 12 |
|
||||
| Version ID | 955bd768-0c3b-490a-9c6b-5c01bc2f6d44 |
|
||||
|
||||
### Node List (12 nodes)
|
||||
1. **Webhook** - Entry point for TradingView alerts
|
||||
2. **Parse Signal Enhanced** - JavaScript code to parse signal format
|
||||
3. **Check Risk1** - HTTP POST to `/api/trading/check-risk`
|
||||
4. **Risk Passed?** - Boolean condition on `allowed` field
|
||||
5. **Execute Trade1** - HTTP POST to `/api/trading/execute`
|
||||
6. **Trade Success?** - Boolean condition on `success` field
|
||||
7. **Format Success** - Format success message for Telegram
|
||||
8. **Format Error** - Format error message for Telegram
|
||||
9. **Format Risk** - Format blocked trade message
|
||||
10. **Telegram Success** - Send success notification
|
||||
11. **Telegram Error** - Send error notification
|
||||
12. **Telegram Risk** - Send blocked trade notification
|
||||
|
||||
---
|
||||
|
||||
## Signal Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ MONEY MACHINE WORKFLOW │
|
||||
├─────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ TradingView Alert │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌──────────┐ │
|
||||
│ │ Webhook │ POST /webhook/tradingview-bot-v4 │
|
||||
│ └────┬─────┘ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌─────────────────────────┐ │
|
||||
│ │ Parse Signal Enhanced │ Extract: symbol, direction, timeframe, │
|
||||
│ │ (JavaScript Code) │ atr, adx, rsi, volumeRatio, pricePosition, │
|
||||
│ └──────────┬──────────────┘ indicatorVersion, indicatorScore │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌─────────────────────────┐ │
|
||||
│ │ Check Risk1 │ POST http://10.0.0.48:3001/api/trading/check-risk │
|
||||
│ │ (HTTP Request) │ Body: {symbol, direction, timeframe, metrics...} │
|
||||
│ └──────────┬──────────────┘ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌─────────────────────────┐ TRUE: allowed=true │
|
||||
│ │ Risk Passed? ├──────────────────────────┐ │
|
||||
│ │ (IF Condition) │ │ │
|
||||
│ └──────────┬──────────────┘ │ │
|
||||
│ │ FALSE: allowed=false │ │
|
||||
│ ▼ ▼ │
|
||||
│ ┌───────────────┐ ┌────────────────────────────┐ │
|
||||
│ │ Format Risk │ │ Execute Trade1 │ │
|
||||
│ │ (Set Node) │ │ POST /api/trading/execute │ │
|
||||
│ └───────┬───────┘ │ Timeout: 120s │ │
|
||||
│ │ └────────────┬───────────────┘ │
|
||||
│ ▼ │ │
|
||||
│ ┌────────────────────┐ ▼ │
|
||||
│ │ Check Skip │ ┌──────────────────────────┐ │
|
||||
│ │ Notification │ │ Trade Success? │ │
|
||||
│ └───────┬────────────┘ │ (IF Condition) │ │
|
||||
│ │ Skip=false └─────┬──────────┬─────────┘ │
|
||||
│ ▼ TRUE │ │ FALSE │
|
||||
│ ┌───────────────┐ ┌──────────────┘ └────────────┐ │
|
||||
│ │ Telegram Risk │ ▼ ▼ │
|
||||
│ └───────────────┘ ┌────────────────┐ ┌────────────────┐ │
|
||||
│ │ Format Success │ │ Format Error │ │
|
||||
│ └───────┬────────┘ └───────┬────────┘ │
|
||||
│ ▼ ▼ │
|
||||
│ ┌──────────────────┐ ┌──────────────────┐ │
|
||||
│ │ Telegram Success │ │ Telegram Error │ │
|
||||
│ └──────────────────┘ └──────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Node Details
|
||||
|
||||
### 1. Webhook
|
||||
- **Type:** n8n-nodes-base.webhook
|
||||
- **Path:** `tradingview-bot-v4`
|
||||
- **Full URL:** `https://flow.egonetix.de/webhook/tradingview-bot-v4`
|
||||
- **Method:** POST
|
||||
- **Purpose:** Entry point for all TradingView alerts
|
||||
|
||||
### 2. Parse Signal Enhanced
|
||||
- **Type:** n8n-nodes-base.code (JavaScript)
|
||||
- **Purpose:** Parse TradingView alert message into structured data
|
||||
|
||||
**Input Format:**
|
||||
```
|
||||
SOL buy 5 | ATR:0.65 | ADX:14.3 | RSI:51.3 | VOL:0.87 | POS:59.3 | IND:v8 | SCORE:100
|
||||
```
|
||||
|
||||
**Output Fields:**
|
||||
```javascript
|
||||
{
|
||||
rawMessage: "original message",
|
||||
symbol: "SOL-PERP", // Extracted and normalized
|
||||
direction: "long", // "buy" → "long", "sell/short" → "short"
|
||||
timeframe: "5", // Chart timeframe
|
||||
atr: 0.65, // Average True Range
|
||||
adx: 14.3, // ADX trend strength
|
||||
rsi: 51.3, // Relative Strength Index
|
||||
volumeRatio: 0.87, // Volume vs 20-period SMA
|
||||
pricePosition: 59.3, // Price position in 100-bar range (0-100)
|
||||
indicatorVersion: "v8", // TradingView indicator version
|
||||
indicatorScore: 100 // Quality score from indicator (optional)
|
||||
}
|
||||
```
|
||||
|
||||
**Symbol Mapping:**
|
||||
- `SOL` → `SOL-PERP`
|
||||
- `BTC` → `BTC-PERP`
|
||||
- `ETH` → `ETH-PERP`
|
||||
- `FARTCOIN` or `FART` → `FARTCOIN-PERP`
|
||||
|
||||
### 3. Check Risk1
|
||||
- **Type:** n8n-nodes-base.httpRequest
|
||||
- **Method:** POST
|
||||
- **URL:** `http://10.0.0.48:3001/api/trading/check-risk`
|
||||
- **Authentication:** Bearer token
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"symbol": "SOL-PERP",
|
||||
"direction": "long",
|
||||
"timeframe": "5",
|
||||
"atr": 0.65,
|
||||
"adx": 14.3,
|
||||
"rsi": 51.3,
|
||||
"volumeRatio": 0.87,
|
||||
"pricePosition": 59.3
|
||||
}
|
||||
```
|
||||
|
||||
**Expected Response:**
|
||||
```json
|
||||
{
|
||||
"allowed": true,
|
||||
"reason": "signal passed quality check",
|
||||
"qualityScore": 95
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Risk Passed? (IF Condition)
|
||||
- **Type:** n8n-nodes-base.if
|
||||
- **Condition:** `{{ $json.allowed }}` equals `true`
|
||||
- **TRUE branch:** → Execute Trade1
|
||||
- **FALSE branch:** → Format Risk
|
||||
|
||||
### 5. Execute Trade1
|
||||
- **Type:** n8n-nodes-base.httpRequest
|
||||
- **Method:** POST
|
||||
- **URL:** `http://10.0.0.48:3001/api/trading/execute`
|
||||
- **Timeout:** 120,000ms (2 minutes)
|
||||
- **Authentication:** Bearer token
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"symbol": "{{ $('Parse Signal Enhanced').item.json.symbol }}",
|
||||
"direction": "{{ $('Parse Signal Enhanced').item.json.direction }}",
|
||||
"timeframe": "{{ $('Parse Signal Enhanced').item.json.timeframe }}",
|
||||
"atr": {{ $('Parse Signal Enhanced').item.json.atr }},
|
||||
"adx": {{ $('Parse Signal Enhanced').item.json.adx }},
|
||||
"rsi": {{ $('Parse Signal Enhanced').item.json.rsi }},
|
||||
"volumeRatio": {{ $('Parse Signal Enhanced').item.json.volumeRatio }},
|
||||
"pricePosition": {{ $('Parse Signal Enhanced').item.json.pricePosition }},
|
||||
"indicatorVersion": "{{ $('Parse Signal Enhanced').item.json.indicatorVersion }}",
|
||||
"signalPrice": {{ $('Parse Signal Enhanced').item.json.pricePosition }},
|
||||
"indicatorScore": {{ $('Parse Signal Enhanced').item.json.indicatorScore || 'null' }}
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Trade Success? (IF Condition)
|
||||
- **Type:** n8n-nodes-base.if
|
||||
- **Condition:** `{{ $json.success }}` equals `true`
|
||||
- **TRUE branch:** → Format Success
|
||||
- **FALSE branch:** → Format Error
|
||||
|
||||
### 7-9. Format Nodes (Set)
|
||||
Format messages for Telegram notifications based on trade outcome.
|
||||
|
||||
### 10-12. Telegram Nodes
|
||||
- **Type:** n8n-nodes-base.telegram
|
||||
- **Chat ID:** 579304651
|
||||
- **Credential:** "Telegram account" (ID: Csk5cg4HtaSqP5jJ)
|
||||
|
||||
---
|
||||
|
||||
## Internal API Configuration
|
||||
|
||||
### Bot API Base URL
|
||||
```
|
||||
http://10.0.0.48:3001
|
||||
```
|
||||
|
||||
### API Endpoints Used
|
||||
| Endpoint | Method | Purpose |
|
||||
|----------|--------|---------|
|
||||
| `/api/trading/check-risk` | POST | Validate signal quality before execution |
|
||||
| `/api/trading/execute` | POST | Execute trade on Drift Protocol |
|
||||
|
||||
### Authentication Token
|
||||
```
|
||||
Bearer 2a344f0149442c857fb56c038c0c7d1b113883b830bec792c76f1e0efa15d6bb
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Other n8n Workflows
|
||||
|
||||
Besides Money Machine, the following workflows exist on the n8n instance:
|
||||
|
||||
| ID | Name | Status |
|
||||
|----|------|--------|
|
||||
| gUDqTiHyHSfRUXv6 | Money Machine | ✅ Active |
|
||||
| Various | Telegram Bot with AI | Active |
|
||||
| Various | Telegram Bot Simple (x2) | Active |
|
||||
| Various | Telegram Router Direct (x2) | Active |
|
||||
|
||||
---
|
||||
|
||||
## Local Workflow Files
|
||||
|
||||
Location: `/home/icke/traderv4/workflows/trading/`
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `Money_Machine.json` | Main workflow (current) |
|
||||
| `Money_Machine_backup.json` | Backup copy |
|
||||
| `Money_Machine_backup_2.json` | Secondary backup |
|
||||
| `parse_signal_enhanced.json` | Standalone signal parser |
|
||||
| `market_data_forwarder.json` | Market data handling |
|
||||
| `market_data_handler.json` | Market data processing |
|
||||
|
||||
---
|
||||
|
||||
## Indicator Score Bypass (v11.2+)
|
||||
|
||||
As of Dec 26, 2025, the v11.2 indicator sends `SCORE:100` in alerts to bypass bot quality scoring:
|
||||
|
||||
**Signal Format:**
|
||||
```
|
||||
SOL buy 5 | ATR:0.65 | ADX:14.3 | RSI:51.3 | VOL:0.87 | POS:59.3 | IND:v11.2 | SCORE:100
|
||||
```
|
||||
|
||||
**Parse Logic (added to Parse Signal Enhanced):**
|
||||
```javascript
|
||||
const scoreMatch = body.match(/SCORE:(\d+)/);
|
||||
const indicatorScore = scoreMatch ? parseInt(scoreMatch[1]) : null;
|
||||
```
|
||||
|
||||
**Bot Behavior:**
|
||||
- If `indicatorScore >= 90`: Bypasses quality check entirely
|
||||
- Rationale: v11.2 indicator already filters to profitable setups (PF 2.617)
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Signal not executing:**
|
||||
- Check Risk1 response - verify `allowed: true`
|
||||
- Check quality score meets threshold (LONG ≥90, SHORT ≥80)
|
||||
- Verify symbol is enabled in bot config
|
||||
|
||||
2. **Telegram notification missing:**
|
||||
- Check "Check Skip Notification" node conditions
|
||||
- Verify Telegram credentials still valid
|
||||
|
||||
3. **Timeout on Execute Trade1:**
|
||||
- 120s timeout may be insufficient for slow Drift responses
|
||||
- Check Drift RPC endpoint health
|
||||
|
||||
### Debug Steps
|
||||
```bash
|
||||
# Get recent executions
|
||||
curl -s -X GET "https://flow.egonetix.de/api/v1/executions?workflowId=gUDqTiHyHSfRUXv6&limit=5" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>" | jq '.[].status'
|
||||
|
||||
# Check workflow is active
|
||||
curl -s -X GET "https://flow.egonetix.de/api/v1/workflows/gUDqTiHyHSfRUXv6" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>" | jq '.active'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Modification Guide
|
||||
|
||||
### To Update Workflow via API:
|
||||
```bash
|
||||
# Export modified workflow JSON, then:
|
||||
curl -X PUT "https://flow.egonetix.de/api/v1/workflows/gUDqTiHyHSfRUXv6" \
|
||||
-H "X-N8N-API-KEY: <API_KEY>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @Money_Machine.json
|
||||
```
|
||||
|
||||
### To Update via UI:
|
||||
1. Open https://flow.egonetix.de
|
||||
2. Navigate to Money Machine workflow
|
||||
3. Edit nodes as needed
|
||||
4. Save workflow
|
||||
5. Export updated JSON to `/home/icke/traderv4/workflows/trading/Money_Machine.json`
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Date | Change | Commit |
|
||||
|------|--------|--------|
|
||||
| Dec 26, 2025 | Added indicatorScore parsing for v11.2 bypass | ba1fe44 |
|
||||
| Dec 7, 2025 | Fixed symbol normalization for FARTCOIN | - |
|
||||
| Nov 27, 2025 | Added MA crossover detection flags | - |
|
||||
| Nov 19, 2025 | Enhanced timeframe parsing | - |
|
||||
|
||||
Reference in New Issue
Block a user