Files
trading_bot_v4/Money_Machine.json

486 lines
12 KiB
JSON

{
"name": "Money Machine",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "3371ad7c-0866-4161-90a4-f251de4aceb8",
"options": {}
},
"id": "35b54214-9761-49dc-97b6-df39543f0a7b",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
-840,
660
],
"webhookId": "3371ad7c-0866-4161-90a4-f251de4aceb8"
},
{
"parameters": {
"fields": {
"values": [
{
"name": "rawMessage",
"stringValue": "={{ $json.body }}"
},
{
"name": "symbol",
"stringValue": "={{ ($json.body || '').toString().match(/\\bSOL\\b/i) ? 'SOL-PERP' : (($json.body || '').toString().match(/\\bBTC\\b/i) ? 'BTC-PERP' : (($json.body || '').toString().match(/\\bETH\\b/i) ? 'ETH-PERP' : 'SOL-PERP')) }}"
},
{
"name": "direction",
"stringValue": "={{ ($json.body || '').toString().match(/\\b(sell|short)\\b/i) ? 'short' : 'long' }}"
},
{
"name": "timeframe",
"stringValue": "5"
}
]
},
"options": {}
},
"id": "99336995-2326-4575-9970-26afcf957132",
"name": "Parse Signal",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
-660,
660
]
},
{
"parameters": {
"method": "POST",
"url": "http://10.0.0.48:3001/api/trading/check-risk",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer 2a344f0149442c857fb56c038c0c7d1b113883b830bec792c76f1e0efa15d6bb"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"symbol\": \"{{ $json.symbol }}\",\n \"direction\": \"{{ $json.direction }}\"\n}",
"options": {}
},
"id": "d42e7897-eadd-4202-8565-ac60759b46e1",
"name": "Check Risk",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-340,
660
],
"credentials": {
"httpHeaderAuth": {
"id": "MATuNdkZclq5ISbr",
"name": "Header Auth account"
}
}
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.allowed }}",
"value2": true
}
]
}
},
"id": "a60bfecb-d2f4-4165-a609-e6ed437aa2aa",
"name": "Risk Passed?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-140,
660
]
},
{
"parameters": {
"method": "POST",
"url": "http://10.0.0.48:3001/api/trading/execute",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer 2a344f0149442c857fb56c038c0c7d1b113883b830bec792c76f1e0efa15d6bb"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"symbol\": \"{{ $('Parse Signal').item.json.symbol }}\",\n \"direction\": \"{{ $('Parse Signal').item.json.direction }}\",\n \"timeframe\": \"{{ $('Parse Signal').item.json.timeframe }}\",\n \"signalStrength\": \"strong\"\n}",
"options": {
"timeout": 120000
}
},
"id": "95c46846-4b6a-4f9e-ad93-be223b73a618",
"name": "Execute Trade",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
60,
560
],
"credentials": {
"httpHeaderAuth": {
"id": "MATuNdkZclq5ISbr",
"name": "Header Auth account"
}
}
},
{
"parameters": {
"conditions": {
"boolean": [
{
"value1": "={{ $json.success }}",
"value2": true
}
]
}
},
"id": "18342642-e76f-484f-b532-d29846536a9c",
"name": "Trade Success?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
260,
560
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "message",
"stringValue": "={{ `🟢 TRADE OPENED\n\n📊 Symbol: ${$('Parse Signal').item.json.symbol}\n${$('Parse Signal').item.json.direction === 'long' ? '📈' : '📉'} Direction: ${$('Parse Signal').item.json.direction.toUpperCase()}\n\n💵 Position: $${$('Execute Trade').item.json.positionSize}\n⚡ Leverage: ${$('Execute Trade').item.json.leverage}x\n\n💰 Entry: $${$('Execute Trade').item.json.entryPrice.toFixed(4)}\n🎯 TP1: $${$('Execute Trade').item.json.takeProfit1.toFixed(4)} (${$('Execute Trade').item.json.tp1Percent}%)\n🎯 TP2: $${$('Execute Trade').item.json.takeProfit2.toFixed(4)} (${$('Execute Trade').item.json.tp2Percent}%)\n🛑 SL: $${$('Execute Trade').item.json.stopLoss.toFixed(4)} (${$('Execute Trade').item.json.stopLossPercent}%)\n\n⏰ ${$now.toFormat('HH:mm:ss')}\n✅ Position monitored` }}"
}
]
},
"options": {}
},
"id": "9da40e3d-b855-4c65-a032-c6fcf88245d4",
"name": "Format Success",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
460,
460
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "message",
"stringValue": "🔴 TRADE FAILED\\n\\n{{ $('Parse Signal').item.json.rawMessage }}\\n\\n❌ Error: {{ $json.error || $json.message }}\\n⏰ {{ $now.toFormat('HH:mm') }}"
}
]
},
"options": {}
},
"id": "500751c7-21bb-4351-8a6a-d43a1bfb9eaa",
"name": "Format Error",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
460,
660
]
},
{
"parameters": {
"fields": {
"values": [
{
"name": "message",
"stringValue": "⚠️ TRADE BLOCKED\\n\\n{{ $('Parse Signal').item.json.rawMessage }}\\n\\n🛑 Risk limits exceeded\\n⏰ {{ $now.toFormat('HH:mm') }}"
}
]
},
"options": {}
},
"id": "dec6cbc4-7550-40d3-9195-c4cc4f787b9b",
"name": "Format Risk",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
60,
760
]
},
{
"parameters": {
"chatId": "579304651",
"text": "={{ $json.message }}",
"additionalFields": {
"appendAttribution": false
}
},
"id": "6267b604-d39b-4cb7-98a5-2342cdced33b",
"name": "Telegram Success",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
660,
460
],
"credentials": {
"telegramApi": {
"id": "Csk5cg4HtaSqP5jJ",
"name": "Telegram account"
}
}
},
{
"parameters": {
"chatId": "579304651",
"text": "{{ `🟢 TRADE OPENED\\n\\n📊 Symbol: ${$('Parse Signal').item.json.symbol}\\n${$('Parse Signal').item.json.direction === 'long' ? '📈' : '📉'} Direction: ${$('Parse Signal').item.json.direction.toUpperCase()}\\n\\n💰 Entry: $${$json.entryPrice.toFixed(4)}\\n🎯 TP1: $${$json.takeProfit1.toFixed(4)} (${$json.tp1Percent}%)\\n🎯 TP2: $${$json.takeProfit2.toFixed(4)} (${$json.tp2Percent}%)\\n🛑 SL: $${$json.stopLoss.toFixed(4)} (${$json.stopLossPercent}%)\\n\\n⏰ ${$now.toFormat('HH:mm:ss')}\\n✅ Position monitored` }}",
"additionalFields": {
"appendAttribution": false
}
},
"id": "88224fac-ef7a-41ec-b68a-e4bc1a5e3f31",
"name": "Telegram Error",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
660,
660
],
"credentials": {
"telegramApi": {
"id": "Csk5cg4HtaSqP5jJ",
"name": "Telegram account"
}
}
},
{
"parameters": {
"chatId": "579304651",
"text": "={{ $json.message }}",
"additionalFields": {
"appendAttribution": false
}
},
"id": "4eccaca4-a5e7-407f-aab9-663a98a8323b",
"name": "Telegram Risk",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
260,
760
],
"credentials": {
"telegramApi": {
"id": "Csk5cg4HtaSqP5jJ",
"name": "Telegram account"
}
}
},
{
"parameters": {
"chatId": "579304651",
"text": "={{ $json.signal.startsWith(\"Buy\") ? \"🟢 \" + $json.signal : \"🔴 \" + $json.signal }}\n",
"additionalFields": {
"appendAttribution": false
}
},
"id": "5a8eda4d-8945-4144-8672-022c9ee68bf6",
"name": "Telegram",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.1,
"position": [
-340,
840
],
"credentials": {
"telegramApi": {
"id": "Csk5cg4HtaSqP5jJ",
"name": "Telegram account"
}
}
},
{
"parameters": {
"fields": {
"values": [
{
"name": "signal",
"stringValue": "={{ $json.body.split('|')[0].trim() }}"
}
]
},
"options": {}
},
"id": "cce16424-fbb1-4191-b719-79ccfd59ec12",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
-660,
840
]
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Parse Signal",
"type": "main",
"index": 0
}
]
]
},
"Parse Signal": {
"main": [
[
{
"node": "Check Risk",
"type": "main",
"index": 0
},
{
"node": "Telegram",
"type": "main",
"index": 0
}
]
]
},
"Check Risk": {
"main": [
[
{
"node": "Risk Passed?",
"type": "main",
"index": 0
}
]
]
},
"Risk Passed?": {
"main": [
[
{
"node": "Execute Trade",
"type": "main",
"index": 0
}
],
[
{
"node": "Format Risk",
"type": "main",
"index": 0
}
]
]
},
"Execute Trade": {
"main": [
[
{
"node": "Trade Success?",
"type": "main",
"index": 0
}
]
]
},
"Trade Success?": {
"main": [
[
{
"node": "Format Success",
"type": "main",
"index": 0
}
],
[
{
"node": "Format Error",
"type": "main",
"index": 0
}
]
]
},
"Format Success": {
"main": [
[
{
"node": "Telegram Success",
"type": "main",
"index": 0
}
]
]
},
"Format Error": {
"main": [
[
{
"node": "Telegram Error",
"type": "main",
"index": 0
}
]
]
},
"Format Risk": {
"main": [
[
{
"node": "Telegram Risk",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "2cc10693-953a-4b97-8c86-750b3063096b",
"id": "xTCaxlyI02bQLxun",
"meta": {
"instanceId": "e766d4f0b5def8ee8cb8561cd9d2b9ba7733e1907990b6987bca40175f82c379"
},
"tags": []
}