From d0aa9dd4135944cf125a7c57af4e3e417e665d29 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Thu, 24 Dec 2020 18:11:28 -0600 Subject: [PATCH] Add NG-flow with bugfixes --- flows_nodered_kraken.json | 1390 ++++++++++++++++++++++++++++++++++++- 1 file changed, 1386 insertions(+), 4 deletions(-) diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index 5ea9920..f51d291 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -45,6 +45,13 @@ "id": "14ed22c2.6530bd", "type": "tab", "label": "LiveDynHF-XMR", + "disabled": true, + "info": "" + }, + { + "id": "791ce869.901798", + "type": "tab", + "label": "LiveDynHF-NG-XMR", "disabled": false, "info": "" }, @@ -1260,7 +1267,7 @@ "payloadType": "json", "repeat": "60", "crontab": "", - "once": false, + "once": true, "onceDelay": 0.1, "x": 140, "y": 420, @@ -3428,7 +3435,7 @@ "t": "set", "p": "maxVolume", "pt": "flow", - "to": "50", + "to": "70", "tot": "num" }, { @@ -3456,7 +3463,7 @@ "t": "set", "p": "maxBuyPrice", "pt": "flow", - "to": "135", + "to": "155", "tot": "num" } ], @@ -3898,7 +3905,7 @@ "type": "function", "z": "14ed22c2.6530bd", "name": "Determine Action", - "func": "//$number(payload.XMRUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.XXMRZUSD.a[0];\nlet bidPrice=msg.payload.XXMRZUSD.b[0];\nlet lastExecPrice=flow.get('lastExecPrice',\"file\");\nif (lastExecPrice === undefined) { \n lastExecPrice=askPrice; \n flow.set('lastExecPrice',lastExecPrice,\"file\");\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPricelastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPricelastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPrice{\n msg.flowContext[\"(File)\"+ele]=flow.get(ele,\"file\");\n});\nflow.keys().forEach(ele=>{\n msg.flowContext[\"(Mem)\"+ele]=flow.get(ele);\n});\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 1510, + "y": 500, + "wires": [ + [ + "1fc77690.6dba29" + ] + ] + }, + { + "id": "7826a982.9ab1a8", + "type": "function", + "z": "791ce869.901798", + "name": "FlowContext2msg", + "func": "msg.flowContext = {};\nflow.keys(\"file\").forEach(ele=>{\n msg.flowContext[\"(File)\"+ele]=flow.get(ele,\"file\");\n});\nflow.keys().forEach(ele=>{\n msg.flowContext[\"(Mem)\"+ele]=flow.get(ele);\n});\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 1510, + "y": 940, + "wires": [ + [ + "fad60147.7959d" + ] + ] + }, + { + "id": "5a75c25c.e3a73c", + "type": "function", + "z": "791ce869.901798", + "name": "FlowContext2msg", + "func": "msg.flowContext = {};\nflow.keys(\"file\").forEach(ele=>{\n msg.flowContext[\"(File)\"+ele]=flow.get(ele,\"file\");\n});\nflow.keys().forEach(ele=>{\n msg.flowContext[\"(Mem)\"+ele]=flow.get(ele);\n});\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 1510, + "y": 1040, + "wires": [ + [ + "a088ddf.2908b2" + ] + ] + }, + { + "id": "18ad848.b1ba67c", + "type": "catch", + "z": "791ce869.901798", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "b12af9d5.fa7168" + ] + ] + }, + { + "id": "b12af9d5.fa7168", + "type": "debug", + "z": "791ce869.901798", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "5cafb1d8.c2e0b", + "type": "switch", + "z": "791ce869.901798", + "name": "Max-Price?", + "property": "$number(payload.XXMRZUSD.a[0])", + "propertyType": "jsonata", + "rules": [ + { + "t": "lte", + "v": "maxBuyPrice", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1750, + "y": 760, + "wires": [ + [ + "7e1d9a.c6aeb268" + ], + [ + "9fc278e4.eec9f8" + ] + ] + }, + { + "id": "9fc278e4.eec9f8", + "type": "debug", + "z": "791ce869.901798", + "name": "Not Buying, max buy price exceeded.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 2040, + "y": 780, + "wires": [] + }, + { + "id": "a83a82d7.061a7", + "type": "function", + "z": "791ce869.901798", + "name": "FlowContext2msg", + "func": "msg.flowContext = {};\nflow.keys(\"file\").forEach(ele=>{\n msg.flowContext[\"(File)\"+ele]=flow.get(ele,\"file\");\n});\nflow.keys().forEach(ele=>{\n msg.flowContext[\"(Mem)\"+ele]=flow.get(ele);\n});\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 190, + "y": 340, + "wires": [ + [ + "40a6e4ef.7b632c" + ] + ] + }, + { + "id": "40a6e4ef.7b632c", + "type": "debug", + "z": "791ce869.901798", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 310, + "y": 280, + "wires": [] + }, + { + "id": "ebc8b806.bd8c08", + "type": "inject", + "z": "791ce869.901798", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 280, + "wires": [ + [ + "a83a82d7.061a7" + ] + ] + }, + { + "id": "90b1a878.2e9078", + "type": "inject", + "z": "791ce869.901798", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 680, + "wires": [ + [ + "842629ff.39e1f8" + ] + ] + }, + { + "id": "842629ff.39e1f8", + "type": "change", + "z": "791ce869.901798", + "name": "BUY", + "rules": [ + { + "t": "set", + "p": "#:(file)::lastExecPrice", + "pt": "flow", + "to": "999", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 290, + "y": 680, + "wires": [ + [] + ] + }, + { + "id": "f0e0540.34101b", + "type": "debug", + "z": "791ce869.901798", + "name": "", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 900, + "y": 440, + "wires": [] + }, + { + "id": "4fc3c2c2.eb524c", + "type": "debug", + "z": "791ce869.901798", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 770, + "y": 40, + "wires": [] + }, + { + "id": "aa3a99bd.8df5b8", + "type": "change", + "z": "791ce869.901798", + "name": "", + "rules": [ + { + "t": "set", + "p": "pair", + "pt": "flow", + "to": "payload.pair", + "tot": "msg" + }, + { + "t": "set", + "p": "currency", + "pt": "flow", + "to": "payload.currency", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 200, + "y": 500, + "wires": [ + [ + "b8f99af2.43c928" + ] + ] + }, + { + "id": "d313119a.7dbbd", + "type": "function", + "z": "791ce869.901798", + "name": "Recompute CoinBalance (sell)", + "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet sellPrice = flow.get(\"bidPrice\");\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 2770, + "y": 560, + "wires": [ + [] + ] + }, + { + "id": "237dab2.fbb4054", + "type": "function", + "z": "791ce869.901798", + "name": "Recompute CoinBalance (buy)", + "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = flow.get(\"askPrice\"); \n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 2770, + "y": 720, + "wires": [ + [] + ] + }, + { + "id": "4c94b0f3.5706d", + "type": "add-standard-order", + "z": "791ce869.901798", + "kraken": "e64b38bb.529c88", + "name": "Send Buy Order ", + "x": 2460, + "y": 720, + "wires": [ + [ + "5596b182.9b1d9", + "237dab2.fbb4054" + ], + [ + "e33429fb.63d0b8" + ] + ] + }, + { + "id": "f8444acf.9e5018", + "type": "function", + "z": "791ce869.901798", + "name": "dynamic Currency To fix Key", + "func": "let currency=flow.get('currency');\n\nif (msg.payload[currency]!==undefined) {\n msg.payload.balance=msg.payload[currency];\n}\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 820, + "y": 80, + "wires": [ + [ + "137e74af.55b07b", + "c6cb83e5.47092" + ] + ] + }, + { + "id": "c6cb83e5.47092", + "type": "debug", + "z": "791ce869.901798", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 1060, + "y": 40, + "wires": [] + }, + { + "id": "a695a39b.f7902", + "type": "inject", + "z": "791ce869.901798", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 760, + "wires": [ + [ + "5b6ededf.2ac89" + ] + ] + }, + { + "id": "5b6ededf.2ac89", + "type": "change", + "z": "791ce869.901798", + "name": "Manual CoinBalance", + "rules": [ + { + "t": "set", + "p": "coinBalance", + "pt": "flow", + "to": "6", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 340, + "y": 760, + "wires": [ + [] + ] + }, + { + "id": "a3d0d862.ac3b88", + "type": "inject", + "z": "791ce869.901798", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 840, + "wires": [ + [ + "f6f269cb.ffcf18" + ] + ] + }, + { + "id": "f6f269cb.ffcf18", + "type": "change", + "z": "791ce869.901798", + "name": "Manual LastExecPrice", + "rules": [ + { + "t": "set", + "p": "#:(file)::lastExecPrice", + "pt": "flow", + "to": "154.96", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 340, + "y": 840, + "wires": [ + [] + ] + }, + { + "id": "d085c84b.b8d738", + "type": "inject", + "z": "791ce869.901798", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 900, + "wires": [ + [ + "8253bf67.e626c" + ] + ] + }, + { + "id": "8253bf67.e626c", + "type": "change", + "z": "791ce869.901798", + "name": "", + "rules": [ + { + "t": "delete", + "p": "#:(file)::coinBalance", + "pt": "flow" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 330, + "y": 900, + "wires": [ + [] + ] } ] \ No newline at end of file