688 lines
17 KiB
JSON
688 lines
17 KiB
JSON
[
|
|
{
|
|
"id": "6d543cb4.ed3084",
|
|
"type": "tab",
|
|
"label": "Kraken Trading",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "42702610.230028",
|
|
"type": "kraken-credentials",
|
|
"z": "",
|
|
"name": "DFLT"
|
|
},
|
|
{
|
|
"id": "c0dcbde0.3085",
|
|
"type": "sqlitedb",
|
|
"z": "",
|
|
"db": "KrakenTradingDB.sqlite3",
|
|
"mode": "RW"
|
|
},
|
|
{
|
|
"id": "b8c92875.131c58",
|
|
"type": "get-server-time",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"x": 310,
|
|
"y": 240,
|
|
"wires": [
|
|
[
|
|
"63e56415.01466c"
|
|
],
|
|
[
|
|
"1637654a.83336b"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d11eed52.456ac",
|
|
"type": "inject",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 120,
|
|
"y": 240,
|
|
"wires": [
|
|
[
|
|
"b8c92875.131c58"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "63e56415.01466c",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 550,
|
|
"y": 220,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1637654a.83336b",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 560,
|
|
"y": 320,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "978bdbc5.1c3508",
|
|
"type": "get-account-balance",
|
|
"z": "6d543cb4.ed3084",
|
|
"kraken": "42702610.230028",
|
|
"name": "",
|
|
"x": 340,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"5fd28dbd.7d1504"
|
|
],
|
|
[
|
|
"8d9b208b.f68a7"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5fd28dbd.7d1504",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Kraken-Balance",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 600,
|
|
"y": 460,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "8d9b208b.f68a7",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "Kraken Balance ERROR",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": true,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 630,
|
|
"y": 540,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "586b4d14.eca6f4",
|
|
"type": "inject",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "18000",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 130,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"978bdbc5.1c3508"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "a669c08c.d0185",
|
|
"type": "sqlite",
|
|
"z": "6d543cb4.ed3084",
|
|
"mydb": "c0dcbde0.3085",
|
|
"sqlquery": "msg.topic",
|
|
"sql": "",
|
|
"name": "",
|
|
"x": 890,
|
|
"y": 720,
|
|
"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": 600,
|
|
"y": 760,
|
|
"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": 830,
|
|
"y": 780,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "b6c88df3.41573",
|
|
"type": "get-ticker-information",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"x": 350,
|
|
"y": 1040,
|
|
"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": "60",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 160,
|
|
"y": 1040,
|
|
"wires": [
|
|
[
|
|
"b6c88df3.41573"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8f27b1c3.3277e",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 590,
|
|
"y": 880,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "57c6ead4.4943d4",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "false",
|
|
"x": 530,
|
|
"y": 1080,
|
|
"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": 560,
|
|
"y": 1020,
|
|
"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": 840,
|
|
"y": 960,
|
|
"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": 1050,
|
|
"y": 1100,
|
|
"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": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1400,
|
|
"y": 1020,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9073f8dd.8a8558",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "lt (buy)",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "true",
|
|
"targetType": "full",
|
|
"x": 1390,
|
|
"y": 1100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1bc0ea09.db8676",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "small",
|
|
"active": false,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1370,
|
|
"y": 1240,
|
|
"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": 760,
|
|
"y": 1180,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "37af9cb0.cd7d74",
|
|
"type": "inject",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": false,
|
|
"onceDelay": 0.1,
|
|
"x": 660,
|
|
"y": 940,
|
|
"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": 1500,
|
|
"y": 1060,
|
|
"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": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1800,
|
|
"y": 1100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "db4dcb29.89cd38",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "SELLING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1720,
|
|
"y": 1020,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "9ff35104.7db0d",
|
|
"type": "debug",
|
|
"z": "6d543cb4.ed3084",
|
|
"name": "BUYING!",
|
|
"active": true,
|
|
"tosidebar": true,
|
|
"console": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1700,
|
|
"y": 1180,
|
|
"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": 1500,
|
|
"y": 1200,
|
|
"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": false,
|
|
"tostatus": false,
|
|
"complete": "payload",
|
|
"targetType": "msg",
|
|
"x": 1780,
|
|
"y": 1260,
|
|
"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');\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": 890,
|
|
"y": 1100,
|
|
"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": 1710,
|
|
"y": 980,
|
|
"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": 1700,
|
|
"y": 1140,
|
|
"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": 1730,
|
|
"y": 1060,
|
|
"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": 1710,
|
|
"y": 1220,
|
|
"wires": [
|
|
[]
|
|
]
|
|
}
|
|
] |