diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index df9e30e..2bf090d 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -31,20 +31,6 @@ "id": "5b601c88.f89c94", "type": "tab", "label": "LiveDynHF-DOT", - "disabled": false, - "info": "" - }, - { - "id": "14ed22c2.6530bd", - "type": "tab", - "label": "LiveDynHF-XMR", - "disabled": true, - "info": "" - }, - { - "id": "28401549.718faa", - "type": "tab", - "label": "OLD_LiveDynHF-NG-ETC", "disabled": true, "info": "" }, @@ -62,6 +48,13 @@ "disabled": false, "info": "" }, + { + "id": "3fba07ea.b0acd8", + "type": "tab", + "label": "LiveDynHF-NG-DOT", + "disabled": false, + "info": "" + }, { "id": "af98615f.cf9ce", "type": "subflow", @@ -2399,1020 +2392,6 @@ ] ] }, - { - "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": "70", - "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": "155", - "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];\n\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" - ] - ] - }, - { - "id": "66debcf1.9d4ee4", - "type": "inject", - "z": "14ed22c2.6530bd", - "name": "", - "topic": "", - "payload": "", - "payloadType": "date", - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "x": 100, - "y": 680, - "wires": [ - [ - "bf9ce0f7.d63af" - ] - ] - }, - { - "id": "bf9ce0f7.d63af", - "type": "change", - "z": "14ed22c2.6530bd", - "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": "66d6fae3.416954", "type": "inject", @@ -3870,7 +2849,8 @@ "ec94685d.efd4b8" ], [ - "87a189d0.fb4808" + "87a189d0.fb4808", + "cf749675.a7b758" ] ] }, @@ -3970,7 +2950,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 multiplier = flow.get('multiplier');\nlet pair=flow.get(\"pair\");\nlet askPrice=Number(msg.payload[pair].a[0]);\nlet bidPrice=Number(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',Number(lastExecPrice),\"file\");\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n // when selling I am going with the floor, that is a bit more conservative; \n // buying fast selling slow\n let jumpSize = Math.floor(Math.abs(lastExecPrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n} else if (askPricemaxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n // when selling I am going with the floor, that is a bit more conservative; \n // buying fast selling slow\n let jumpSize = Math.floor(Math.abs(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\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": "price", - "propertyType": "msg", - "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": [ - [] - ] - }, { "id": "49b4c202.4977fc", "type": "inject", @@ -6261,7 +3958,8 @@ "7a72175a.7669e8" ], [ - "8ecf1845.71d1d8" + "8ecf1845.71d1d8", + "81c5ea58.e6a088" ] ] }, @@ -6361,7 +4059,7 @@ "type": "function", "z": "9d5ee7b4.680b68", "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 multiplier = flow.get('multiplier');\nlet pair=flow.get(\"pair\");\nlet askPrice=Number(msg.payload[pair].a[0]);\nlet bidPrice=Number(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',Number(lastExecPrice),\"file\");\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n // when selling I am going with the floor, that is a bit more conservative; \n // buying fast selling slow\n let jumpSize = Math.floor(Math.abs(lastExecPrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n} else if (askPricemaxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n // when selling I am going with the floor, that is a bit more conservative; \n // buying fast selling slow\n let jumpSize = Math.floor(Math.abs(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else if (askPricemaxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n // when selling I am going with the floor, that is a bit more conservative; \n // buying fast selling slow\n let jumpSize = Math.floor(Math.abs(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\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": [ + [ + "b1e44203.91c91" + ] + ] + }, + { + "id": "23eb6189.8565de", + "type": "function", + "z": "3fba07ea.b0acd8", + "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": [ + [ + "cbbd1581.37ad58" + ] + ] + }, + { + "id": "2ab676b7.975e1a", + "type": "function", + "z": "3fba07ea.b0acd8", + "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": [ + [ + "2745ccbb.120674" + ] + ] + }, + { + "id": "9331d935.466378", + "type": "catch", + "z": "3fba07ea.b0acd8", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "4c67d1ec.73dd4" + ] + ] + }, + { + "id": "4c67d1ec.73dd4", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "843d2cb7.525a7", + "type": "switch", + "z": "3fba07ea.b0acd8", + "name": "Max-Price?", + "property": "price", + "propertyType": "msg", + "rules": [ + { + "t": "lte", + "v": "maxBuyPrice", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1750, + "y": 760, + "wires": [ + [ + "52882f5b.86b19" + ], + [ + "2ebec1ce.99f26e" + ] + ] + }, + { + "id": "2ebec1ce.99f26e", + "type": "debug", + "z": "3fba07ea.b0acd8", + "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": "25e47f1f.a9a9d", + "type": "function", + "z": "3fba07ea.b0acd8", + "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": [ + [ + "8e66e1ce.08ca6" + ] + ] + }, + { + "id": "8e66e1ce.08ca6", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 310, + "y": 280, + "wires": [] + }, + { + "id": "95ab8523.4c0378", + "type": "inject", + "z": "3fba07ea.b0acd8", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 280, + "wires": [ + [ + "25e47f1f.a9a9d" + ] + ] + }, + { + "id": "d8e15d86.7f87f", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 900, + "y": 440, + "wires": [] + }, + { + "id": "e4eb7b53.5e1f48", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 770, + "y": 40, + "wires": [] + }, + { + "id": "3d3f5c03.2d8a74", + "type": "change", + "z": "3fba07ea.b0acd8", + "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": [ + [ + "5b03fb12.673c74" + ] + ] + }, + { + "id": "8c5facab.8b6e8", + "type": "function", + "z": "3fba07ea.b0acd8", + "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": "db1110d5.0860c", + "type": "function", + "z": "3fba07ea.b0acd8", + "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": "9a98519c.12f49", + "type": "add-standard-order", + "z": "3fba07ea.b0acd8", + "kraken": "e64b38bb.529c88", + "name": "Send Buy Order ", + "x": 2460, + "y": 720, + "wires": [ + [ + "258764e0.79d46c", + "db1110d5.0860c" + ], + [ + "87ccdbf2.f0c7f8" + ] + ] + }, + { + "id": "681dfe53.c121f", + "type": "function", + "z": "3fba07ea.b0acd8", + "name": "dynamic Currency To fix Key", + "func": "let currency=flow.get('currency');\n\nif (msg.payload[currency]!==undefined) {\n msg.payload.balance=Number(msg.payload[currency]);\n}\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 820, + "y": 80, + "wires": [ + [ + "d9fafdd1.9f6ef", + "974054cb.f3c458" + ] + ] + }, + { + "id": "974054cb.f3c458", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 1060, + "y": 40, + "wires": [] + }, + { + "id": "9bf486c9.b6b328", + "type": "debug", + "z": "3fba07ea.b0acd8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "x": 1380, + "y": 160, + "wires": [] + }, + { + "id": "5645cab6.8bf7c4", + "type": "inject", + "z": "3fba07ea.b0acd8", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "3600", + "crontab": "", + "once": true, + "onceDelay": "10", + "x": 450, + "y": 40, + "wires": [ + [ + "2c667cd5.5eac84" + ] + ] } ] \ No newline at end of file