diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index f51d291..3c6bdd1 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -31,7 +31,7 @@ "id": "75185287.024c5c", "type": "tab", "label": "LiveDynHF-ETC", - "disabled": false, + "disabled": true, "info": "" }, { @@ -55,6 +55,13 @@ "disabled": false, "info": "" }, + { + "id": "28401549.718faa", + "type": "tab", + "label": "LiveDynHF-NG-ETC", + "disabled": false, + "info": "" + }, { "id": "af98615f.cf9ce", "type": "subflow", @@ -1359,7 +1366,7 @@ "t": "set", "p": "maxBuyPrice", "pt": "flow", - "to": "7", + "to": "7.5", "tot": "num" } ], @@ -2494,7 +2501,7 @@ "t": "set", "p": "maxBuyPrice", "pt": "flow", - "to": "6", + "to": "6.5", "tot": "num" } ], @@ -4426,7 +4433,7 @@ "z": "791ce869.901798", "name": "", "topic": "", - "payload": "{\"pair\":\"XXMRZUSD\", \"currency\":\"XXMR\"}", + "payload": "{\"pair\":\"XXMRZUSD\", \"currency\":\"XXMR\", \"maxVolume\": 70, \"minVolume\":0, \"delta\":1, \"multiplier\":2, \"maxBuyPrice\":165}", "payloadType": "json", "repeat": "60", "crontab": "", @@ -4489,41 +4496,6 @@ "pt": "flow", "to": "$number(payload.balance)", "tot": "jsonata" - }, - { - "t": "set", - "p": "maxVolume", - "pt": "flow", - "to": "54", - "tot": "num" - }, - { - "t": "set", - "p": "minVolume", - "pt": "flow", - "to": "0", - "tot": "num" - }, - { - "t": "set", - "p": "delta", - "pt": "flow", - "to": "1", - "tot": "num" - }, - { - "t": "set", - "p": "multiplier", - "pt": "flow", - "to": "2", - "tot": "num" - }, - { - "t": "set", - "p": "maxBuyPrice", - "pt": "flow", - "to": "165", - "tot": "num" } ], "action": "", @@ -4966,7 +4938,7 @@ "type": "function", "z": "791ce869.901798", "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 pair=flow.get(\"pair\");\nlet askPrice=msg.payload[pair].a[0];\nlet bidPrice=msg.payload[pair].b[0];\nflow.set(\"askPrice\",Number(askPrice));\nflow.set(\"bidPrice\",Number(bidPrice));\n\nlet lastExecPrice=flow.get('lastExecPrice',\"file\");\n\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": [ + [ + "bad3930d.0ec49" + ] + ] + }, + { + "id": "6c1b650a.85f83c", + "type": "function", + "z": "28401549.718faa", + "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": [ + [ + "c7db83ea.ee89b" + ] + ] + }, + { + "id": "af3ca106.0c6df", + "type": "function", + "z": "28401549.718faa", + "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": [ + [ + "5e82f447.b7312c" + ] + ] + }, + { + "id": "cfc5c019.f5059", + "type": "catch", + "z": "28401549.718faa", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "dc04cd7a.1f338" + ] + ] + }, + { + "id": "dc04cd7a.1f338", + "type": "debug", + "z": "28401549.718faa", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "abb50971.3c6678", + "type": "switch", + "z": "28401549.718faa", + "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": [ + [ + "eb76a933.5be198" + ], + [ + "8bc8b1f9.66d35" + ] + ] + }, + { + "id": "8bc8b1f9.66d35", + "type": "debug", + "z": "28401549.718faa", + "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": "10231861.ad3ec8", + "type": "function", + "z": "28401549.718faa", + "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": [ + [ + "64222400.2f6cfc" + ] + ] + }, + { + "id": "64222400.2f6cfc", + "type": "debug", + "z": "28401549.718faa", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 310, + "y": 280, + "wires": [] + }, + { + "id": "ed2c5332.6d791", + "type": "inject", + "z": "28401549.718faa", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 280, + "wires": [ + [ + "10231861.ad3ec8" + ] + ] + }, + { + "id": "dba0a3af.87b3d", + "type": "inject", + "z": "28401549.718faa", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 680, + "wires": [ + [ + "609ce70a.f0e4c8" + ] + ] + }, + { + "id": "609ce70a.f0e4c8", + "type": "change", + "z": "28401549.718faa", + "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": "481867e7.00e518", + "type": "debug", + "z": "28401549.718faa", + "name": "", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 900, + "y": 440, + "wires": [] + }, + { + "id": "8d54894c.12e758", + "type": "debug", + "z": "28401549.718faa", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 770, + "y": 40, + "wires": [] + }, + { + "id": "c3a7340e.13c908", + "type": "change", + "z": "28401549.718faa", + "name": "", + "rules": [ + { + "t": "set", + "p": "pair", + "pt": "flow", + "to": "payload.pair", + "tot": "msg" + }, + { + "t": "set", + "p": "currency", + "pt": "flow", + "to": "payload.currency", + "tot": "msg" + }, + { + "t": "set", + "p": "maxVolume", + "pt": "flow", + "to": "payload.maxVolume", + "tot": "msg" + }, + { + "t": "set", + "p": "minVolume", + "pt": "flow", + "to": "payload.minVolume", + "tot": "msg" + }, + { + "t": "set", + "p": "multiplier", + "pt": "flow", + "to": "payload.multiplier", + "tot": "msg" + }, + { + "t": "set", + "p": "maxBuyPrice", + "pt": "flow", + "to": "payload.maxBuyPrice", + "tot": "msg" + }, + { + "t": "set", + "p": "delta", + "pt": "flow", + "to": "payload.delta", + "tot": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 200, + "y": 500, + "wires": [ + [ + "2e3c4069.869b4" + ] + ] + }, + { + "id": "a9bda89.c5e5258", + "type": "function", + "z": "28401549.718faa", + "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": "950f94.5276007", + "type": "function", + "z": "28401549.718faa", + "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": "e21e73d0.3f292", + "type": "add-standard-order", + "z": "28401549.718faa", + "kraken": "e64b38bb.529c88", + "name": "Send Buy Order ", + "x": 2460, + "y": 720, + "wires": [ + [ + "92d9aa58.40bf58", + "950f94.5276007" + ], + [ + "1be10ced.ae6883" + ] + ] + }, + { + "id": "adf52a9f.4e5a18", + "type": "function", + "z": "28401549.718faa", + "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": [ + [ + "610d0259.e3df5c", + "9bda3ba8.c6b038" + ] + ] + }, + { + "id": "9bda3ba8.c6b038", + "type": "debug", + "z": "28401549.718faa", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 1060, + "y": 40, + "wires": [] + }, + { + "id": "3e8fee12.033832", + "type": "inject", + "z": "28401549.718faa", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 760, + "wires": [ + [ + "d56e5ce0.a2499" + ] + ] + }, + { + "id": "d56e5ce0.a2499", + "type": "change", + "z": "28401549.718faa", + "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": "db23fe61.a94ea", + "type": "inject", + "z": "28401549.718faa", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 840, + "wires": [ + [ + "49001c8f.527214" + ] + ] + }, + { + "id": "49001c8f.527214", + "type": "change", + "z": "28401549.718faa", + "name": "Manual LastExecPrice", + "rules": [ + { + "t": "delete", + "p": "#:(file)::lastExecPrice", + "pt": "flow" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 340, + "y": 840, + "wires": [ + [] + ] + }, + { + "id": "18ed1316.8484dd", + "type": "inject", + "z": "28401549.718faa", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 900, + "wires": [ + [ + "538f5e05.71637" + ] + ] + }, + { + "id": "538f5e05.71637", + "type": "change", + "z": "28401549.718faa", + "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