diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index 9c63454..5ea9920 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -41,6 +41,13 @@ "disabled": false, "info": "" }, + { + "id": "14ed22c2.6530bd", + "type": "tab", + "label": "LiveDynHF-XMR", + "disabled": false, + "info": "" + }, { "id": "af98615f.cf9ce", "type": "subflow", @@ -2388,7 +2395,7 @@ "payloadType": "json", "repeat": "60", "crontab": "", - "once": false, + "once": true, "onceDelay": 0.1, "x": 140, "y": 420, @@ -2452,7 +2459,7 @@ "t": "set", "p": "maxVolume", "pt": "flow", - "to": "2000", + "to": "1000", "tot": "num" }, { @@ -3346,5 +3353,974 @@ "ba00b0ab.a251b" ] ] + }, + { + "id": "aec915e5.618078", + "type": "inject", + "z": "14ed22c2.6530bd", + "name": "", + "topic": "", + "payload": "{\"pair\":\"XMRUSD\"}", + "payloadType": "json", + "repeat": "60", + "crontab": "", + "once": true, + "onceDelay": 0.1, + "x": 140, + "y": 420, + "wires": [ + [ + "488765e5.fd988c" + ] + ] + }, + { + "id": "488765e5.fd988c", + "type": "switch", + "z": "14ed22c2.6530bd", + "name": "isInitialized?", + "property": "$flowContext('isInitialized')", + "propertyType": "jsonata", + "rules": [ + { + "t": "true" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 390, + "y": 420, + "wires": [ + [ + "7d29ff37.f2257" + ], + [ + "65427c76.51bcf4", + "aef88a37.983178" + ] + ] + }, + { + "id": "171e49e3.897756", + "type": "change", + "z": "14ed22c2.6530bd", + "name": "", + "rules": [ + { + "t": "set", + "p": "isInitialized", + "pt": "flow", + "to": "true", + "tot": "bool" + }, + { + "t": "set", + "p": "coinBalance", + "pt": "flow", + "to": "$number(payload.XXMR)", + "tot": "jsonata" + }, + { + "t": "set", + "p": "maxVolume", + "pt": "flow", + "to": "50", + "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": "135", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1180, + "y": 80, + "wires": [ + [ + "669c98fd.bd65c8" + ] + ] + }, + { + "id": "65427c76.51bcf4", + "type": "get-account-balance", + "z": "14ed22c2.6530bd", + "kraken": "e64b38bb.529c88", + "name": "", + "x": 600, + "y": 120, + "wires": [ + [ + "5b53de52.c452" + ], + [ + "4bb94032.f6cc4", + "1f06f665.27695a" + ] + ] + }, + { + "id": "5b53de52.c452", + "type": "switch", + "z": "14ed22c2.6530bd", + "name": "", + "property": "payload.XXMR", + "propertyType": "msg", + "rules": [ + { + "t": "nempty" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 770, + "y": 80, + "wires": [ + [ + "171e49e3.897756" + ], + [ + "3404b358.f1d4cc" + ] + ] + }, + { + "id": "3404b358.f1d4cc", + "type": "change", + "z": "14ed22c2.6530bd", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload.XXMR", + "pt": "msg", + "to": "0", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 950, + "y": 120, + "wires": [ + [ + "171e49e3.897756" + ] + ] + }, + { + "id": "669c98fd.bd65c8", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "Initialized.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 1370, + "y": 80, + "wires": [] + }, + { + "id": "4bb94032.f6cc4", + "type": "delay", + "z": "14ed22c2.6530bd", + "name": "", + "pauseType": "delay", + "timeout": "5", + "timeoutUnits": "seconds", + "rate": "1", + "nbRateUnits": "1", + "rateUnits": "second", + "randomFirst": "1", + "randomLast": "5", + "randomUnits": "seconds", + "drop": false, + "x": 600, + "y": 180, + "wires": [ + [ + "65427c76.51bcf4" + ] + ] + }, + { + "id": "1f06f665.27695a", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "Error getting Balance - retrying infinite.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 940, + "y": 160, + "wires": [] + }, + { + "id": "8071fbaa.1c5d48", + "type": "inject", + "z": "14ed22c2.6530bd", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 80, + "wires": [ + [ + "47f3737.0c6b88c" + ] + ] + }, + { + "id": "47f3737.0c6b88c", + "type": "change", + "z": "14ed22c2.6530bd", + "name": "", + "rules": [ + { + "t": "delete", + "p": "isInitialized", + "pt": "flow" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 340, + "y": 80, + "wires": [ + [] + ] + }, + { + "id": "e2e11ccd.fc438", + "type": "comment", + "z": "14ed22c2.6530bd", + "name": "Force-Uninitialize (Reload settings)", + "info": "", + "x": 160, + "y": 40, + "wires": [] + }, + { + "id": "7d29ff37.f2257", + "type": "get-ticker-information", + "z": "14ed22c2.6530bd", + "name": "", + "x": 630, + "y": 640, + "wires": [ + [ + "91f75008.3eed7", + "d307c646.5d9df8" + ], + [ + "ae756663.cd1f58" + ] + ] + }, + { + "id": "ae756663.cd1f58", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "Ticker Retrieval Error", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 890, + "y": 760, + "wires": [] + }, + { + "id": "f5f45b8.f80b8a8", + "type": "switch", + "z": "14ed22c2.6530bd", + "name": "Action", + "property": "action", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "sell", + "vt": "str" + }, + { + "t": "eq", + "v": "buy", + "vt": "str" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 3, + "x": 1090, + "y": 680, + "wires": [ + [ + "58be0ce7.3f43b4", + "2efdb850.3d7208" + ], + [ + "c2b77579.76d838", + "28400255.0b17ee" + ], + [ + "79513700.5fce28" + ] + ] + }, + { + "id": "6ba2f795.a566b8", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "gt (sell)", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1740, + "y": 520, + "wires": [] + }, + { + "id": "c6563d45.9123d", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "lt (buy)", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1720, + "y": 880, + "wires": [] + }, + { + "id": "eda42480.b3cd08", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "small diff (nothing)", + "active": false, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1800, + "y": 1060, + "wires": [] + }, + { + "id": "58be0ce7.3f43b4", + "type": "switch", + "z": "14ed22c2.6530bd", + "name": "MinVolReached?", + "property": "$flowContext('coinBalance') - $flowContext('multiplier') ", + "propertyType": "jsonata", + "rules": [ + { + "t": "gte", + "v": "minVolume", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1510, + "y": 620, + "wires": [ + [ + "bce3c307.995fe" + ], + [ + "114507bc.fb5158" + ] + ] + }, + { + "id": "9d0b7450.8501d8", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "Not Selling, min Volume reached.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2000, + "y": 640, + "wires": [] + }, + { + "id": "edb52050.12bf1", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "SELLING!", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 1990, + "y": 560, + "wires": [] + }, + { + "id": "939eadc6.ade49", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "BUYING!", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2190, + "y": 720, + "wires": [] + }, + { + "id": "c2b77579.76d838", + "type": "switch", + "z": "14ed22c2.6530bd", + "name": "MaxVolReached?", + "property": "$flowContext('coinBalance') + $flowContext('multiplier')", + "propertyType": "jsonata", + "rules": [ + { + "t": "lte", + "v": "maxVolume", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1510, + "y": 800, + "wires": [ + [ + "f15c519.de8f9b" + ], + [ + "2e0dfac4.cb3576" + ] + ] + }, + { + "id": "50a81e03.b3341", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "Not buying, max Volume reached.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2170, + "y": 840, + "wires": [] + }, + { + "id": "91f75008.3eed7", + "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 (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": 1550, + "y": 520, + "wires": [ + [ + "6ba2f795.a566b8" + ] + ] + }, + { + "id": "28400255.0b17ee", + "type": "function", + "z": "14ed22c2.6530bd", + "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": 880, + "wires": [ + [ + "c6563d45.9123d" + ] + ] + }, + { + "id": "79513700.5fce28", + "type": "function", + "z": "14ed22c2.6530bd", + "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": 1550, + "y": 1060, + "wires": [ + [ + "eda42480.b3cd08" + ] + ] + }, + { + "id": "a3da91e5.f3412", + "type": "catch", + "z": "14ed22c2.6530bd", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "20b9c7f5.436138" + ] + ] + }, + { + "id": "20b9c7f5.436138", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "f15c519.de8f9b", + "type": "switch", + "z": "14ed22c2.6530bd", + "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": [ + [ + "5eb47b40.77f6e4" + ], + [ + "538afcf8.fa4884" + ] + ] + }, + { + "id": "538afcf8.fa4884", + "type": "debug", + "z": "14ed22c2.6530bd", + "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": "8f059da7.a60e9", + "type": "function", + "z": "14ed22c2.6530bd", + "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": [ + [ + "125f119e.8dde2e" + ] + ] + }, + { + "id": "125f119e.8dde2e", + "type": "debug", + "z": "14ed22c2.6530bd", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 310, + "y": 280, + "wires": [] + }, + { + "id": "fc7490c2.60301", + "type": "inject", + "z": "14ed22c2.6530bd", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 280, + "wires": [ + [ + "8f059da7.a60e9" + ] + ] } ] \ No newline at end of file