5869 lines
148 KiB
JSON
5869 lines
148 KiB
JSON
[
|
|
{
|
|
"id": "6d543cb4.ed3084",
|
|
"type": "tab",
|
|
"label": "Simulation Dynamic HF Trading",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "5d834238.9ad88c",
|
|
"type": "tab",
|
|
"label": "Cyclic buy",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "d8e8a587.a39408",
|
|
"type": "tab",
|
|
"label": "HTML Queries",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "e67f589a.f8d378",
|
|
"type": "tab",
|
|
"label": "Misc",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "5b601c88.f89c94",
|
|
"type": "tab",
|
|
"label": "LiveDynHF-DOT",
|
|
"disabled": true,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "791ce869.901798",
|
|
"type": "tab",
|
|
"label": "LiveDynHF-NG-XMR",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "9d5ee7b4.680b68",
|
|
"type": "tab",
|
|
"label": "LiveDynHF-NG-ETC",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "3fba07ea.b0acd8",
|
|
"type": "tab",
|
|
"label": "LiveDynHF-NG-DOT",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "af98615f.cf9ce",
|
|
"type": "subflow",
|
|
"name": "DB Data to HTML Table",
|
|
"info": "",
|
|
"category": "",
|
|
"in": [
|
|
{
|
|
"x": 20,
|
|
"y": 80,
|
|
"wires": [
|
|
{
|
|
"id": "3ff8fa1b.3148f6"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"out": [
|
|
{
|
|
"x": 320,
|
|
"y": 240,
|
|
"wires": [
|
|
{
|
|
"id": "71b8fd74.2d9404",
|
|
"port": 0
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"env": [],
|
|
"color": "#DDAA99"
|
|
},
|
|
{
|
|
"id": "42702610.230028",
|
|
"type": "kraken-credentials",
|
|
"z": "",
|
|
"name": "DFLT"
|
|
},
|
|
{
|
|
"id": "c0dcbde0.3085",
|
|
"type": "sqlitedb",
|
|
"z": "",
|
|
"db": "KrakenTradingDB.sqlite3",
|
|
"mode": "RW"
|
|
},
|
|
{
|
|
"id": "4378beea.a2c7f",
|
|
"type": "sqlitedb",
|
|
"z": "",
|
|
"db": "KrakenTradingDB.sqlite3",
|
|
"mode": "RWC"
|
|
},
|
|
{
|
|
"id": "e64b38bb.529c88",
|
|
"type": "kraken-credentials",
|
|
"z": "",
|
|
"name": "DFLT"
|
|
},
|
|
{
|
|
"id": "a669c08c.d0185",
|
|
"type": "sqlite",
|
|
"z": "6d543cb4.ed3084",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 1010,
|
|
"y": 120,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "4f94e60f.4d3838",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"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": 720,
|
|
"y": 160,
|
|
"wires": [
|
|
[
|
|
"853572da.0b0bf",
|
|
"a669c08c.d0185"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "853572da.0b0bf",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 950,
|
|
"y": 180,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "b6c88df3.41573",
|
|
"type": "get-ticker-information",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"x": 470,
|
|
"y": 440,
|
|
"wires": [
|
|
[
|
|
"8f27b1c3.3277e",
|
|
"1a447d86.305162",
|
|
"4f94e60f.4d3838"
|
|
],
|
|
[
|
|
"57c6ead4.4943d4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b131c158.9b6e5",
|
|
"type": "inject",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "{\"pair\":\"XETCZUSD\"}",
|
|
"payloadType": "json",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 280,
|
|
"y": 440,
|
|
"wires": [
|
|
[
|
|
"b6c88df3.41573"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8f27b1c3.3277e",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 710,
|
|
"y": 280,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "57c6ead4.4943d4",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Ticker Retrieval Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 630,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1a447d86.305162",
|
|
"type": "switch",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Initialization Needed?",
|
|
"property": "lastExecPrice",
|
|
"propertyType": "flow",
|
|
"rules": [
|
|
{
|
|
"t": "null"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 680,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"b14715f9.da01b8"
|
|
],
|
|
[
|
|
"746dd800.489408",
|
|
"3fcb4bfe.6d4b84"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b14715f9.da01b8",
|
|
"type": "change",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "lastExecPrice",
|
|
"pt": "flow",
|
|
"to": "payload.XETCZUSD.a[0]",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxVolume",
|
|
"pt": "flow",
|
|
"to": "10",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "minVolume",
|
|
"pt": "flow",
|
|
"to": "0",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "currVolume",
|
|
"pt": "flow",
|
|
"to": "0",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "delta",
|
|
"pt": "flow",
|
|
"to": "0.1",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "grosBalance",
|
|
"pt": "flow",
|
|
"to": "0",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "commission",
|
|
"pt": "flow",
|
|
"to": "0",
|
|
"tot": "num"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "acctBalance",
|
|
"pt": "flow",
|
|
"to": "100",
|
|
"tot": "num"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 960,
|
|
"y": 360,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "713645b4.f9ba7c",
|
|
"type": "switch",
|
|
"z": "6d543cb4.ed3084",
|
|
"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": 1170,
|
|
"y": 500,
|
|
"wires": [
|
|
[
|
|
"8fc8be9f.e3552",
|
|
"894f2795.914b38"
|
|
],
|
|
[
|
|
"9073f8dd.8a8558",
|
|
"e961895.42ab678"
|
|
],
|
|
[
|
|
"1bc0ea09.db8676"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8fc8be9f.e3552",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "gt (Sell)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1520,
|
|
"y": 420,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9073f8dd.8a8558",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "lt (buy)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1520,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1bc0ea09.db8676",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "small",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1490,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "746dd800.489408",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "{\"le\":$flowContext('lastExecPrice'),\"cp\":payload.XETCZUSD.a[0] }",
|
|
"targetType": "jsonata",
|
|
"x": 880,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "37af9cb0.cd7d74",
|
|
"type": "inject",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 780,
|
|
"y": 340,
|
|
"wires": [
|
|
[
|
|
"b14715f9.da01b8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "894f2795.914b38",
|
|
"type": "switch",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "MinReached?",
|
|
"property": "currVolume",
|
|
"propertyType": "flow",
|
|
"rules": [
|
|
{
|
|
"t": "gt",
|
|
"v": "minVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1620,
|
|
"y": 460,
|
|
"wires": [
|
|
[
|
|
"db4dcb29.89cd38",
|
|
"7a524b14.ab2ea4"
|
|
],
|
|
[
|
|
"c6b046f0.da94b8",
|
|
"10898ef6.fab381"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c6b046f0.da94b8",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Not Selling, min Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1920,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "db4dcb29.89cd38",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "SELLING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1850,
|
|
"y": 420,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9ff35104.7db0d",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "BUYING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1830,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e961895.42ab678",
|
|
"type": "switch",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "MaxReached?",
|
|
"property": "currVolume",
|
|
"propertyType": "flow",
|
|
"rules": [
|
|
{
|
|
"t": "lt",
|
|
"v": "maxVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1620,
|
|
"y": 600,
|
|
"wires": [
|
|
[
|
|
"9ff35104.7db0d",
|
|
"11de6ea9.7cbab1"
|
|
],
|
|
[
|
|
"cf8bb8be.0de778",
|
|
"b1857f61.f3b9a"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "cf8bb8be.0de778",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Not buying, max Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1910,
|
|
"y": 660,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "3fcb4bfe.6d4b84",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"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": 990,
|
|
"y": 500,
|
|
"wires": [
|
|
[
|
|
"713645b4.f9ba7c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7a524b14.ab2ea4",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "SellAction",
|
|
"func": "let commission = flow.get('commission');\nlet grosBalance = flow.get('grosBalance');\nlet acctBalance = flow.get('acctBalance');\nlet delta = flow.get('delta');\n\nlet sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\ncommission += sellPrice*0.0026;\ngrosBalance -= 1;\nacctBalance += sellPrice;\n\nflow.set('commission',commission);\nflow.set('grosBalance',grosBalance);\nflow.set('acctBalance',acctBalance);\n\nflow.set('lastExecPrice',sellPrice);\nflow.set('currVolume',flow.get('currVolume')-1);\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1830,
|
|
"y": 380,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "11de6ea9.7cbab1",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "BuyAction",
|
|
"func": "let commission = flow.get('commission');\nlet grosBalance = flow.get('grosBalance');\nlet acctBalance = flow.get('acctBalance');\nlet delta = flow.get('delta');\n\nlet buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\ncommission += buyPrice*0.0026;\ngrosBalance += 1;\nacctBalance -= buyPrice;\n\nflow.set('commission',commission);\nflow.set('grosBalance',grosBalance);\nflow.set('acctBalance',acctBalance);\n\nflow.set('lastExecPrice',buyPrice);\nflow.set('currVolume',flow.get('currVolume')+1);\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1820,
|
|
"y": 540,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "10898ef6.fab381",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "NoSellAction",
|
|
"func": "let sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\nflow.set('lastExecPrice',sellPrice);\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1850,
|
|
"y": 460,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "b1857f61.f3b9a",
|
|
"type": "function",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "NoBuyAction",
|
|
"func": "let buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\nflow.set('lastExecPrice',sellPrice);\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1830,
|
|
"y": 620,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "71b8fd74.2d9404",
|
|
"type": "template",
|
|
"z": "af98615f.cf9ce",
|
|
"name": "HTML",
|
|
"field": "payload",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "mustache",
|
|
"template": "<html>\n <head>\n <title>{{payload.title}}</title>\n <style>{{payload.style}}</style>\n </head>\n<body>\n<table border='1'>\n <tr>\n {{#payload.header}}\n <th>{{.}}</th>\n {{/payload.header}}\n </tr>\n {{#payload.data}}\n <tr>\n {{#.}}\n <td><pre>{{.}}</pre></td>\n {{/.}}\n </tr>\n {{/payload.data}}\n</table>\n</body>\n</html>",
|
|
"output": "str",
|
|
"x": 190,
|
|
"y": 240,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "3ff8fa1b.3148f6",
|
|
"type": "function",
|
|
"z": "af98615f.cf9ce",
|
|
"name": "JSON Obj -> Array split Header and Data",
|
|
"func": "function toArray(json_data){\n for(var i in json_data)\n result.push([i, json_data [i]]);\n}\n\nfunction getHeader(json_data){\n let keys=Object.keys(json_data);\n return keys;\n}\n\nlet pl=msg.payload;\ndelete msg.payload;\n\nmsg.payload={};\nmsg.payload.header=[];\nmsg.payload.data=[];\nmsg.payload.title=msg.title;\n\nlet y=[];\nfor(var i in pl) {\n if (i==1) {\n msg.payload.header=getHeader(pl[i]);\n }\n let x=[];\n for (var j in pl[i]){\n x.push(pl[i][j]);\n }\n y.push(x);\n}\n\nmsg.payload.data=y;\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 260,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"325628f8.f9bb48"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "325628f8.f9bb48",
|
|
"type": "template",
|
|
"z": "af98615f.cf9ce",
|
|
"name": "CSS",
|
|
"field": "payload.style",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "mustache",
|
|
"template": "html,\nbody {\n height: 100%;\n}\nbody {\n margin: 0;\n background: #222222;\n font-family: sans-serif;\n font-weight: 100;\n}\n.container {\n position: absolute;\n top: 50%;\n left: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n}\ntable {\n width: 800px;\n border-collapse: collapse;\n overflow: hidden;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);\n}\ntd {\n padding: 0px;\n background-color: rgba(255, 255, 255, 0.2);\n color: #ffffff;\n text-align: left;\n}\npre {\n margin: 0;\n text-align: left;\n}\nth {\n background-color: #27206f;\n color: yellow;\n}\ntbody tr:hover {\n background-color: rgba(255, 255, 255, 0.3);\n}\ntbody td {\n position: relative;\n}\ntbody td:hover:before {\n content: \"\";\n position: absolute;\n left: 0;\n right: 0;\n top: -9999px;\n bottom: -9999px;\n background-color: rgba(255, 255, 255, 0.2);\n z-index: -1;\n}\n",
|
|
"output": "str",
|
|
"x": 190,
|
|
"y": 160,
|
|
"wires": [
|
|
[
|
|
"71b8fd74.2d9404"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8b96370c.e63028",
|
|
"type": "debug",
|
|
"z": "d8e8a587.a39408",
|
|
"d": true,
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 360,
|
|
"y": 100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "448c23fb.54356c",
|
|
"type": "http response",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"statusCode": "",
|
|
"headers": {},
|
|
"x": 1000,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e7546e50.b4e6",
|
|
"type": "sqlite",
|
|
"z": "d8e8a587.a39408",
|
|
"mydb": "4378beea.a2c7f",
|
|
"sqlquery": "fixed",
|
|
"sql": "select * from TradeGeneralLog order by ID desc limit 10000;",
|
|
"name": "",
|
|
"x": 680,
|
|
"y": 140,
|
|
"wires": [
|
|
[
|
|
"b67c9c51.fda15"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "79f2b3b4.db6cdc",
|
|
"type": "change",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "Set Title (Manual)",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "title",
|
|
"pt": "msg",
|
|
"to": "LOGs",
|
|
"tot": "str"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 300,
|
|
"y": 140,
|
|
"wires": [
|
|
[
|
|
"e7546e50.b4e6",
|
|
"8b96370c.e63028"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b67c9c51.fda15",
|
|
"type": "subflow:af98615f.cf9ce",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"env": [],
|
|
"x": 760,
|
|
"y": 220,
|
|
"wires": [
|
|
[
|
|
"448c23fb.54356c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7f957960.b6cd58",
|
|
"type": "http in",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"url": "/getLog",
|
|
"method": "get",
|
|
"upload": false,
|
|
"swaggerDoc": "",
|
|
"x": 80,
|
|
"y": 140,
|
|
"wires": [
|
|
[
|
|
"79f2b3b4.db6cdc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1733f8e8.f401d7",
|
|
"type": "http in",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"url": "/ethquote",
|
|
"method": "get",
|
|
"upload": false,
|
|
"swaggerDoc": "",
|
|
"x": 90,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"466e0099.9d9f4",
|
|
"dccf207a.84fe"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "133190be.64ae9f",
|
|
"type": "http response",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"statusCode": "",
|
|
"headers": {},
|
|
"x": 1120,
|
|
"y": 460,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "dccf207a.84fe",
|
|
"type": "get-ticker-information",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"x": 460,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"98e46a7a.8e8f78"
|
|
],
|
|
[
|
|
"7bb32908.e9d688"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "98e46a7a.8e8f78",
|
|
"type": "change",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "q.bid",
|
|
"pt": "msg",
|
|
"to": "payload.*.b[0]",
|
|
"tot": "jsonata"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "q.ask",
|
|
"pt": "msg",
|
|
"to": "payload.*.a[0]",
|
|
"tot": "jsonata"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 630,
|
|
"y": 460,
|
|
"wires": [
|
|
[
|
|
"d4c52c13.e1a43"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d4c52c13.e1a43",
|
|
"type": "change",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "payload",
|
|
"pt": "msg",
|
|
"to": "q",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 830,
|
|
"y": 460,
|
|
"wires": [
|
|
[
|
|
"63fe3995.999ad8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "63fe3995.999ad8",
|
|
"type": "csv",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "",
|
|
"sep": ",",
|
|
"hdrin": "",
|
|
"hdrout": "",
|
|
"multi": "one",
|
|
"ret": "\\n",
|
|
"temp": "",
|
|
"skip": "0",
|
|
"strings": true,
|
|
"x": 990,
|
|
"y": 460,
|
|
"wires": [
|
|
[
|
|
"133190be.64ae9f"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "466e0099.9d9f4",
|
|
"type": "debug",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "Incoming Ticker Query",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 350,
|
|
"y": 420,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "7bb32908.e9d688",
|
|
"type": "debug",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "Error in Ticker Query",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 720,
|
|
"y": 520,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f11eec38.1437d",
|
|
"type": "comment",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "Query Ticker bid/ask",
|
|
"info": "",
|
|
"x": 130,
|
|
"y": 360,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "686e858f.ba35bc",
|
|
"type": "comment",
|
|
"z": "d8e8a587.a39408",
|
|
"name": "Query the logs",
|
|
"info": "",
|
|
"x": 100,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "93ad6549.2fb1c8",
|
|
"type": "get-ticker-information",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "",
|
|
"x": 430,
|
|
"y": 220,
|
|
"wires": [
|
|
[
|
|
"85a560a3.c1f3e",
|
|
"b624e64.f93ef18"
|
|
],
|
|
[
|
|
"bcc562fd.dabae"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "47aba35f.ef005c",
|
|
"type": "inject",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Wednesdays, 10am",
|
|
"topic": "",
|
|
"payload": "{\"pair\":\"XETHZUSD\"}",
|
|
"payloadType": "json",
|
|
"repeat": "",
|
|
"crontab": "00 10 * * 3",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 200,
|
|
"y": 220,
|
|
"wires": [
|
|
[
|
|
"93ad6549.2fb1c8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "85a560a3.c1f3e",
|
|
"type": "debug",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Ticker Output",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 670,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "bcc562fd.dabae",
|
|
"type": "debug",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Error getting Ticker",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 690,
|
|
"y": 280,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "b624e64.f93ef18",
|
|
"type": "function",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "compute order",
|
|
"func": "let askPrice = msg.payload.XETHZUSD.a[0];\nlet volume2Buy = 50/askPrice; // How much Ethereum to buy for 50 USD?\nnode.log(\"Ask Price \", askPrice, \" --> Volume : \", volume2Buy );\n\nmsg.payload={\n\tpair : 'XETHZUSD',\n\ttype : 'buy',\n\tordertype : 'limit',\n\tprice : askPrice,\n\tvolume : volume2Buy\n};\n\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 690,
|
|
"y": 240,
|
|
"wires": [
|
|
[
|
|
"aa87fc3a.968ee",
|
|
"9ffc04e0.96e1d8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "aa87fc3a.968ee",
|
|
"type": "add-standard-order",
|
|
"z": "5d834238.9ad88c",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "",
|
|
"x": 900,
|
|
"y": 240,
|
|
"wires": [
|
|
[
|
|
"847e754.3bc3b88"
|
|
],
|
|
[
|
|
"e7a0fa8a.d9c008"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "847e754.3bc3b88",
|
|
"type": "debug",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Order Execution Success",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1140,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e7a0fa8a.d9c008",
|
|
"type": "debug",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Order Execution Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1140,
|
|
"y": 260,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9ffc04e0.96e1d8",
|
|
"type": "debug",
|
|
"z": "5d834238.9ad88c",
|
|
"name": "Computed Order",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 920,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "8272f674.8a7c98",
|
|
"type": "get-server-time",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "",
|
|
"x": 330,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"288d7d82.889772"
|
|
],
|
|
[
|
|
"49ef2217.4037bc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "6a276dbb.1b4804",
|
|
"type": "inject",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 140,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"8272f674.8a7c98"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "288d7d82.889772",
|
|
"type": "debug",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 570,
|
|
"y": 100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "49ef2217.4037bc",
|
|
"type": "debug",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 580,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "d23ac766.df15d8",
|
|
"type": "get-account-balance",
|
|
"z": "e67f589a.f8d378",
|
|
"kraken": "42702610.230028",
|
|
"name": "",
|
|
"x": 360,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"e69da0fa.a973"
|
|
],
|
|
[
|
|
"4139462.65bf8b8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e69da0fa.a973",
|
|
"type": "debug",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "Kraken-Balance",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 620,
|
|
"y": 340,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "4139462.65bf8b8",
|
|
"type": "debug",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "Kraken Balance ERROR",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 650,
|
|
"y": 420,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "105e61e6.8fea0e",
|
|
"type": "inject",
|
|
"z": "e67f589a.f8d378",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "86400",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 150,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"d23ac766.df15d8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"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": true,
|
|
"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": "1000",
|
|
"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.5",
|
|
"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<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": [
|
|
[
|
|
"615d2f89.216e2"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4919fa9e.7087b4",
|
|
"type": "function",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "BuyAction",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = Number(msg.payload.DOTUSD.a[0]);\n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nmsg.payload={\n\tpair : 'DOTUSD',\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1940,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"3f4bce34.ba9772",
|
|
"7ae49fbd.e5d98"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "57b4e5da.a8dedc",
|
|
"type": "function",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "NoSellAction",
|
|
"func": "let sellPrice = Number(msg.payload.DOTUSD.b[0]);\n\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1770,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"5122dba4.2f46b4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "443994b5.e4cfcc",
|
|
"type": "function",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "NoBuyAction",
|
|
"func": "let buyPrice = Number(msg.payload.DOTUSD.a[0]);\n\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1890,
|
|
"y": 840,
|
|
"wires": [
|
|
[
|
|
"f4682271.e52a7"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "bcc2295e.e1e198",
|
|
"type": "function",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "SellAction",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\n\nlet sellPrice = Number(msg.payload.DOTUSD.b[0]);\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nmsg.payload={\n\tpair : 'DOTUSD',\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1760,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"7795f775.712988",
|
|
"7ae49fbd.e5d98"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "36a67f9d.84d5c",
|
|
"type": "sqlite",
|
|
"z": "5b601c88.f89c94",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 1150,
|
|
"y": 500,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "dc364cac.c8885",
|
|
"type": "function",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Build Insert Statement",
|
|
"func": "msg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('DOTUSD','\" + JSON.stringify(msg.payload.DOTUSD) + \"');\"\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 860,
|
|
"y": 540,
|
|
"wires": [
|
|
[
|
|
"5b92bd62.aa6394",
|
|
"36a67f9d.84d5c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5b92bd62.aa6394",
|
|
"type": "debug",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1090,
|
|
"y": 560,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "291c035e.48469c",
|
|
"type": "comment",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Initialization",
|
|
"info": "",
|
|
"x": 510,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "8d4891ff.fee48",
|
|
"type": "comment",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Regular Looping",
|
|
"info": "",
|
|
"x": 520,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "7ae49fbd.e5d98",
|
|
"type": "add-standard-order",
|
|
"z": "5b601c88.f89c94",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "",
|
|
"x": 2410,
|
|
"y": 680,
|
|
"wires": [
|
|
[
|
|
"490a0d7e.03e7d4"
|
|
],
|
|
[
|
|
"23022422.b65bdc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "490a0d7e.03e7d4",
|
|
"type": "debug",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Order Execution Success",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2650,
|
|
"y": 660,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "23022422.b65bdc",
|
|
"type": "debug",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Order Execution Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2650,
|
|
"y": 700,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f2b11b31.7f5da8",
|
|
"type": "debug",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Needs Initialization",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 640,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1f02219e.43eaae",
|
|
"type": "debug",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "$flowContext('coinBalance') / $flowContext('multiplier')",
|
|
"targetType": "jsonata",
|
|
"x": 320,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "767a5d6.a26b9a4",
|
|
"type": "inject",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 110,
|
|
"y": 200,
|
|
"wires": [
|
|
[
|
|
"1f02219e.43eaae"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e581fdfb.e369",
|
|
"type": "comment",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "Get current \"standardized balance\"",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1e0e13fa.b2671c",
|
|
"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": 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"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "66d6fae3.416954",
|
|
"type": "inject",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 540,
|
|
"wires": [
|
|
[
|
|
"590fd33a.7469cc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "590fd33a.7469cc",
|
|
"type": "change",
|
|
"z": "5b601c88.f89c94",
|
|
"name": "BUY",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "#:(file)::lastExecPrice",
|
|
"pt": "flow",
|
|
"to": "999",
|
|
"tot": "num"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 290,
|
|
"y": 540,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "b91b73d5.e1c6b",
|
|
"type": "inject",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "{\"pair\":\"XXMRZUSD\", \"currency\":\"XXMR\", \"maxVolume\": 70, \"minVolume\":0, \"delta\":1, \"multiplier\":2, \"maxBuyPrice\":165}",
|
|
"payloadType": "json",
|
|
"repeat": "60",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": 0.1,
|
|
"x": 90,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"aa3a99bd.8df5b8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b8f99af2.43c928",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"name": "isInitialized?",
|
|
"property": "$flowContext('isInitialized')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "true"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 390,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"5ac19b61.231e64"
|
|
],
|
|
[
|
|
"4bbbf5fa.1a452c",
|
|
"ebb71aba.3ffc38"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "ff1341d.17ca8c",
|
|
"type": "change",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "isInitialized",
|
|
"pt": "flow",
|
|
"to": "true",
|
|
"tot": "bool"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "coinBalance",
|
|
"pt": "flow",
|
|
"to": "payload.balance",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1420,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"a855b1cd.68de7"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4bbbf5fa.1a452c",
|
|
"type": "get-account-balance",
|
|
"z": "791ce869.901798",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "",
|
|
"x": 600,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"4fc3c2c2.eb524c",
|
|
"f8444acf.9e5018"
|
|
],
|
|
[
|
|
"25a10fa1.89d85",
|
|
"bed8d866.996918"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "137e74af.55b07b",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"property": "payload.balance",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "nnull"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1010,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"ff1341d.17ca8c"
|
|
],
|
|
[
|
|
"5da3780b.7006f8",
|
|
"55955668.3c3f18"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5da3780b.7006f8",
|
|
"type": "change",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "payload.balance",
|
|
"pt": "msg",
|
|
"to": "0",
|
|
"tot": "num"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1190,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"ff1341d.17ca8c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "a855b1cd.68de7",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Initialized.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1610,
|
|
"y": 80,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "25a10fa1.89d85",
|
|
"type": "delay",
|
|
"z": "791ce869.901798",
|
|
"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": [
|
|
[
|
|
"4bbbf5fa.1a452c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "bed8d866.996918",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Error getting Balance - retrying infinite.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 940,
|
|
"y": 160,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a1380874.e1ec38",
|
|
"type": "inject",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"4e7b5ea3.e8877"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4e7b5ea3.e8877",
|
|
"type": "change",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "delete",
|
|
"p": "isInitialized",
|
|
"pt": "flow"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 340,
|
|
"y": 80,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "a4844097.ea3fa",
|
|
"type": "comment",
|
|
"z": "791ce869.901798",
|
|
"name": "Force-Uninitialize (Reload settings)",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5ac19b61.231e64",
|
|
"type": "get-ticker-information",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"x": 630,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"f5b164f3.f31528",
|
|
"7732e077.359e8",
|
|
"f0e0540.34101b"
|
|
],
|
|
[
|
|
"1eaad6dd.29ae19"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1eaad6dd.29ae19",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Ticker Retrieval Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 890,
|
|
"y": 760,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "46ab4c93.ec7a24",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"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": [
|
|
[
|
|
"65e8472b.077f68",
|
|
"c4c5f78.c5b4008"
|
|
],
|
|
[
|
|
"b569c8e1.7d8798",
|
|
"7826a982.9ab1a8"
|
|
],
|
|
[
|
|
"5a75c25c.e3a73c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1fc77690.6dba29",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "gt (sell)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1760,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "fad60147.7959d",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "lt (buy)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1740,
|
|
"y": 940,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a088ddf.2908b2",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "small diff (nothing)",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1780,
|
|
"y": 1040,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "65e8472b.077f68",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"name": "MinVolReached?",
|
|
"property": "$flowContext('coinBalance') - $flowContext('orderVolume') ",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "gte",
|
|
"v": "minVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 620,
|
|
"wires": [
|
|
[
|
|
"ec94685d.efd4b8"
|
|
],
|
|
[
|
|
"87a189d0.fb4808",
|
|
"cf749675.a7b758"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "87a189d0.fb4808",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Not Selling, min Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1820,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f22af620.d468b8",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "SELLING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1970,
|
|
"y": 540,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "37da2485.6ae8ec",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "BUYING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 2150,
|
|
"y": 700,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "b569c8e1.7d8798",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"name": "MaxVolReached?",
|
|
"property": "$flowContext('coinBalance') + $flowContext('orderVolume')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"5cafb1d8.c2e0b"
|
|
],
|
|
[
|
|
"392c8978.051c36"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "392c8978.051c36",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Not buying, max Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1830,
|
|
"y": 840,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f5b164f3.f31528",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "Determine Action",
|
|
"func": "const delta=flow.get('delta'); // how much price move to take action?\nlet multiplier = flow.get('multiplier');\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\n// if the last exec price is higher than the maxBuyPrice, \n// we won't use that high price to calculate the volume.\n// instead, the max-buy price is used.\n// we need to add 1 delta, so that we buy also \"AT\" the \n// max buy price and not only 1 delta under.\nlet maxBuyPrice=flow.get(\"maxBuyPrice\");\nlet volumePrice=(lastExecPrice>maxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+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(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else if (askPrice<volumePrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n let jumpSize = Math.floor(Math.abs(volumePrice-askPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 910,
|
|
"y": 680,
|
|
"wires": [
|
|
[
|
|
"46ab4c93.ec7a24"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7e1d9a.c6aeb268",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "BuildOrder (buy)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1960,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"37da2485.6ae8ec",
|
|
"4c94b0f3.5706d"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "cf749675.a7b758",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "NoSellAction",
|
|
"func": "let sellPrice = flow.get(\"bidPrice\"); \nflow.set('lastExecPrice',sellPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 680,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "d0eab84.fb81048",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "NoBuyAction",
|
|
"func": "let buyPrice = flow.get(\"askPrice\"); \nflow.set('lastExecPrice',buyPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 880,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "ec94685d.efd4b8",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "Buid Order (sell)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1760,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"f22af620.d468b8",
|
|
"4b011555.eb58dc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "a0f0c683.33fa88",
|
|
"type": "sqlite",
|
|
"z": "791ce869.901798",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 1150,
|
|
"y": 500,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "7732e077.359e8",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "Build Insert Statement",
|
|
"func": "let pair=flow.get(\"pair\");\nmsg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('\"+ pair +\"','\" + JSON.stringify(msg.payload[pair]) + \"');\"\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 860,
|
|
"y": 540,
|
|
"wires": [
|
|
[
|
|
"c9f10e3c.9c955",
|
|
"a0f0c683.33fa88"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c9f10e3c.9c955",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1090,
|
|
"y": 560,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "3ff5fd03.2ca232",
|
|
"type": "comment",
|
|
"z": "791ce869.901798",
|
|
"name": "Initialization",
|
|
"info": "",
|
|
"x": 510,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "de6fb450.f80908",
|
|
"type": "comment",
|
|
"z": "791ce869.901798",
|
|
"name": "Regular Looping",
|
|
"info": "",
|
|
"x": 520,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "4b011555.eb58dc",
|
|
"type": "add-standard-order",
|
|
"z": "791ce869.901798",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Sell Order",
|
|
"x": 2460,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"5596b182.9b1d9",
|
|
"d313119a.7dbbd"
|
|
],
|
|
[
|
|
"e33429fb.63d0b8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5596b182.9b1d9",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Order Execution Success",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2740,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e33429fb.63d0b8",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Order Execution Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2750,
|
|
"y": 800,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "ebb71aba.3ffc38",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "Needs Initialization",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 640,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9171c134.547a5",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "$flowContext('coinBalance') / $flowContext('multiplier')",
|
|
"targetType": "jsonata",
|
|
"x": 320,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2c6c2f0.fd81ad",
|
|
"type": "inject",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 110,
|
|
"y": 200,
|
|
"wires": [
|
|
[
|
|
"9171c134.547a5"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b563c64d.f3b4d8",
|
|
"type": "comment",
|
|
"z": "791ce869.901798",
|
|
"name": "Get current \"standardized balance\"",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "c4c5f78.c5b4008",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"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": 500,
|
|
"wires": [
|
|
[
|
|
"1fc77690.6dba29"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7826a982.9ab1a8",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"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": 940,
|
|
"wires": [
|
|
[
|
|
"fad60147.7959d"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5a75c25c.e3a73c",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"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": 1040,
|
|
"wires": [
|
|
[
|
|
"a088ddf.2908b2"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "18ad848.b1ba67c",
|
|
"type": "catch",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"scope": null,
|
|
"uncaught": false,
|
|
"x": 220,
|
|
"y": 980,
|
|
"wires": [
|
|
[
|
|
"b12af9d5.fa7168"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b12af9d5.fa7168",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "ERROR!!!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 470,
|
|
"y": 980,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5cafb1d8.c2e0b",
|
|
"type": "switch",
|
|
"z": "791ce869.901798",
|
|
"name": "Max-Price?",
|
|
"property": "price",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxBuyPrice",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1750,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"7e1d9a.c6aeb268"
|
|
],
|
|
[
|
|
"9fc278e4.eec9f8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "9fc278e4.eec9f8",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"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": "a83a82d7.061a7",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"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": [
|
|
[
|
|
"40a6e4ef.7b632c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "40a6e4ef.7b632c",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 310,
|
|
"y": 280,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "ebc8b806.bd8c08",
|
|
"type": "inject",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 280,
|
|
"wires": [
|
|
[
|
|
"a83a82d7.061a7"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "f0e0540.34101b",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 900,
|
|
"y": 440,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "4fc3c2c2.eb524c",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 770,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "aa3a99bd.8df5b8",
|
|
"type": "change",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "pair",
|
|
"pt": "flow",
|
|
"to": "payload.pair",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "currency",
|
|
"pt": "flow",
|
|
"to": "payload.currency",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxVolume",
|
|
"pt": "flow",
|
|
"to": "payload.maxVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "minVolume",
|
|
"pt": "flow",
|
|
"to": "payload.minVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "multiplier",
|
|
"pt": "flow",
|
|
"to": "payload.multiplier",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxBuyPrice",
|
|
"pt": "flow",
|
|
"to": "payload.maxBuyPrice",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "delta",
|
|
"pt": "flow",
|
|
"to": "payload.delta",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 200,
|
|
"y": 500,
|
|
"wires": [
|
|
[
|
|
"b8f99af2.43c928"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d313119a.7dbbd",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "Recompute CoinBalance (sell)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet sellPrice = flow.get(\"bidPrice\");\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 560,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "237dab2.fbb4054",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "Recompute CoinBalance (buy)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = flow.get(\"askPrice\"); \n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 720,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "4c94b0f3.5706d",
|
|
"type": "add-standard-order",
|
|
"z": "791ce869.901798",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Buy Order ",
|
|
"x": 2460,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"5596b182.9b1d9",
|
|
"237dab2.fbb4054"
|
|
],
|
|
[
|
|
"e33429fb.63d0b8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "f8444acf.9e5018",
|
|
"type": "function",
|
|
"z": "791ce869.901798",
|
|
"name": "dynamic Currency To fix Key",
|
|
"func": "let currency=flow.get('currency');\n\nif (msg.payload[currency]!==undefined) {\n msg.payload.balance=Number(msg.payload[currency]);\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 820,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"137e74af.55b07b",
|
|
"c6cb83e5.47092"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c6cb83e5.47092",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1060,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "49b4c202.4977fc",
|
|
"type": "inject",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "{\"pair\":\"XETCZUSD\", \"currency\":\"XETC\", \"maxVolume\": 2000, \"minVolume\":0, \"delta\":0.1, \"multiplier\":50, \"maxBuyPrice\":7.5}",
|
|
"payloadType": "json",
|
|
"repeat": "60",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": 0.1,
|
|
"x": 90,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"6cebf48.658d20c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e1ac406a.aa733",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "isInitialized?",
|
|
"property": "$flowContext('isInitialized')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "true"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 390,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"3a492217.4d9f9e"
|
|
],
|
|
[
|
|
"3d795ca5.2e7ca4",
|
|
"a7548970.2ea4d8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8ee0d04e.612b5",
|
|
"type": "change",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "isInitialized",
|
|
"pt": "flow",
|
|
"to": "true",
|
|
"tot": "bool"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "coinBalance",
|
|
"pt": "flow",
|
|
"to": "payload.balance",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1440,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"d9ad21d6.9eae2"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "3d795ca5.2e7ca4",
|
|
"type": "get-account-balance",
|
|
"z": "9d5ee7b4.680b68",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "",
|
|
"x": 600,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"5f9cf343.aab02c",
|
|
"476c2bfd.588624"
|
|
],
|
|
[
|
|
"f928aa62.6c3e78",
|
|
"6bfbe297.90f6cc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "23264922.5c11c6",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"property": "payload.balance",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "nnull"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1050,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"8ee0d04e.612b5"
|
|
],
|
|
[
|
|
"11b75c20.bed614",
|
|
"5797473.ba4dbb8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "11b75c20.bed614",
|
|
"type": "change",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "payload.balance",
|
|
"pt": "msg",
|
|
"to": "0",
|
|
"tot": "num"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1230,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"8ee0d04e.612b5"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d9ad21d6.9eae2",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Initialized.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1650,
|
|
"y": 80,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f928aa62.6c3e78",
|
|
"type": "delay",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": [
|
|
[
|
|
"3d795ca5.2e7ca4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "6bfbe297.90f6cc",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Error getting Balance - retrying infinite.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 940,
|
|
"y": 160,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e3dcd6e2.3bd1e8",
|
|
"type": "inject",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"21975354.3eaebc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "21975354.3eaebc",
|
|
"type": "change",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "delete",
|
|
"p": "isInitialized",
|
|
"pt": "flow"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 340,
|
|
"y": 80,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "109d9da6.9c54d2",
|
|
"type": "comment",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Force-Uninitialize (Reload settings)",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "3a492217.4d9f9e",
|
|
"type": "get-ticker-information",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"x": 630,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"530e563b.26da58",
|
|
"eb48386e.793c28",
|
|
"fae4335d.1e0c9"
|
|
],
|
|
[
|
|
"31ec3637.3f4d8a"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "31ec3637.3f4d8a",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Ticker Retrieval Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 890,
|
|
"y": 760,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1729c03a.0279c",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": [
|
|
[
|
|
"75e975b.ec6798c",
|
|
"2ea52791.394798"
|
|
],
|
|
[
|
|
"2c8eb6b7.bee18a",
|
|
"c9ba5205.88dd"
|
|
],
|
|
[
|
|
"2de87b96.c112f4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8374a5e.dd27158",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "gt (sell)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1760,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "136a83d.4f24f7c",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "lt (buy)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1740,
|
|
"y": 940,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "ab118944.75cdb8",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "small diff (nothing)",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1780,
|
|
"y": 1040,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "75e975b.ec6798c",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "MinVolReached?",
|
|
"property": "$flowContext('coinBalance') - $flowContext('orderVolume') ",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "gte",
|
|
"v": "minVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 620,
|
|
"wires": [
|
|
[
|
|
"7a72175a.7669e8"
|
|
],
|
|
[
|
|
"8ecf1845.71d1d8",
|
|
"81c5ea58.e6a088"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8ecf1845.71d1d8",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Not Selling, min Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1820,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "d016a6b3.3ec3d8",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "SELLING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1970,
|
|
"y": 540,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a7ed93f2.c0172",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "BUYING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 2150,
|
|
"y": 700,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2c8eb6b7.bee18a",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "MaxVolReached?",
|
|
"property": "$flowContext('coinBalance') + $flowContext('orderVolume')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"1f388909.129287"
|
|
],
|
|
[
|
|
"62bc33d4.5bea1c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "62bc33d4.5bea1c",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Not buying, max Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1830,
|
|
"y": 840,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "530e563b.26da58",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Determine Action",
|
|
"func": "const delta=flow.get('delta'); // how much price move to take action?\nlet multiplier = flow.get('multiplier');\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\n// if the last exec price is higher than the maxBuyPrice, \n// we won't use that high price to calculate the volume.\n// instead, the max-buy price is used.\n// we need to add 1 delta, so that we buy also \"AT\" the \n// max buy price and not only 1 delta under.\nlet maxBuyPrice=flow.get(\"maxBuyPrice\");\nlet volumePrice=(lastExecPrice>maxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+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(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else if (askPrice<volumePrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n let jumpSize = Math.floor(Math.abs(volumePrice-askPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 910,
|
|
"y": 680,
|
|
"wires": [
|
|
[
|
|
"1729c03a.0279c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "feffd99e.9c4998",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "BuildOrder (buy)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1960,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"a7ed93f2.c0172",
|
|
"b872c91c.0c3fa8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "81c5ea58.e6a088",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "NoSellAction",
|
|
"func": "let sellPrice = flow.get(\"bidPrice\"); \nflow.set('lastExecPrice',sellPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 680,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "574ff851.949858",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "NoBuyAction",
|
|
"func": "let buyPrice = flow.get(\"askPrice\"); \nflow.set('lastExecPrice',buyPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 880,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "7a72175a.7669e8",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Buid Order (sell)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1760,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"d016a6b3.3ec3d8",
|
|
"65304ace.259ae4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "a6080316.c5ed3",
|
|
"type": "sqlite",
|
|
"z": "9d5ee7b4.680b68",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 1150,
|
|
"y": 500,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "eb48386e.793c28",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Build Insert Statement",
|
|
"func": "let pair=flow.get(\"pair\");\nmsg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('\"+ pair +\"','\" + JSON.stringify(msg.payload[pair]) + \"');\"\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 860,
|
|
"y": 540,
|
|
"wires": [
|
|
[
|
|
"35965af2.76f7c6",
|
|
"a6080316.c5ed3"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "35965af2.76f7c6",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1090,
|
|
"y": 560,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a962fcef.d07f2",
|
|
"type": "comment",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Initialization",
|
|
"info": "",
|
|
"x": 510,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "aa97d26d.1bdc7",
|
|
"type": "comment",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Regular Looping",
|
|
"info": "",
|
|
"x": 520,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "65304ace.259ae4",
|
|
"type": "add-standard-order",
|
|
"z": "9d5ee7b4.680b68",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Sell Order",
|
|
"x": 2460,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"777fb372.39187c",
|
|
"34c1cd9d.422812"
|
|
],
|
|
[
|
|
"67c1ceeb.b4bb"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "777fb372.39187c",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Order Execution Success",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2740,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "67c1ceeb.b4bb",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Order Execution Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2750,
|
|
"y": 800,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a7548970.2ea4d8",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Needs Initialization",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 640,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "3b1c4df7.d7b7d2",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "$flowContext('coinBalance') / $flowContext('multiplier')",
|
|
"targetType": "jsonata",
|
|
"x": 320,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "320f93f.cdc616c",
|
|
"type": "inject",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 110,
|
|
"y": 200,
|
|
"wires": [
|
|
[
|
|
"3b1c4df7.d7b7d2"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e5b65bbb.303078",
|
|
"type": "comment",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Get current \"standardized balance\"",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2ea52791.394798",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": 500,
|
|
"wires": [
|
|
[
|
|
"8374a5e.dd27158"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c9ba5205.88dd",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": 940,
|
|
"wires": [
|
|
[
|
|
"136a83d.4f24f7c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2de87b96.c112f4",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": 1040,
|
|
"wires": [
|
|
[
|
|
"ab118944.75cdb8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d1958e6b.be162",
|
|
"type": "catch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"scope": null,
|
|
"uncaught": false,
|
|
"x": 220,
|
|
"y": 980,
|
|
"wires": [
|
|
[
|
|
"4ab5af6e.45938"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4ab5af6e.45938",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "ERROR!!!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 470,
|
|
"y": 980,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1f388909.129287",
|
|
"type": "switch",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Max-Price?",
|
|
"property": "price",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxBuyPrice",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1750,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"feffd99e.9c4998"
|
|
],
|
|
[
|
|
"80b6f5aa.f73b18"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "80b6f5aa.f73b18",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": "88c1202f.1565b",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"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": [
|
|
[
|
|
"5095f8b2.73bc58"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5095f8b2.73bc58",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 310,
|
|
"y": 280,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "4fd99ba.4d5c964",
|
|
"type": "inject",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 280,
|
|
"wires": [
|
|
[
|
|
"88c1202f.1565b"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "fae4335d.1e0c9",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 900,
|
|
"y": 440,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5f9cf343.aab02c",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 770,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "6cebf48.658d20c",
|
|
"type": "change",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "pair",
|
|
"pt": "flow",
|
|
"to": "payload.pair",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "currency",
|
|
"pt": "flow",
|
|
"to": "payload.currency",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxVolume",
|
|
"pt": "flow",
|
|
"to": "payload.maxVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "minVolume",
|
|
"pt": "flow",
|
|
"to": "payload.minVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "multiplier",
|
|
"pt": "flow",
|
|
"to": "payload.multiplier",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxBuyPrice",
|
|
"pt": "flow",
|
|
"to": "payload.maxBuyPrice",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "delta",
|
|
"pt": "flow",
|
|
"to": "payload.delta",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 200,
|
|
"y": 500,
|
|
"wires": [
|
|
[
|
|
"e1ac406a.aa733"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "34c1cd9d.422812",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Recompute CoinBalance (sell)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet sellPrice = flow.get(\"bidPrice\");\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 560,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "1514778.cfca489",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "Recompute CoinBalance (buy)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = flow.get(\"askPrice\"); \n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 720,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "b872c91c.0c3fa8",
|
|
"type": "add-standard-order",
|
|
"z": "9d5ee7b4.680b68",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Buy Order ",
|
|
"x": 2460,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"777fb372.39187c",
|
|
"1514778.cfca489"
|
|
],
|
|
[
|
|
"67c1ceeb.b4bb"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "476c2bfd.588624",
|
|
"type": "function",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "dynamic Currency To fix Key",
|
|
"func": "let currency=flow.get('currency');\n\nif (msg.payload[currency]!==undefined) {\n msg.payload.balance=Number(msg.payload[currency]);\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 820,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"23264922.5c11c6",
|
|
"ce6ea663.120788"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "ce6ea663.120788",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1060,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5797473.ba4dbb8",
|
|
"type": "debug",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1400,
|
|
"y": 180,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "55955668.3c3f18",
|
|
"type": "debug",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1380,
|
|
"y": 160,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "155d44e4.5b234b",
|
|
"type": "inject",
|
|
"z": "9d5ee7b4.680b68",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "3600",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": "30",
|
|
"x": 490,
|
|
"y": 40,
|
|
"wires": [
|
|
[
|
|
"3d795ca5.2e7ca4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e1503421.db6318",
|
|
"type": "inject",
|
|
"z": "791ce869.901798",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "3600",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": "20",
|
|
"x": 450,
|
|
"y": 40,
|
|
"wires": [
|
|
[
|
|
"4bbbf5fa.1a452c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "ec58b50a.d546b8",
|
|
"type": "inject",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "{\"pair\":\"DOTUSD\", \"currency\":\"DOT\", \"maxVolume\": 1000, \"minVolume\":0, \"delta\":0.1, \"multiplier\":50, \"maxBuyPrice\":7.5}",
|
|
"payloadType": "json",
|
|
"repeat": "60",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": 0.1,
|
|
"x": 90,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"3d3f5c03.2d8a74"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5b03fb12.673c74",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "isInitialized?",
|
|
"property": "$flowContext('isInitialized')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "true"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 390,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"36d75647.4096ca"
|
|
],
|
|
[
|
|
"2c667cd5.5eac84",
|
|
"f4e598ad.680768"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1d202d55.d951b3",
|
|
"type": "change",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "isInitialized",
|
|
"pt": "flow",
|
|
"to": "true",
|
|
"tot": "bool"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "coinBalance",
|
|
"pt": "flow",
|
|
"to": "payload.balance",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1420,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"d7cad7b3.25cbb8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2c667cd5.5eac84",
|
|
"type": "get-account-balance",
|
|
"z": "3fba07ea.b0acd8",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "",
|
|
"x": 600,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"e4eb7b53.5e1f48",
|
|
"681dfe53.c121f"
|
|
],
|
|
[
|
|
"d55d1dab.dcfb3",
|
|
"250b5650.142efa"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d9fafdd1.9f6ef",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"property": "payload.balance",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "nnull"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1010,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"1d202d55.d951b3"
|
|
],
|
|
[
|
|
"d74ee645.ccec88",
|
|
"9bf486c9.b6b328"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d74ee645.ccec88",
|
|
"type": "change",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "payload.balance",
|
|
"pt": "msg",
|
|
"to": "0",
|
|
"tot": "num"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 1190,
|
|
"y": 120,
|
|
"wires": [
|
|
[
|
|
"1d202d55.d951b3"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d7cad7b3.25cbb8",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Initialized.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1610,
|
|
"y": 80,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "d55d1dab.dcfb3",
|
|
"type": "delay",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": [
|
|
[
|
|
"2c667cd5.5eac84"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "250b5650.142efa",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Error getting Balance - retrying infinite.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 940,
|
|
"y": 160,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2c25d9b9.bbaf16",
|
|
"type": "inject",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"fe559dee.f7d76"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "fe559dee.f7d76",
|
|
"type": "change",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "delete",
|
|
"p": "isInitialized",
|
|
"pt": "flow"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 340,
|
|
"y": 80,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "ebb97673.a6fcc8",
|
|
"type": "comment",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Force-Uninitialize (Reload settings)",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "36d75647.4096ca",
|
|
"type": "get-ticker-information",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"x": 630,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"a77fea93.65f6e8",
|
|
"8ee6e73f.a4f988",
|
|
"d8e15d86.7f87f"
|
|
],
|
|
[
|
|
"a9d2bb0.dc2d148"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "a9d2bb0.dc2d148",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Ticker Retrieval Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 890,
|
|
"y": 760,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "bad8e70d.6a3098",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": [
|
|
[
|
|
"da2c966d.ce45a8",
|
|
"523c2591.0b243c"
|
|
],
|
|
[
|
|
"b6620062.c8c8e",
|
|
"23eb6189.8565de"
|
|
],
|
|
[
|
|
"2ab676b7.975e1a"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b1e44203.91c91",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "gt (sell)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1760,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "cbbd1581.37ad58",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "lt (buy)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1740,
|
|
"y": 940,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2745ccbb.120674",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "small diff (nothing)",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1780,
|
|
"y": 1040,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "da2c966d.ce45a8",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "MinVolReached?",
|
|
"property": "$flowContext('coinBalance') - $flowContext('orderVolume') ",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "gte",
|
|
"v": "minVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 620,
|
|
"wires": [
|
|
[
|
|
"463ce648.7b1f38"
|
|
],
|
|
[
|
|
"82ea3cff.83471",
|
|
"82e314ee.a67478"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "82ea3cff.83471",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Not Selling, min Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1820,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "11a4d493.b2ffab",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "SELLING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1970,
|
|
"y": 540,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "96f9020b.d84e8",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "BUYING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 2150,
|
|
"y": 700,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "b6620062.c8c8e",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "MaxVolReached?",
|
|
"property": "$flowContext('coinBalance') + $flowContext('orderVolume')",
|
|
"propertyType": "jsonata",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxVolume",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1510,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"843d2cb7.525a7"
|
|
],
|
|
[
|
|
"589b26f0.a7cec8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "589b26f0.a7cec8",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Not buying, max Volume reached.",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1830,
|
|
"y": 840,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a77fea93.65f6e8",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Determine Action",
|
|
"func": "const delta=flow.get('delta'); // how much price move to take action?\nlet multiplier = flow.get('multiplier');\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\n// if the last exec price is higher than the maxBuyPrice, \n// we won't use that high price to calculate the volume.\n// instead, the max-buy price is used.\n// we need to add 1 delta, so that we buy also \"AT\" the \n// max buy price and not only 1 delta under.\nlet maxBuyPrice=flow.get(\"maxBuyPrice\");\nlet volumePrice=(lastExecPrice>maxBuyPrice+delta)?maxBuyPrice+delta:lastExecPrice;\n\nflow.set(\"orderVolume\",0);\nif (bidPrice>volumePrice+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(volumePrice-bidPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else if (askPrice<volumePrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n let jumpSize = Math.floor(Math.abs(volumePrice-askPrice)/delta);\n flow.set(\"orderVolume\",jumpSize * multiplier);\n flow.set(\"volumePrice\",volumePrice);\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 910,
|
|
"y": 680,
|
|
"wires": [
|
|
[
|
|
"bad8e70d.6a3098"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "52882f5b.86b19",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "BuildOrder (buy)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1960,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"96f9020b.d84e8",
|
|
"9a98519c.12f49"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "82e314ee.a67478",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "NoSellAction",
|
|
"func": "let sellPrice = flow.get(\"bidPrice\"); \nflow.set('lastExecPrice',sellPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 680,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "e73f6e6e.c13c2",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "NoBuyAction",
|
|
"func": "let buyPrice = flow.get(\"askPrice\"); \nflow.set('lastExecPrice',buyPrice,\"file\");\n",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1750,
|
|
"y": 880,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "463ce648.7b1f38",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Buid Order (sell)",
|
|
"func": "msg.payload={\n\tpair : flow.get('pair'),\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : flow.get('orderVolume')\n};\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 1760,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"11a4d493.b2ffab",
|
|
"5b77ca35.176384"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5743f9ed.28fea8",
|
|
"type": "sqlite",
|
|
"z": "3fba07ea.b0acd8",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 1150,
|
|
"y": 500,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "8ee6e73f.a4f988",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Build Insert Statement",
|
|
"func": "let pair=flow.get(\"pair\");\nmsg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('\"+ pair +\"','\" + JSON.stringify(msg.payload[pair]) + \"');\"\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 860,
|
|
"y": 540,
|
|
"wires": [
|
|
[
|
|
"58bf7702.db4ac8",
|
|
"5743f9ed.28fea8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "58bf7702.db4ac8",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1090,
|
|
"y": 560,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5071a10d.00427",
|
|
"type": "comment",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Initialization",
|
|
"info": "",
|
|
"x": 510,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "113f2634.d2a96a",
|
|
"type": "comment",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Regular Looping",
|
|
"info": "",
|
|
"x": 520,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5b77ca35.176384",
|
|
"type": "add-standard-order",
|
|
"z": "3fba07ea.b0acd8",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Sell Order",
|
|
"x": 2460,
|
|
"y": 560,
|
|
"wires": [
|
|
[
|
|
"258764e0.79d46c",
|
|
"8c5facab.8b6e8"
|
|
],
|
|
[
|
|
"87ccdbf2.f0c7f8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "258764e0.79d46c",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Order Execution Success",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2740,
|
|
"y": 500,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "87ccdbf2.f0c7f8",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Order Execution Error",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 2750,
|
|
"y": 800,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f4e598ad.680768",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Needs Initialization",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 640,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "20a188a7.f14318",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "$flowContext('coinBalance') / $flowContext('multiplier')",
|
|
"targetType": "jsonata",
|
|
"x": 320,
|
|
"y": 200,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2f9147f8.7aea58",
|
|
"type": "inject",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 110,
|
|
"y": 200,
|
|
"wires": [
|
|
[
|
|
"20a188a7.f14318"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b5839f75.b12bc",
|
|
"type": "comment",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Get current \"standardized balance\"",
|
|
"info": "",
|
|
"x": 160,
|
|
"y": 140,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "523c2591.0b243c",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": 500,
|
|
"wires": [
|
|
[
|
|
"b1e44203.91c91"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "23eb6189.8565de",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": 940,
|
|
"wires": [
|
|
[
|
|
"cbbd1581.37ad58"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2ab676b7.975e1a",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": 1040,
|
|
"wires": [
|
|
[
|
|
"2745ccbb.120674"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "9331d935.466378",
|
|
"type": "catch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"scope": null,
|
|
"uncaught": false,
|
|
"x": 220,
|
|
"y": 980,
|
|
"wires": [
|
|
[
|
|
"4c67d1ec.73dd4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4c67d1ec.73dd4",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "ERROR!!!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 470,
|
|
"y": 980,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "843d2cb7.525a7",
|
|
"type": "switch",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Max-Price?",
|
|
"property": "price",
|
|
"propertyType": "msg",
|
|
"rules": [
|
|
{
|
|
"t": "lte",
|
|
"v": "maxBuyPrice",
|
|
"vt": "flow"
|
|
},
|
|
{
|
|
"t": "else"
|
|
}
|
|
],
|
|
"checkall": "true",
|
|
"repair": false,
|
|
"outputs": 2,
|
|
"x": 1750,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"52882f5b.86b19"
|
|
],
|
|
[
|
|
"2ebec1ce.99f26e"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2ebec1ce.99f26e",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": "25e47f1f.a9a9d",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"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": [
|
|
[
|
|
"8e66e1ce.08ca6"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8e66e1ce.08ca6",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 310,
|
|
"y": 280,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "95ab8523.4c0378",
|
|
"type": "inject",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 100,
|
|
"y": 280,
|
|
"wires": [
|
|
[
|
|
"25e47f1f.a9a9d"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d8e15d86.7f87f",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 900,
|
|
"y": 440,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e4eb7b53.5e1f48",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 770,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "3d3f5c03.2d8a74",
|
|
"type": "change",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "pair",
|
|
"pt": "flow",
|
|
"to": "payload.pair",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "currency",
|
|
"pt": "flow",
|
|
"to": "payload.currency",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxVolume",
|
|
"pt": "flow",
|
|
"to": "payload.maxVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "minVolume",
|
|
"pt": "flow",
|
|
"to": "payload.minVolume",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "multiplier",
|
|
"pt": "flow",
|
|
"to": "payload.multiplier",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "maxBuyPrice",
|
|
"pt": "flow",
|
|
"to": "payload.maxBuyPrice",
|
|
"tot": "msg"
|
|
},
|
|
{
|
|
"t": "set",
|
|
"p": "delta",
|
|
"pt": "flow",
|
|
"to": "payload.delta",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 200,
|
|
"y": 500,
|
|
"wires": [
|
|
[
|
|
"5b03fb12.673c74"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8c5facab.8b6e8",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Recompute CoinBalance (sell)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet sellPrice = flow.get(\"bidPrice\");\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 560,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "db1110d5.0860c",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "Recompute CoinBalance (buy)",
|
|
"func": "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = flow.get(\"askPrice\"); \n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice,\"file\");\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 2770,
|
|
"y": 720,
|
|
"wires": [
|
|
[]
|
|
]
|
|
},
|
|
{
|
|
"id": "9a98519c.12f49",
|
|
"type": "add-standard-order",
|
|
"z": "3fba07ea.b0acd8",
|
|
"kraken": "e64b38bb.529c88",
|
|
"name": "Send Buy Order ",
|
|
"x": 2460,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"258764e0.79d46c",
|
|
"db1110d5.0860c"
|
|
],
|
|
[
|
|
"87ccdbf2.f0c7f8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "681dfe53.c121f",
|
|
"type": "function",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "dynamic Currency To fix Key",
|
|
"func": "let currency=flow.get('currency');\n\nif (msg.payload[currency]!==undefined) {\n msg.payload.balance=Number(msg.payload[currency]);\n}\n\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 820,
|
|
"y": 80,
|
|
"wires": [
|
|
[
|
|
"d9fafdd1.9f6ef",
|
|
"974054cb.f3c458"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "974054cb.f3c458",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1060,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9bf486c9.b6b328",
|
|
"type": "debug",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 1380,
|
|
"y": 160,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "5645cab6.8bf7c4",
|
|
"type": "inject",
|
|
"z": "3fba07ea.b0acd8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "3600",
|
|
"crontab": "",
|
|
"once": true,
|
|
"onceDelay": "10",
|
|
"x": 450,
|
|
"y": 40,
|
|
"wires": [
|
|
[
|
|
"2c667cd5.5eac84"
|
|
]
|
|
]
|
|
}
|
|
] |