From 9a8e7196be0cae315932045046e25a08dcb93ef4 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Sun, 12 Jan 2020 15:25:58 -0600 Subject: [PATCH] Consider maximum buy price --- flows_nodered_kraken.json | 117 ++++++++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 17 deletions(-) diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index 08fabb5..69ef6c9 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -1333,6 +1333,13 @@ "pt": "flow", "to": "10", "tot": "num" + }, + { + "t": "set", + "p": "maxBuyPrice", + "pt": "flow", + "to": "6", + "tot": "num" } ], "action": "", @@ -1627,7 +1634,7 @@ "tostatus": false, "complete": "true", "targetType": "full", - "x": 1760, + "x": 1720, "y": 880, "wires": [] }, @@ -1650,7 +1657,7 @@ "id": "b29e9a85.c0f208", "type": "switch", "z": "75185287.024c5c", - "name": "MinReached?", + "name": "MinVolReached?", "property": "$flowContext('coinBalance') - $flowContext('multiplier') ", "propertyType": "jsonata", "rules": [ @@ -1666,8 +1673,8 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 1540, - "y": 640, + "x": 1510, + "y": 620, "wires": [ [ "277a2c5d.908d54" @@ -1703,7 +1710,7 @@ "tostatus": false, "complete": "payload", "targetType": "msg", - "x": 2010, + "x": 1990, "y": 560, "wires": [] }, @@ -1718,15 +1725,15 @@ "tostatus": false, "complete": "payload", "targetType": "msg", - "x": 2010, - "y": 760, + "x": 2190, + "y": 720, "wires": [] }, { "id": "cc5f7279.5f84b", "type": "switch", "z": "75185287.024c5c", - "name": "MaxReached?", + "name": "MaxVolReached?", "property": "$flowContext('coinBalance') + $flowContext('multiplier')", "propertyType": "jsonata", "rules": [ @@ -1742,11 +1749,11 @@ "checkall": "true", "repair": false, "outputs": 2, - "x": 1540, + "x": 1510, "y": 800, "wires": [ [ - "6e38bc3.4922b44" + "7b6cd46f.5195fc" ], [ "b770e41f.d48838" @@ -1764,8 +1771,8 @@ "tostatus": false, "complete": "payload", "targetType": "msg", - "x": 2030, - "y": 820, + "x": 2170, + "y": 840, "wires": [] }, { @@ -1792,8 +1799,8 @@ "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": 760, + "x": 1940, + "y": 720, "wires": [ [ "a25291a9.35e33", @@ -1825,8 +1832,8 @@ "func": "let buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\nflow.set('lastExecPrice',buyPrice);\n\nreturn msg;", "outputs": 1, "noerr": 0, - "x": 1750, - "y": 820, + "x": 1890, + "y": 840, "wires": [ [ "c3c9ab5b.c535c8" @@ -2047,7 +2054,7 @@ "func": "msg.flowContext = {};\nflow.keys().forEach(ele=>{\n msg.flowContext[ele]=flow.get(ele);\n});\nreturn msg;", "outputs": 1, "noerr": 0, - "x": 1550, + "x": 1510, "y": 880, "wires": [ [ @@ -2070,5 +2077,81 @@ "7028479c.9a21b8" ] ] + }, + { + "id": "94f8bbad.d99128", + "type": "catch", + "z": "75185287.024c5c", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "d9b37b29.d69da8" + ] + ] + }, + { + "id": "d9b37b29.d69da8", + "type": "debug", + "z": "75185287.024c5c", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "7b6cd46f.5195fc", + "type": "switch", + "z": "75185287.024c5c", + "name": "Max-Price?", + "property": "$number(payload.XETCZUSD.a[0])", + "propertyType": "jsonata", + "rules": [ + { + "t": "lte", + "v": "maxBuyPrice", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1750, + "y": 760, + "wires": [ + [ + "6e38bc3.4922b44" + ], + [ + "27f3e6cf.40475a" + ] + ] + }, + { + "id": "27f3e6cf.40475a", + "type": "debug", + "z": "75185287.024c5c", + "name": "Not Buying, max buy price exceeded.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 2040, + "y": 780, + "wires": [] } ] \ No newline at end of file