From 16ba70335e8e989978a1784cb04dbc47e804df47 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Mon, 30 Nov 2020 11:38:12 -0600 Subject: [PATCH] add dot and misc changes --- flows_nodered_kraken.json | 1150 ++++++++++++++++++++++++++++++++++++- 1 file changed, 1146 insertions(+), 4 deletions(-) diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index 17811ad..9c63454 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -9,7 +9,7 @@ { "id": "5d834238.9ad88c", "type": "tab", - "label": "Weekly Ethereum buy", + "label": "Cyclic buy", "disabled": false, "info": "" }, @@ -34,6 +34,13 @@ "disabled": false, "info": "" }, + { + "id": "5b601c88.f89c94", + "type": "tab", + "label": "LiveDynHF-DOT", + "disabled": false, + "info": "" + }, { "id": "af98615f.cf9ce", "type": "subflow", @@ -1310,7 +1317,7 @@ "t": "set", "p": "maxVolume", "pt": "flow", - "to": "100", + "to": "2000", "tot": "num" }, { @@ -1331,14 +1338,14 @@ "t": "set", "p": "multiplier", "pt": "flow", - "to": "10", + "to": "50", "tot": "num" }, { "t": "set", "p": "maxBuyPrice", "pt": "flow", - "to": "6", + "to": "7", "tot": "num" } ], @@ -2204,5 +2211,1140 @@ "d733ac19.e8d0b" ] ] + }, + { + "id": "b270d15c.78ca6", + "type": "get-ticker-information", + "z": "5d834238.9ad88c", + "name": "", + "x": 410, + "y": 600, + "wires": [ + [ + "b6e0a61e.2e75e8", + "d260895.83a5278" + ], + [ + "f18ee89a.2792e8" + ] + ] + }, + { + "id": "a628006.a5022", + "type": "inject", + "z": "5d834238.9ad88c", + "name": "Wednesdays, 10:30am", + "topic": "", + "payload": "{\"pair\":\"XXBTZUSD\"}", + "payloadType": "json", + "repeat": "", + "crontab": "30 10 * * 3", + "once": false, + "onceDelay": 0.1, + "x": 190, + "y": 600, + "wires": [ + [ + "b270d15c.78ca6" + ] + ] + }, + { + "id": "b6e0a61e.2e75e8", + "type": "debug", + "z": "5d834238.9ad88c", + "name": "Ticker Output", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 650, + "y": 580, + "wires": [] + }, + { + "id": "f18ee89a.2792e8", + "type": "debug", + "z": "5d834238.9ad88c", + "name": "Error getting Ticker", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 670, + "y": 660, + "wires": [] + }, + { + "id": "d260895.83a5278", + "type": "function", + "z": "5d834238.9ad88c", + "name": "compute order", + "func": "let askPrice = msg.payload.XXBTZUSD.a[0] - 50;\nlet volume2Buy = 250/askPrice; // How much Crypto-currency to buy for the USD-Amount?\nnode.log(\"Ask Price \", askPrice, \" --> Volume : \", volume2Buy );\n\nmsg.payload={\n\tpair : 'XXBTZUSD',\n\ttype : 'buy',\n\tordertype : 'limit',\n\tprice : askPrice,\n\tvolume : volume2Buy\n};\n\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 670, + "y": 620, + "wires": [ + [ + "d3b9fc5e.4f0a", + "ec82d6e6.92e9b8" + ] + ] + }, + { + "id": "d3b9fc5e.4f0a", + "type": "add-standard-order", + "z": "5d834238.9ad88c", + "kraken": "e64b38bb.529c88", + "name": "", + "x": 880, + "y": 620, + "wires": [ + [ + "3e4a4fc2.6d5e9" + ], + [ + "a1f76098.67548" + ] + ] + }, + { + "id": "3e4a4fc2.6d5e9", + "type": "debug", + "z": "5d834238.9ad88c", + "name": "Order Execution Success", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1120, + "y": 600, + "wires": [] + }, + { + "id": "a1f76098.67548", + "type": "debug", + "z": "5d834238.9ad88c", + "name": "Order Execution Error", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1120, + "y": 640, + "wires": [] + }, + { + "id": "ec82d6e6.92e9b8", + "type": "debug", + "z": "5d834238.9ad88c", + "name": "Computed Order", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 900, + "y": 520, + "wires": [] + }, + { + "id": "d4797497.421e58", + "type": "comment", + "z": "5d834238.9ad88c", + "name": "Bitcoin", + "info": "", + "x": 130, + "y": 500, + "wires": [] + }, + { + "id": "8e1f7774.980a78", + "type": "comment", + "z": "5d834238.9ad88c", + "name": "Ethereum", + "info": "", + "x": 140, + "y": 160, + "wires": [] + }, + { + "id": "58579544.f37b3c", + "type": "inject", + "z": "5b601c88.f89c94", + "name": "", + "topic": "", + "payload": "{\"pair\":\"DOTUSD\"}", + "payloadType": "json", + "repeat": "60", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 140, + "y": 420, + "wires": [ + [ + "d7b63da9.2bb59" + ] + ] + }, + { + "id": "d7b63da9.2bb59", + "type": "switch", + "z": "5b601c88.f89c94", + "name": "isInitialized?", + "property": "$flowContext('isInitialized')", + "propertyType": "jsonata", + "rules": [ + { + "t": "true" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 390, + "y": 420, + "wires": [ + [ + "abf002df.739e3" + ], + [ + "8b491ba9.c3a698", + "f2b11b31.7f5da8" + ] + ] + }, + { + "id": "88587e0f.eac9c", + "type": "change", + "z": "5b601c88.f89c94", + "name": "", + "rules": [ + { + "t": "set", + "p": "isInitialized", + "pt": "flow", + "to": "true", + "tot": "bool" + }, + { + "t": "set", + "p": "coinBalance", + "pt": "flow", + "to": "$number(payload.DOT)", + "tot": "jsonata" + }, + { + "t": "set", + "p": "maxVolume", + "pt": "flow", + "to": "2000", + "tot": "num" + }, + { + "t": "set", + "p": "minVolume", + "pt": "flow", + "to": "0", + "tot": "num" + }, + { + "t": "set", + "p": "delta", + "pt": "flow", + "to": "0.1", + "tot": "num" + }, + { + "t": "set", + "p": "multiplier", + "pt": "flow", + "to": "50", + "tot": "num" + }, + { + "t": "set", + "p": "maxBuyPrice", + "pt": "flow", + "to": "6", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 1180, + "y": 80, + "wires": [ + [ + "b66be511.a0f338" + ] + ] + }, + { + "id": "8b491ba9.c3a698", + "type": "get-account-balance", + "z": "5b601c88.f89c94", + "kraken": "e64b38bb.529c88", + "name": "", + "x": 600, + "y": 120, + "wires": [ + [ + "4a856293.dd87cc" + ], + [ + "bb739ef2.fee7c", + "706e9cfb.7d54d4" + ] + ] + }, + { + "id": "4a856293.dd87cc", + "type": "switch", + "z": "5b601c88.f89c94", + "name": "", + "property": "payload.DOT", + "propertyType": "msg", + "rules": [ + { + "t": "nempty" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 770, + "y": 80, + "wires": [ + [ + "88587e0f.eac9c" + ], + [ + "7445376b.9e1808" + ] + ] + }, + { + "id": "7445376b.9e1808", + "type": "change", + "z": "5b601c88.f89c94", + "name": "", + "rules": [ + { + "t": "set", + "p": "payload.DOT", + "pt": "msg", + "to": "0", + "tot": "num" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 940, + "y": 120, + "wires": [ + [ + "88587e0f.eac9c" + ] + ] + }, + { + "id": "b66be511.a0f338", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "Initialized.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 1370, + "y": 80, + "wires": [] + }, + { + "id": "bb739ef2.fee7c", + "type": "delay", + "z": "5b601c88.f89c94", + "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": [ + [ + "8b491ba9.c3a698" + ] + ] + }, + { + "id": "706e9cfb.7d54d4", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "Error getting Balance - retrying infinite.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 940, + "y": 160, + "wires": [] + }, + { + "id": "92dd5eb3.ed94f", + "type": "inject", + "z": "5b601c88.f89c94", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 80, + "wires": [ + [ + "5aab0d70.d6d174" + ] + ] + }, + { + "id": "5aab0d70.d6d174", + "type": "change", + "z": "5b601c88.f89c94", + "name": "", + "rules": [ + { + "t": "delete", + "p": "isInitialized", + "pt": "flow" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 340, + "y": 80, + "wires": [ + [] + ] + }, + { + "id": "9ed4aaad.a665d8", + "type": "comment", + "z": "5b601c88.f89c94", + "name": "Force-Uninitialize (Reload settings)", + "info": "", + "x": 160, + "y": 40, + "wires": [] + }, + { + "id": "abf002df.739e3", + "type": "get-ticker-information", + "z": "5b601c88.f89c94", + "name": "", + "x": 630, + "y": 640, + "wires": [ + [ + "f3ad0be8.2124f8", + "dc364cac.c8885" + ], + [ + "eec1a78.8265558" + ] + ] + }, + { + "id": "eec1a78.8265558", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "Ticker Retrieval Error", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 890, + "y": 760, + "wires": [] + }, + { + "id": "615d2f89.216e2", + "type": "switch", + "z": "5b601c88.f89c94", + "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": [ + [ + "9cc315f6.237678", + "1e0e13fa.b2671c" + ], + [ + "f3cf4376.2eed6", + "e1896e34.2c727" + ], + [ + "75cc2515.20821c" + ] + ] + }, + { + "id": "f81c652f.62b1b8", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "gt (sell)", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1740, + "y": 520, + "wires": [] + }, + { + "id": "7a0280e6.a6694", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "lt (buy)", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1720, + "y": 880, + "wires": [] + }, + { + "id": "1c21bacf.c10215", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "small diff (nothing)", + "active": false, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 1800, + "y": 1060, + "wires": [] + }, + { + "id": "9cc315f6.237678", + "type": "switch", + "z": "5b601c88.f89c94", + "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": [ + [ + "bcc2295e.e1e198" + ], + [ + "57b4e5da.a8dedc" + ] + ] + }, + { + "id": "5122dba4.2f46b4", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "Not Selling, min Volume reached.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2000, + "y": 640, + "wires": [] + }, + { + "id": "7795f775.712988", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "SELLING!", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 1990, + "y": 560, + "wires": [] + }, + { + "id": "3f4bce34.ba9772", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "BUYING!", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2190, + "y": 720, + "wires": [] + }, + { + "id": "f3cf4376.2eed6", + "type": "switch", + "z": "5b601c88.f89c94", + "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": [ + [ + "1aa69cdc.b7d923" + ], + [ + "443994b5.e4cfcc" + ] + ] + }, + { + "id": "f4682271.e52a7", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "Not buying, max Volume reached.", + "active": true, + "tosidebar": true, + "console": true, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "x": 2170, + "y": 840, + "wires": [] + }, + { + "id": "f3ad0be8.2124f8", + "type": "function", + "z": "5b601c88.f89c94", + "name": "Determine Action", + "func": "//$number(payload.DOTUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.DOTUSD.a[0];\nlet bidPrice=msg.payload.DOTUSD.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": [ + [ + "f81c652f.62b1b8" + ] + ] + }, + { + "id": "e1896e34.2c727", + "type": "function", + "z": "5b601c88.f89c94", + "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": [ + [ + "7a0280e6.a6694" + ] + ] + }, + { + "id": "75cc2515.20821c", + "type": "function", + "z": "5b601c88.f89c94", + "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": [ + [ + "1c21bacf.c10215" + ] + ] + }, + { + "id": "cdc5d8b3.33ed78", + "type": "catch", + "z": "5b601c88.f89c94", + "name": "", + "scope": null, + "uncaught": false, + "x": 220, + "y": 980, + "wires": [ + [ + "ba8a4005.4d38e" + ] + ] + }, + { + "id": "ba8a4005.4d38e", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "ERROR!!!", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 470, + "y": 980, + "wires": [] + }, + { + "id": "1aa69cdc.b7d923", + "type": "switch", + "z": "5b601c88.f89c94", + "name": "Max-Price?", + "property": "$number(payload.DOTUSD.a[0])", + "propertyType": "jsonata", + "rules": [ + { + "t": "lte", + "v": "maxBuyPrice", + "vt": "flow" + }, + { + "t": "else" + } + ], + "checkall": "true", + "repair": false, + "outputs": 2, + "x": 1750, + "y": 760, + "wires": [ + [ + "4919fa9e.7087b4" + ], + [ + "f50872aa.54f45" + ] + ] + }, + { + "id": "f50872aa.54f45", + "type": "debug", + "z": "5b601c88.f89c94", + "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": "ba00b0ab.a251b", + "type": "function", + "z": "5b601c88.f89c94", + "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": [ + [ + "46f90e14.9cde6" + ] + ] + }, + { + "id": "46f90e14.9cde6", + "type": "debug", + "z": "5b601c88.f89c94", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "true", + "targetType": "full", + "x": 310, + "y": 280, + "wires": [] + }, + { + "id": "8f6456e7.abc808", + "type": "inject", + "z": "5b601c88.f89c94", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "x": 100, + "y": 280, + "wires": [ + [ + "ba00b0ab.a251b" + ] + ] } ] \ No newline at end of file