2020-01-05 19:16:13 -06:00
[
{
"id" : "6d543cb4.ed3084" ,
"type" : "tab" ,
2020-01-08 20:25:22 -06:00
"label" : "Simulation Dynamic HF Trading" ,
2020-01-07 19:20:08 -06:00
"disabled" : false ,
"info" : ""
} ,
{
"id" : "5d834238.9ad88c" ,
"type" : "tab" ,
"label" : "Weekly Ethereum buy" ,
2020-01-05 19:16:13 -06:00
"disabled" : false ,
"info" : ""
} ,
2020-01-07 09:22:34 -06:00
{
"id" : "d8e8a587.a39408" ,
"type" : "tab" ,
"label" : "HTML Queries" ,
"disabled" : false ,
"info" : ""
} ,
2020-01-07 19:20:08 -06:00
{
"id" : "e67f589a.f8d378" ,
"type" : "tab" ,
"label" : "Misc" ,
"disabled" : false ,
"info" : ""
} ,
2020-01-08 20:25:22 -06:00
{
"id" : "75185287.024c5c" ,
"type" : "tab" ,
"label" : "LiveDynHF-ETC" ,
"disabled" : false ,
"info" : ""
} ,
2020-01-07 09:22:34 -06:00
{
"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"
} ,
2020-01-05 19:16:13 -06:00
{
"id" : "42702610.230028" ,
"type" : "kraken-credentials" ,
"z" : "" ,
"name" : "DFLT"
} ,
{
"id" : "c0dcbde0.3085" ,
"type" : "sqlitedb" ,
"z" : "" ,
"db" : "KrakenTradingDB.sqlite3" ,
"mode" : "RW"
} ,
2020-01-07 09:22:34 -06:00
{
"id" : "4378beea.a2c7f" ,
"type" : "sqlitedb" ,
"z" : "" ,
"db" : "KrakenTradingDB.sqlite3" ,
"mode" : "RWC"
} ,
2020-01-05 19:16:13 -06:00
{
2020-01-07 19:20:08 -06:00
"id" : "e64b38bb.529c88" ,
"type" : "kraken-credentials" ,
"z" : "" ,
"name" : "DFLT"
2020-01-05 19:16:13 -06:00
} ,
{
"id" : "a669c08c.d0185" ,
"type" : "sqlite" ,
"z" : "6d543cb4.ed3084" ,
"mydb" : "c0dcbde0.3085" ,
"sqlquery" : "msg.topic" ,
"sql" : "" ,
"name" : "" ,
2020-01-07 19:20:08 -06:00
"x" : 1010 ,
"y" : 120 ,
2020-01-05 19:16:13 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 720 ,
"y" : 160 ,
2020-01-05 19:16:13 -06:00
"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" ,
2020-01-07 19:20:08 -06:00
"x" : 950 ,
"y" : 180 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "b6c88df3.41573" ,
"type" : "get-ticker-information" ,
"z" : "6d543cb4.ed3084" ,
"name" : "" ,
2020-01-07 19:20:08 -06:00
"x" : 470 ,
"y" : 440 ,
2020-01-06 20:57:03 -06:00
"wires" : [
[
"8f27b1c3.3277e" ,
"1a447d86.305162" ,
"4f94e60f.4d3838"
] ,
[
"57c6ead4.4943d4"
]
]
} ,
{
"id" : "b131c158.9b6e5" ,
"type" : "inject" ,
"z" : "6d543cb4.ed3084" ,
"name" : "" ,
"topic" : "" ,
"payload" : "{\"pair\":\"XETCZUSD\"}" ,
"payloadType" : "json" ,
2020-01-08 20:25:22 -06:00
"repeat" : "" ,
2020-01-06 20:57:03 -06:00
"crontab" : "" ,
"once" : false ,
"onceDelay" : 0.1 ,
2020-01-07 19:20:08 -06:00
"x" : 280 ,
"y" : 440 ,
2020-01-06 20:57:03 -06:00
"wires" : [
[
"b6c88df3.41573"
]
]
} ,
{
"id" : "8f27b1c3.3277e" ,
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
"name" : "" ,
"active" : false ,
"tosidebar" : true ,
"console" : false ,
"tostatus" : false ,
"complete" : "false" ,
2020-01-07 19:20:08 -06:00
"x" : 710 ,
"y" : 280 ,
2020-01-05 19:16:13 -06:00
"wires" : [ ]
} ,
{
2020-01-06 20:57:03 -06:00
"id" : "57c6ead4.4943d4" ,
2020-01-05 19:16:13 -06:00
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
2020-01-07 09:22:34 -06:00
"name" : "Ticker Retrieval Error" ,
2020-01-05 19:16:13 -06:00
"active" : true ,
"tosidebar" : true ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
2020-01-07 09:22:34 -06:00
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 630 ,
"y" : 500 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 680 ,
"y" : 420 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 960 ,
"y" : 360 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1170 ,
"y" : 500 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-05 19:16:13 -06:00
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
2020-01-07 19:20:08 -06:00
"x" : 1520 ,
"y" : 420 ,
2020-01-05 19:16:13 -06:00
"wires" : [ ]
2020-01-06 20:57:03 -06:00
} ,
{
"id" : "9073f8dd.8a8558" ,
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
"name" : "lt (buy)" ,
"active" : true ,
"tosidebar" : true ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
2020-01-07 19:20:08 -06:00
"x" : 1520 ,
"y" : 500 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "1bc0ea09.db8676" ,
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
"name" : "small" ,
"active" : false ,
"tosidebar" : true ,
"console" : false ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 1490 ,
"y" : 640 ,
2020-01-06 20:57:03 -06:00
"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" ,
2020-01-07 19:20:08 -06:00
"x" : 880 ,
"y" : 580 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "37af9cb0.cd7d74" ,
"type" : "inject" ,
"z" : "6d543cb4.ed3084" ,
"name" : "" ,
"topic" : "" ,
"payload" : "" ,
"payloadType" : "date" ,
"repeat" : "" ,
"crontab" : "" ,
"once" : false ,
"onceDelay" : 0.1 ,
2020-01-07 19:20:08 -06:00
"x" : 780 ,
"y" : 340 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1620 ,
"y" : 460 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 1920 ,
"y" : 500 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "db4dcb29.89cd38" ,
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
"name" : "SELLING!" ,
"active" : true ,
"tosidebar" : true ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 1850 ,
"y" : 420 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "9ff35104.7db0d" ,
"type" : "debug" ,
"z" : "6d543cb4.ed3084" ,
"name" : "BUYING!" ,
"active" : true ,
"tosidebar" : true ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 1830 ,
"y" : 580 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1620 ,
"y" : 600 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 09:22:34 -06:00
"console" : true ,
2020-01-06 20:57:03 -06:00
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
2020-01-07 19:20:08 -06:00
"x" : 1910 ,
"y" : 660 ,
2020-01-06 20:57:03 -06:00
"wires" : [ ]
} ,
{
"id" : "3fcb4bfe.6d4b84" ,
"type" : "function" ,
"z" : "6d543cb4.ed3084" ,
"name" : "Determine Action" ,
2020-01-08 20:25:22 -06:00
"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;" ,
2020-01-06 20:57:03 -06:00
"outputs" : 1 ,
"noerr" : 0 ,
2020-01-08 20:25:22 -06:00
"x" : 990 ,
2020-01-07 19:20:08 -06:00
"y" : 500 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1830 ,
"y" : 380 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1820 ,
"y" : 540 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1850 ,
"y" : 460 ,
2020-01-06 20:57:03 -06:00
"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 ,
2020-01-07 19:20:08 -06:00
"x" : 1830 ,
"y" : 620 ,
2020-01-06 20:57:03 -06:00
"wires" : [
[ ]
]
2020-01-07 09:22:34 -06:00
} ,
{
"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"
]
]
2020-01-07 19:20:08 -06:00
} ,
{
"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" ,
2020-01-08 20:25:22 -06:00
"name" : "Wednesdays, 10am" ,
2020-01-07 19:20:08 -06:00
"topic" : "" ,
"payload" : "{\"pair\":\"XETHZUSD\"}" ,
"payloadType" : "json" ,
"repeat" : "" ,
2020-01-08 20:25:22 -06:00
"crontab" : "00 10 * * 3" ,
2020-01-07 19:20:08 -06:00
"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"
]
]
2020-01-08 20:25:22 -06:00
} ,
{
"id" : "46878dfa.5580c4" ,
"type" : "inject" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"topic" : "" ,
"payload" : "{\"pair\":\"XETCZUSD\"}" ,
"payloadType" : "json" ,
"repeat" : "60" ,
"crontab" : "" ,
"once" : false ,
"onceDelay" : 0.1 ,
"x" : 140 ,
"y" : 420 ,
"wires" : [
[
"8aa9f7f4.8c2668"
]
]
} ,
{
"id" : "8aa9f7f4.8c2668" ,
"type" : "switch" ,
"z" : "75185287.024c5c" ,
"name" : "isInitialized?" ,
"property" : "$flowContext('isInitialized')" ,
"propertyType" : "jsonata" ,
"rules" : [
{
"t" : "true"
} ,
{
"t" : "else"
}
] ,
"checkall" : "true" ,
"repair" : false ,
"outputs" : 2 ,
"x" : 390 ,
"y" : 420 ,
"wires" : [
[
"69f7851b.bdc39c"
] ,
[
"a99eaee4.37596" ,
"21e109cf.713d56"
]
]
} ,
{
"id" : "55be5c77.c5aa24" ,
"type" : "change" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"rules" : [
{
"t" : "set" ,
"p" : "isInitialized" ,
"pt" : "flow" ,
"to" : "true" ,
"tot" : "bool"
} ,
{
"t" : "set" ,
"p" : "coinBalance" ,
"pt" : "flow" ,
"to" : "payload.XETC" ,
"tot" : "msg"
} ,
{
"t" : "set" ,
"p" : "maxVolume" ,
"pt" : "flow" ,
"to" : "10" ,
"tot" : "num"
} ,
{
"t" : "set" ,
"p" : "minVolume" ,
"pt" : "flow" ,
"to" : "0" ,
2020-01-08 21:47:16 -06:00
"tot" : "num"
2020-01-08 20:25:22 -06:00
} ,
{
"t" : "set" ,
"p" : "delta" ,
"pt" : "flow" ,
"to" : "0.1" ,
"tot" : "num"
} ,
{
"t" : "set" ,
"p" : "multiplier" ,
"pt" : "flow" ,
2020-01-08 21:47:16 -06:00
"to" : "1" ,
"tot" : "num"
2020-01-08 20:25:22 -06:00
}
] ,
"action" : "" ,
"property" : "" ,
"from" : "" ,
"to" : "" ,
"reg" : false ,
"x" : 1180 ,
"y" : 80 ,
"wires" : [
[
"89274697.2db938"
]
]
} ,
{
"id" : "a99eaee4.37596" ,
"type" : "get-account-balance" ,
"z" : "75185287.024c5c" ,
"kraken" : "e64b38bb.529c88" ,
"name" : "" ,
"x" : 600 ,
"y" : 120 ,
"wires" : [
[
"df0504ca.1b5e68"
] ,
[
"d35cbfeb.3029" ,
"aceb2bba.402fa8"
]
]
} ,
{
"id" : "df0504ca.1b5e68" ,
"type" : "switch" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"property" : "payload.XETC" ,
"propertyType" : "msg" ,
"rules" : [
{
"t" : "nempty"
} ,
{
"t" : "else"
}
] ,
"checkall" : "true" ,
"repair" : false ,
"outputs" : 2 ,
"x" : 770 ,
"y" : 80 ,
"wires" : [
[
"55be5c77.c5aa24"
] ,
[
"957f8c8.49e1d7"
]
]
} ,
{
"id" : "957f8c8.49e1d7" ,
"type" : "change" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"rules" : [
{
"t" : "set" ,
"p" : "payload.XETC" ,
"pt" : "msg" ,
"to" : "0" ,
"tot" : "num"
}
] ,
"action" : "" ,
"property" : "" ,
"from" : "" ,
"to" : "" ,
"reg" : false ,
"x" : 940 ,
"y" : 120 ,
"wires" : [
[
"55be5c77.c5aa24"
]
]
} ,
{
"id" : "89274697.2db938" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Initialized." ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 1370 ,
"y" : 80 ,
"wires" : [ ]
} ,
{
"id" : "d35cbfeb.3029" ,
"type" : "delay" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"pauseType" : "delay" ,
"timeout" : "5" ,
"timeoutUnits" : "seconds" ,
"rate" : "1" ,
"nbRateUnits" : "1" ,
"rateUnits" : "second" ,
"randomFirst" : "1" ,
"randomLast" : "5" ,
"randomUnits" : "seconds" ,
"drop" : false ,
"x" : 600 ,
"y" : 180 ,
"wires" : [
[
"a99eaee4.37596"
]
]
} ,
{
"id" : "aceb2bba.402fa8" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
2020-01-08 21:47:16 -06:00
"name" : "Error getting Balance - retrying infinite." ,
2020-01-08 20:25:22 -06:00
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
2020-01-08 21:47:16 -06:00
"x" : 940 ,
2020-01-08 20:25:22 -06:00
"y" : 160 ,
"wires" : [ ]
} ,
{
"id" : "8072675b.525b98" ,
"type" : "inject" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"topic" : "" ,
"payload" : "" ,
"payloadType" : "date" ,
"repeat" : "" ,
"crontab" : "" ,
"once" : false ,
"onceDelay" : 0.1 ,
"x" : 100 ,
"y" : 80 ,
"wires" : [
[
"6a2a4e21.ffc76"
]
]
} ,
{
"id" : "6a2a4e21.ffc76" ,
"type" : "change" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"rules" : [
{
"t" : "delete" ,
"p" : "isInitialized" ,
"pt" : "flow"
}
] ,
"action" : "" ,
"property" : "" ,
"from" : "" ,
"to" : "" ,
"reg" : false ,
"x" : 340 ,
"y" : 80 ,
"wires" : [
[ ]
]
} ,
{
"id" : "af95f15e.3e857" ,
"type" : "comment" ,
"z" : "75185287.024c5c" ,
2020-01-08 21:47:16 -06:00
"name" : "Force-Uninitialize (Reload settings)" ,
2020-01-08 20:25:22 -06:00
"info" : "" ,
2020-01-08 21:47:16 -06:00
"x" : 160 ,
2020-01-08 20:25:22 -06:00
"y" : 40 ,
"wires" : [ ]
} ,
{
"id" : "69f7851b.bdc39c" ,
"type" : "get-ticker-information" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"x" : 630 ,
"y" : 640 ,
"wires" : [
[
"24025058.051ac" ,
"d302c81.a8b0a38"
] ,
[
"a886187f.3229b8"
]
]
} ,
{
"id" : "a886187f.3229b8" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Ticker Retrieval Error" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 890 ,
"y" : 760 ,
"wires" : [ ]
} ,
{
"id" : "1d957ceb.c40d73" ,
"type" : "switch" ,
"z" : "75185287.024c5c" ,
"name" : "Action" ,
"property" : "action" ,
"propertyType" : "msg" ,
"rules" : [
{
"t" : "eq" ,
"v" : "sell" ,
"vt" : "str"
} ,
{
"t" : "eq" ,
"v" : "buy" ,
"vt" : "str"
} ,
{
"t" : "else"
}
] ,
"checkall" : "true" ,
"repair" : false ,
"outputs" : 3 ,
"x" : 1090 ,
"y" : 680 ,
"wires" : [
[
"3e2250ef.405d5" ,
"b29e9a85.c0f208"
] ,
[
"800f6d47.f091b" ,
"cc5f7279.5f84b"
] ,
[
"7028479c.9a21b8"
]
]
} ,
{
"id" : "3e2250ef.405d5" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "gt (sell)" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 1520 ,
"y" : 600 ,
"wires" : [ ]
} ,
{
"id" : "800f6d47.f091b" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "lt (buy)" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 1520 ,
"y" : 740 ,
"wires" : [ ]
} ,
{
"id" : "7028479c.9a21b8" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "small diff (nothing)" ,
"active" : false ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 1560 ,
"y" : 900 ,
"wires" : [ ]
} ,
{
"id" : "b29e9a85.c0f208" ,
"type" : "switch" ,
"z" : "75185287.024c5c" ,
"name" : "MinReached?" ,
2020-01-08 21:47:16 -06:00
"property" : " $flowContext('multiplier') - $flowContext('coinBalance') " ,
"propertyType" : "jsonata" ,
2020-01-08 20:25:22 -06:00
"rules" : [
{
2020-01-08 21:47:16 -06:00
"t" : "gte" ,
2020-01-08 20:25:22 -06:00
"v" : "minVolume" ,
"vt" : "flow"
} ,
{
"t" : "else"
}
] ,
"checkall" : "true" ,
"repair" : false ,
"outputs" : 2 ,
"x" : 1540 ,
"y" : 640 ,
"wires" : [
[
"277a2c5d.908d54"
] ,
[
"be56cf39.afb4e"
]
]
} ,
{
"id" : "24a6d9cc.fc2466" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Not Selling, min Volume reached." ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 2000 ,
"y" : 640 ,
"wires" : [ ]
} ,
{
"id" : "52986989.ee2b38" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "SELLING!" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 1950 ,
"y" : 500 ,
"wires" : [ ]
} ,
{
"id" : "a25291a9.35e33" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "BUYING!" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 1970 ,
"y" : 700 ,
"wires" : [ ]
} ,
{
"id" : "cc5f7279.5f84b" ,
"type" : "switch" ,
"z" : "75185287.024c5c" ,
"name" : "MaxReached?" ,
2020-01-08 21:47:16 -06:00
"property" : "$flowContext('coinBalance') + $flowContext('multiplier')" ,
"propertyType" : "jsonata" ,
2020-01-08 20:25:22 -06:00
"rules" : [
{
2020-01-08 21:47:16 -06:00
"t" : "lte" ,
2020-01-08 20:25:22 -06:00
"v" : "maxVolume" ,
"vt" : "flow"
} ,
{
"t" : "else"
}
] ,
"checkall" : "true" ,
"repair" : false ,
"outputs" : 2 ,
"x" : 1540 ,
"y" : 780 ,
"wires" : [
[
"6e38bc3.4922b44"
] ,
[
"b770e41f.d48838"
]
]
} ,
{
"id" : "c3c9ab5b.c535c8" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Not buying, max Volume reached." ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "payload" ,
"targetType" : "msg" ,
"x" : 2030 ,
"y" : 800 ,
"wires" : [ ]
} ,
{
"id" : "24025058.051ac" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "Determine Action" ,
"func" : "//$number(payload.XETCZUSD.a[0]) - $number($flowContext('lastExecPrice'))\n\nconst delta=flow.get('delta'); // how much price move to take action?\nlet askPrice=msg.payload.XETCZUSD.a[0];\nlet bidPrice=msg.payload.XETCZUSD.b[0];\nlet lastExecPrice=flow.get('lastExecPrice');\nif (lastExecPrice === undefined) { \n lastExecPrice=askPrice; \n flow.set('lastExecPrice',lastExecPrice);\n}\n\nmsg.lastExecPrice=lastExecPrice;\n\nif (bidPrice>lastExecPrice+delta) {\n msg.action=\"sell\";\n msg.price=bidPrice;\n} else if (askPrice<lastExecPrice-delta) {\n msg.action=\"buy\";\n msg.price=askPrice;\n} else {\n msg.action=\"nothing\";\n}\n\nreturn msg;" ,
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 910 ,
"y" : 680 ,
"wires" : [
[
"1d957ceb.c40d73"
]
]
} ,
{
"id" : "6e38bc3.4922b44" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "BuyAction" ,
2020-01-08 21:47:16 -06:00
"func" : "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\nlet buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\ncoinBalance += multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',buyPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'buy',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;" ,
2020-01-08 20:25:22 -06:00
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 1740 ,
"y" : 740 ,
"wires" : [
[
"a25291a9.35e33" ,
"ab124111.85da6"
]
]
} ,
{
"id" : "be56cf39.afb4e" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "NoSellAction" ,
"func" : "let sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\nflow.set('lastExecPrice',sellPrice);\n\nreturn msg;" ,
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 1770 ,
"y" : 640 ,
"wires" : [
[
"24a6d9cc.fc2466"
]
]
} ,
{
"id" : "b770e41f.d48838" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "NoBuyAction" ,
"func" : "let buyPrice = Number(msg.payload.XETCZUSD.a[0]);\n\nflow.set('lastExecPrice',buyPrice);\n\nreturn msg;" ,
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 1750 ,
"y" : 800 ,
"wires" : [
[
"c3c9ab5b.c535c8"
]
]
} ,
{
"id" : "277a2c5d.908d54" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "SellAction" ,
2020-01-08 21:47:16 -06:00
"func" : "let coinBalance = flow.get('coinBalance');\nlet delta = flow.get('delta');\nlet multiplier = Number(flow.get('multiplier'));\n\nlet sellPrice = Number(msg.payload.XETCZUSD.b[0]);\n\ncoinBalance -= multiplier;\n\nflow.set('coinBalance',coinBalance);\nflow.set('lastExecPrice',sellPrice);\n\nmsg.payload={\n\tpair : 'XETCZUSD',\n\ttype : 'sell',\n\tordertype : 'market',\n\tvolume : multiplier\n};\n\nreturn msg;" ,
2020-01-08 20:25:22 -06:00
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 1760 ,
"y" : 560 ,
"wires" : [
[
"52986989.ee2b38" ,
"ab124111.85da6"
]
]
} ,
{
"id" : "f637b849.b81cd8" ,
"type" : "sqlite" ,
"z" : "75185287.024c5c" ,
"mydb" : "c0dcbde0.3085" ,
"sqlquery" : "msg.topic" ,
"sql" : "" ,
"name" : "" ,
"x" : 1150 ,
"y" : 500 ,
"wires" : [
[ ]
]
} ,
{
"id" : "d302c81.a8b0a38" ,
"type" : "function" ,
"z" : "75185287.024c5c" ,
"name" : "Build Insert Statement" ,
"func" : "msg.topic=\"Insert into KrakenQuotes (Symbol,Data) values ('XETCZUSD','\" + JSON.stringify(msg.payload.XETCZUSD) + \"');\"\nreturn msg;" ,
"outputs" : 1 ,
"noerr" : 0 ,
"x" : 860 ,
"y" : 540 ,
"wires" : [
[
"b134e494.b4e6c8" ,
"f637b849.b81cd8"
]
]
} ,
{
"id" : "b134e494.b4e6c8" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"active" : false ,
"tosidebar" : true ,
"console" : false ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 1090 ,
"y" : 560 ,
"wires" : [ ]
} ,
{
"id" : "fcc5965e.257558" ,
"type" : "comment" ,
"z" : "75185287.024c5c" ,
"name" : "Initialization" ,
"info" : "" ,
"x" : 510 ,
"y" : 300 ,
"wires" : [ ]
} ,
{
"id" : "52d1add7.1a1144" ,
"type" : "comment" ,
"z" : "75185287.024c5c" ,
"name" : "Regular Looping" ,
"info" : "" ,
"x" : 520 ,
"y" : 580 ,
"wires" : [ ]
} ,
{
"id" : "ab124111.85da6" ,
"type" : "add-standard-order" ,
"z" : "75185287.024c5c" ,
"kraken" : "e64b38bb.529c88" ,
"name" : "" ,
"x" : 2410 ,
"y" : 680 ,
"wires" : [
[
"1191bbfb.c728d4"
] ,
[
"96991058.9ed6d"
]
]
} ,
{
"id" : "1191bbfb.c728d4" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Order Execution Success" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 2650 ,
"y" : 660 ,
"wires" : [ ]
} ,
{
"id" : "96991058.9ed6d" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Order Execution Error" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 2650 ,
"y" : 700 ,
"wires" : [ ]
} ,
{
"id" : "21e109cf.713d56" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "Needs Initialization" ,
"active" : true ,
"tosidebar" : true ,
"console" : true ,
"tostatus" : false ,
"complete" : "true" ,
"targetType" : "full" ,
"x" : 640 ,
"y" : 220 ,
"wires" : [ ]
2020-01-08 21:47:16 -06:00
} ,
{
"id" : "bfbcb0ec.f032c" ,
"type" : "debug" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"active" : true ,
"tosidebar" : true ,
"console" : false ,
"tostatus" : false ,
"complete" : "$flowContext('coinBalance') / $flowContext('multiplier')" ,
"targetType" : "jsonata" ,
"x" : 300 ,
"y" : 200 ,
"wires" : [ ]
} ,
{
"id" : "8b60b992.9a6258" ,
"type" : "inject" ,
"z" : "75185287.024c5c" ,
"name" : "" ,
"topic" : "" ,
"payload" : "" ,
"payloadType" : "date" ,
"repeat" : "" ,
"crontab" : "" ,
"once" : false ,
"onceDelay" : 0.1 ,
"x" : 110 ,
"y" : 200 ,
"wires" : [
[
"bfbcb0ec.f032c"
]
]
} ,
{
"id" : "72e50f95.f5f68" ,
"type" : "comment" ,
"z" : "75185287.024c5c" ,
"name" : "Get current \"standardized balance\"" ,
"info" : "" ,
"x" : 160 ,
"y" : 140 ,
"wires" : [ ]
2020-01-05 19:16:13 -06:00
}
]