From ac2bc957bf8781460fdecb7039770a0ef701ce38 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Wed, 8 Jan 2020 21:47:16 -0600 Subject: [PATCH] some fixes on the autotrading side --- flows_nodered_kraken.json | 108 +++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index 10a3719..65c6610 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -1318,7 +1318,7 @@ "p": "minVolume", "pt": "flow", "to": "0", - "tot": "str" + "tot": "num" }, { "t": "set", @@ -1331,8 +1331,8 @@ "t": "set", "p": "multiplier", "pt": "flow", - "to": "8", - "tot": "str" + "to": "1", + "tot": "num" } ], "action": "", @@ -1464,14 +1464,14 @@ "id": "aceb2bba.402fa8", "type": "debug", "z": "75185287.024c5c", - "name": "Error getting Balance", + "name": "Error getting Balance - retrying infinite.", "active": true, "tosidebar": true, "console": true, "tostatus": false, "complete": "true", "targetType": "full", - "x": 890, + "x": 940, "y": 160, "wires": [] }, @@ -1522,9 +1522,9 @@ "id": "af95f15e.3e857", "type": "comment", "z": "75185287.024c5c", - "name": "Force-Uninitialize.", + "name": "Force-Uninitialize (Reload settings)", "info": "", - "x": 110, + "x": 160, "y": 40, "wires": [] }, @@ -1651,11 +1651,11 @@ "type": "switch", "z": "75185287.024c5c", "name": "MinReached?", - "property": "currVolume", - "propertyType": "flow", + "property": " $flowContext('multiplier') - $flowContext('coinBalance') ", + "propertyType": "jsonata", "rules": [ { - "t": "gt", + "t": "gte", "v": "minVolume", "vt": "flow" }, @@ -1727,11 +1727,11 @@ "type": "switch", "z": "75185287.024c5c", "name": "MaxReached?", - "property": "currVolume", - "propertyType": "flow", + "property": "$flowContext('coinBalance') + $flowContext('multiplier')", + "propertyType": "jsonata", "rules": [ { - "t": "lt", + "t": "lte", "v": "maxVolume", "vt": "flow" }, @@ -1789,14 +1789,13 @@ "type": "function", "z": "75185287.024c5c", "name": "BuyAction", - "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\n\nlet buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\ncoinBalance += 1;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : Number(flow.get('multiplier'))\n};\n\nreturn msg;", + "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1740, "y": 740, "wires": [ [ - "b13db4ef.65a078", "a25291a9.35e33", "ab124111.85da6" ] @@ -1839,49 +1838,18 @@ "type": "function", "z": "75185287.024c5c", "name": "SellAction", - "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\n\nlet sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\ncoinBalance -= 1;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : Number(flow.get('multiplier'))\n};\n\nreturn msg;", + "func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\n\nlet sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 1760, "y": 560, "wires": [ [ - "39e6c932.e87666", "52986989.ee2b38", "ab124111.85da6" ] ] }, - { - "id": "39e6c932.e87666", - "type": "debug", - "z": "75185287.024c5c", - "name": "DUMMY SELL", - "active": true, - "tosidebar": true, - "console": true, - "tostatus": false, - "complete": "payload", - "targetType": "msg", - "x": 1960, - "y": 560, - "wires": [] - }, - { - "id": "b13db4ef.65a078", - "type": "debug", - "z": "75185287.024c5c", - "name": "DUMMY BUY", - "active": true, - "tosidebar": true, - "console": true, - "tostatus": false, - "complete": "payload", - "targetType": "msg", - "x": 1990, - "y": 740, - "wires": [] - }, { "id": "f637b849.b81cd8", "type": "sqlite", @@ -1952,7 +1920,6 @@ "id": "ab124111.85da6", "type": "add-standard-order", "z": "75185287.024c5c", - "d": true, "kraken": "e64b38bb.529c88", "name": "", "x": 2410, @@ -2010,5 +1977,50 @@ "x": 640, "y": 220, "wires": [] + }, + { + "id": "bfbcb0ec.f032c", + "type": "debug", + "z": "75185287.024c5c", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "$flowContext('coinBalance') / $flowContext('multiplier')", + "targetType": "jsonata", + "x": 300, + "y": 200, + "wires": [] + }, + { + "id": "8b60b992.9a6258", + "type": "inject", + "z": "75185287.024c5c", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 110, + "y": 200, + "wires": [ + [ + "bfbcb0ec.f032c" + ] + ] + }, + { + "id": "72e50f95.f5f68", + "type": "comment", + "z": "75185287.024c5c", + "name": "Get current \"standardized balance\"", + "info": "", + "x": 160, + "y": 140, + "wires": [] } ] \ No newline at end of file