From 468124421d22320f16e38c4104beb5fd26b85712 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Thu, 7 Jan 2021 16:39:14 -0600 Subject: [PATCH] misc fixes in volume calc --- flows_nodered_kraken.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flows_nodered_kraken.json b/flows_nodered_kraken.json index f90e71f..f86a775 100644 --- a/flows_nodered_kraken.json +++ b/flows_nodered_kraken.json @@ -3969,7 +3969,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 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\nlet jumpPrice=undefined;\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=jumpPrice=bidPrice;\n} else if (askPricelastExecPrice+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 (askPricelastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=jumpPrice=bidPrice;\n} else if (askPricelastExecPrice+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 (askPrice