Implemented Live trading based on swings.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"id": "6d543cb4.ed3084",
|
"id": "6d543cb4.ed3084",
|
||||||
"type": "tab",
|
"type": "tab",
|
||||||
"label": "Dynamic HF Trading",
|
"label": "Simulation Dynamic HF Trading",
|
||||||
"disabled": false,
|
"disabled": false,
|
||||||
"info": ""
|
"info": ""
|
||||||
},
|
},
|
||||||
@@ -27,6 +27,13 @@
|
|||||||
"disabled": false,
|
"disabled": false,
|
||||||
"info": ""
|
"info": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "75185287.024c5c",
|
||||||
|
"type": "tab",
|
||||||
|
"label": "LiveDynHF-ETC",
|
||||||
|
"disabled": false,
|
||||||
|
"info": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "af98615f.cf9ce",
|
"id": "af98615f.cf9ce",
|
||||||
"type": "subflow",
|
"type": "subflow",
|
||||||
@@ -157,7 +164,7 @@
|
|||||||
"topic": "",
|
"topic": "",
|
||||||
"payload": "{\"pair\":\"XETCZUSD\"}",
|
"payload": "{\"pair\":\"XETCZUSD\"}",
|
||||||
"payloadType": "json",
|
"payloadType": "json",
|
||||||
"repeat": "60",
|
"repeat": "",
|
||||||
"crontab": "",
|
"crontab": "",
|
||||||
"once": false,
|
"once": false,
|
||||||
"onceDelay": 0.1,
|
"onceDelay": 0.1,
|
||||||
@@ -554,10 +561,10 @@
|
|||||||
"type": "function",
|
"type": "function",
|
||||||
"z": "6d543cb4.ed3084",
|
"z": "6d543cb4.ed3084",
|
||||||
"name": "Determine Action",
|
"name": "Determine Action",
|
||||||
"func": "//$number(payload.XETCZUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.XETCZUSD.a[0];\nlet bidPrice=msg.payload.XETCZUSD.b[0];\nlet lastExecPrice=flow.get('lastExecPrice');\n\nmsg.lastExecPrice=lastExecPrice;\n\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPrice<lastExecPrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
"func": "//$number(payload.XETCZUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.XETCZUSD.a[0];\nlet bidPrice=msg.payload.XETCZUSD.b[0];\nlet lastExecPrice=flow.get('lastExecPrice');\nif (lastExecPrice === undefined) { \n lastExecPrice=askPrice; \n flow.set('lastExecPrice',lastExecPrice);\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPrice<lastExecPrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
||||||
"outputs": 1,
|
"outputs": 1,
|
||||||
"noerr": 0,
|
"noerr": 0,
|
||||||
"x": 1010,
|
"x": 990,
|
||||||
"y": 500,
|
"y": 500,
|
||||||
"wires": [
|
"wires": [
|
||||||
[
|
[
|
||||||
@@ -973,12 +980,12 @@
|
|||||||
"id": "47aba35f.ef005c",
|
"id": "47aba35f.ef005c",
|
||||||
"type": "inject",
|
"type": "inject",
|
||||||
"z": "5d834238.9ad88c",
|
"z": "5d834238.9ad88c",
|
||||||
"name": "",
|
"name": "Wednesdays, 10am",
|
||||||
"topic": "",
|
"topic": "",
|
||||||
"payload": "{\"pair\":\"XETHZUSD\"}",
|
"payload": "{\"pair\":\"XETHZUSD\"}",
|
||||||
"payloadType": "json",
|
"payloadType": "json",
|
||||||
"repeat": "",
|
"repeat": "",
|
||||||
"crontab": "",
|
"crontab": "00 10 * * 3",
|
||||||
"once": false,
|
"once": false,
|
||||||
"onceDelay": 0.1,
|
"onceDelay": 0.1,
|
||||||
"x": 200,
|
"x": 200,
|
||||||
@@ -1228,5 +1235,780 @@
|
|||||||
"d23ac766.df15d8"
|
"d23ac766.df15d8"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "46878dfa.5580c4",
|
||||||
|
"type": "inject",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"topic": "",
|
||||||
|
"payload": "{\"pair\":\"XETCZUSD\"}",
|
||||||
|
"payloadType": "json",
|
||||||
|
"repeat": "60",
|
||||||
|
"crontab": "",
|
||||||
|
"once": false,
|
||||||
|
"onceDelay": 0.1,
|
||||||
|
"x": 140,
|
||||||
|
"y": 420,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"8aa9f7f4.8c2668"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8aa9f7f4.8c2668",
|
||||||
|
"type": "switch",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "isInitialized?",
|
||||||
|
"property": "$flowContext('isInitialized')",
|
||||||
|
"propertyType": "jsonata",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "else"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"checkall": "true",
|
||||||
|
"repair": false,
|
||||||
|
"outputs": 2,
|
||||||
|
"x": 390,
|
||||||
|
"y": 420,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"69f7851b.bdc39c"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"a99eaee4.37596",
|
||||||
|
"21e109cf.713d56"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "55be5c77.c5aa24",
|
||||||
|
"type": "change",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "isInitialized",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "true",
|
||||||
|
"tot": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "coinBalance",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "payload.XETC",
|
||||||
|
"tot": "msg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "maxVolume",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "10",
|
||||||
|
"tot": "num"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "minVolume",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "0",
|
||||||
|
"tot": "str"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "delta",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "0.1",
|
||||||
|
"tot": "num"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "multiplier",
|
||||||
|
"pt": "flow",
|
||||||
|
"to": "8",
|
||||||
|
"tot": "str"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"action": "",
|
||||||
|
"property": "",
|
||||||
|
"from": "",
|
||||||
|
"to": "",
|
||||||
|
"reg": false,
|
||||||
|
"x": 1180,
|
||||||
|
"y": 80,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"89274697.2db938"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "a99eaee4.37596",
|
||||||
|
"type": "get-account-balance",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"kraken": "e64b38bb.529c88",
|
||||||
|
"name": "",
|
||||||
|
"x": 600,
|
||||||
|
"y": 120,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"df0504ca.1b5e68"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"d35cbfeb.3029",
|
||||||
|
"aceb2bba.402fa8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "df0504ca.1b5e68",
|
||||||
|
"type": "switch",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"property": "payload.XETC",
|
||||||
|
"propertyType": "msg",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "nempty"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "else"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"checkall": "true",
|
||||||
|
"repair": false,
|
||||||
|
"outputs": 2,
|
||||||
|
"x": 770,
|
||||||
|
"y": 80,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"55be5c77.c5aa24"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"957f8c8.49e1d7"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "957f8c8.49e1d7",
|
||||||
|
"type": "change",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "set",
|
||||||
|
"p": "payload.XETC",
|
||||||
|
"pt": "msg",
|
||||||
|
"to": "0",
|
||||||
|
"tot": "num"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"action": "",
|
||||||
|
"property": "",
|
||||||
|
"from": "",
|
||||||
|
"to": "",
|
||||||
|
"reg": false,
|
||||||
|
"x": 940,
|
||||||
|
"y": 120,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"55be5c77.c5aa24"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "89274697.2db938",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Initialized.",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 1370,
|
||||||
|
"y": 80,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "d35cbfeb.3029",
|
||||||
|
"type": "delay",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"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": [
|
||||||
|
[
|
||||||
|
"a99eaee4.37596"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "aceb2bba.402fa8",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Error getting Balance",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 890,
|
||||||
|
"y": 160,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "8072675b.525b98",
|
||||||
|
"type": "inject",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"topic": "",
|
||||||
|
"payload": "",
|
||||||
|
"payloadType": "date",
|
||||||
|
"repeat": "",
|
||||||
|
"crontab": "",
|
||||||
|
"once": false,
|
||||||
|
"onceDelay": 0.1,
|
||||||
|
"x": 100,
|
||||||
|
"y": 80,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"6a2a4e21.ffc76"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6a2a4e21.ffc76",
|
||||||
|
"type": "change",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "delete",
|
||||||
|
"p": "isInitialized",
|
||||||
|
"pt": "flow"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"action": "",
|
||||||
|
"property": "",
|
||||||
|
"from": "",
|
||||||
|
"to": "",
|
||||||
|
"reg": false,
|
||||||
|
"x": 340,
|
||||||
|
"y": 80,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "af95f15e.3e857",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Force-Uninitialize.",
|
||||||
|
"info": "",
|
||||||
|
"x": 110,
|
||||||
|
"y": 40,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "69f7851b.bdc39c",
|
||||||
|
"type": "get-ticker-information",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"x": 630,
|
||||||
|
"y": 640,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"24025058.051ac",
|
||||||
|
"d302c81.a8b0a38"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"a886187f.3229b8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "a886187f.3229b8",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Ticker Retrieval Error",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 890,
|
||||||
|
"y": 760,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1d957ceb.c40d73",
|
||||||
|
"type": "switch",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"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": [
|
||||||
|
[
|
||||||
|
"3e2250ef.405d5",
|
||||||
|
"b29e9a85.c0f208"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"800f6d47.f091b",
|
||||||
|
"cc5f7279.5f84b"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"7028479c.9a21b8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "3e2250ef.405d5",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "gt (sell)",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 1520,
|
||||||
|
"y": 600,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "800f6d47.f091b",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "lt (buy)",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 1520,
|
||||||
|
"y": 740,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "7028479c.9a21b8",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "small diff (nothing)",
|
||||||
|
"active": false,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 1560,
|
||||||
|
"y": 900,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b29e9a85.c0f208",
|
||||||
|
"type": "switch",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "MinReached?",
|
||||||
|
"property": "currVolume",
|
||||||
|
"propertyType": "flow",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "gt",
|
||||||
|
"v": "minVolume",
|
||||||
|
"vt": "flow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "else"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"checkall": "true",
|
||||||
|
"repair": false,
|
||||||
|
"outputs": 2,
|
||||||
|
"x": 1540,
|
||||||
|
"y": 640,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"277a2c5d.908d54"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"be56cf39.afb4e"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "24a6d9cc.fc2466",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Not Selling, min Volume reached.",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 2000,
|
||||||
|
"y": 640,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "52986989.ee2b38",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "SELLING!",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 1950,
|
||||||
|
"y": 500,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "a25291a9.35e33",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "BUYING!",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 1970,
|
||||||
|
"y": 700,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "cc5f7279.5f84b",
|
||||||
|
"type": "switch",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "MaxReached?",
|
||||||
|
"property": "currVolume",
|
||||||
|
"propertyType": "flow",
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"t": "lt",
|
||||||
|
"v": "maxVolume",
|
||||||
|
"vt": "flow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"t": "else"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"checkall": "true",
|
||||||
|
"repair": false,
|
||||||
|
"outputs": 2,
|
||||||
|
"x": 1540,
|
||||||
|
"y": 780,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"6e38bc3.4922b44"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"b770e41f.d48838"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "c3c9ab5b.c535c8",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Not buying, max Volume reached.",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "payload",
|
||||||
|
"targetType": "msg",
|
||||||
|
"x": 2030,
|
||||||
|
"y": 800,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "24025058.051ac",
|
||||||
|
"type": "function",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Determine Action",
|
||||||
|
"func": "//$number(payload.XETCZUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.XETCZUSD.a[0];\nlet bidPrice=msg.payload.XETCZUSD.b[0];\nlet lastExecPrice=flow.get('lastExecPrice');\nif (lastExecPrice === undefined) { \n lastExecPrice=askPrice; \n flow.set('lastExecPrice',lastExecPrice);\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPrice<lastExecPrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 910,
|
||||||
|
"y": 680,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"1d957ceb.c40d73"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6e38bc3.4922b44",
|
||||||
|
"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;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 1740,
|
||||||
|
"y": 740,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"b13db4ef.65a078",
|
||||||
|
"a25291a9.35e33",
|
||||||
|
"ab124111.85da6"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "be56cf39.afb4e",
|
||||||
|
"type": "function",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "NoSellAction",
|
||||||
|
"func": "let sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\nflow.set('lastExecPrice',sellPrice);\n\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 1770,
|
||||||
|
"y": 640,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"24a6d9cc.fc2466"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b770e41f.d48838",
|
||||||
|
"type": "function",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "NoBuyAction",
|
||||||
|
"func": "let buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\nflow.set('lastExecPrice',buyPrice);\n\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 1750,
|
||||||
|
"y": 800,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"c3c9ab5b.c535c8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "277a2c5d.908d54",
|
||||||
|
"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;",
|
||||||
|
"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",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"mydb": "c0dcbde0.3085",
|
||||||
|
"sqlquery": "msg.topic",
|
||||||
|
"sql": "",
|
||||||
|
"name": "",
|
||||||
|
"x": 1150,
|
||||||
|
"y": 500,
|
||||||
|
"wires": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "d302c81.a8b0a38",
|
||||||
|
"type": "function",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Build Insert Statement",
|
||||||
|
"func": "msg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('XETCZUSD','\" + JSON.stringify(msg.payload.XETCZUSD) + \"');\"\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 860,
|
||||||
|
"y": 540,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"b134e494.b4e6c8",
|
||||||
|
"f637b849.b81cd8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b134e494.b4e6c8",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "",
|
||||||
|
"active": false,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": false,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 1090,
|
||||||
|
"y": 560,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fcc5965e.257558",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Initialization",
|
||||||
|
"info": "",
|
||||||
|
"x": 510,
|
||||||
|
"y": 300,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "52d1add7.1a1144",
|
||||||
|
"type": "comment",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Regular Looping",
|
||||||
|
"info": "",
|
||||||
|
"x": 520,
|
||||||
|
"y": 580,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ab124111.85da6",
|
||||||
|
"type": "add-standard-order",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"d": true,
|
||||||
|
"kraken": "e64b38bb.529c88",
|
||||||
|
"name": "",
|
||||||
|
"x": 2410,
|
||||||
|
"y": 680,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"1191bbfb.c728d4"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"96991058.9ed6d"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1191bbfb.c728d4",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Order Execution Success",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 2650,
|
||||||
|
"y": 660,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "96991058.9ed6d",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Order Execution Error",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 2650,
|
||||||
|
"y": 700,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "21e109cf.713d56",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "75185287.024c5c",
|
||||||
|
"name": "Needs Initialization",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"console": true,
|
||||||
|
"tostatus": false,
|
||||||
|
"complete": "true",
|
||||||
|
"targetType": "full",
|
||||||
|
"x": 640,
|
||||||
|
"y": 220,
|
||||||
|
"wires": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user