bitstamp_ticker_flow.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. [{
  2. "id": "30e5a1df4ff2780a",
  3. "type": "inject",
  4. "z": "f6ebb8e404985534",
  5. "name": "Once a minute",
  6. "props": [{
  7. "p": "payload"
  8. }, {
  9. "p": "topic",
  10. "vt": "str"
  11. }, {
  12. "p": "timestamp",
  13. "v": "",
  14. "vt": "date"
  15. }
  16. ],
  17. "repeat": "60",
  18. "crontab": "",
  19. "once": false,
  20. "onceDelay": 0.1,
  21. "topic": "Bitstamp Ticker",
  22. "payload": "",
  23. "payloadType": "date",
  24. "x": 140,
  25. "y": 80,
  26. "wires": [["2bc9825b6248713e"]]
  27. }, {
  28. "id": "2bc9825b6248713e",
  29. "type": "http request",
  30. "z": "f6ebb8e404985534",
  31. "name": "",
  32. "method": "GET",
  33. "ret": "obj",
  34. "paytoqs": "ignore",
  35. "url": "https://www.bitstamp.net/api/v2/ticker/",
  36. "tls": "",
  37. "persist": false,
  38. "proxy": "",
  39. "insecureHTTPParser": false,
  40. "authType": "",
  41. "senderr": false,
  42. "headers": [],
  43. "x": 390,
  44. "y": 80,
  45. "wires": [["dffe92840fbff3bb"]]
  46. }, {
  47. "id": "d8824452cc11c4e7",
  48. "type": "debug",
  49. "z": "f6ebb8e404985534",
  50. "name": "DB Result",
  51. "active": true,
  52. "tosidebar": false,
  53. "console": false,
  54. "tostatus": true,
  55. "complete": "payload",
  56. "targetType": "msg",
  57. "statusVal": "payload",
  58. "statusType": "auto",
  59. "x": 880,
  60. "y": 260,
  61. "wires": []
  62. }, {
  63. "id": "dffe92840fbff3bb",
  64. "type": "function",
  65. "z": "f6ebb8e404985534",
  66. "name": "splitTickers",
  67. "func": "var outputMsgs = [];\n\nmsg.payload.forEach(myFunction);\n\nfunction myFunction(value) {\n outputMsgs.push({ payload: value, timestamp: msg.timestamp });\n}\n\nreturn [outputMsgs];",
  68. "outputs": 1,
  69. "noerr": 0,
  70. "initialize": "",
  71. "finalize": "",
  72. "libs": [],
  73. "x": 570,
  74. "y": 80,
  75. "wires": [["969cb4bae1c4c259"]]
  76. }, {
  77. "id": "ee5f8710c0a6b568",
  78. "type": "comment",
  79. "z": "f6ebb8e404985534",
  80. "name": "splitting the JSON Object",
  81. "info": "The ticker is split into individual json objects and passed on as messages ... ",
  82. "x": 610,
  83. "y": 40,
  84. "wires": []
  85. }, {
  86. "id": "97961487e6cdb936",
  87. "type": "http request",
  88. "z": "f6ebb8e404985534",
  89. "name": "QuestDB Query",
  90. "method": "GET",
  91. "ret": "txt",
  92. "paytoqs": "query",
  93. "url": "http://192.168.0.200:9000/exec",
  94. "tls": "",
  95. "persist": false,
  96. "proxy": "",
  97. "insecureHTTPParser": false,
  98. "authType": "",
  99. "senderr": false,
  100. "headers": [],
  101. "x": 860,
  102. "y": 220,
  103. "wires": [["d8824452cc11c4e7"]]
  104. }, {
  105. "id": "969cb4bae1c4c259",
  106. "type": "function",
  107. "z": "f6ebb8e404985534",
  108. "name": "BuildSQL",
  109. "func": "/*\ntimestamp: \"1671032171\"\nopen: \"3.82\"\nhigh: \"3.88\"\nlow: \"3.75\"\nlast: \"3.82\"\nvolume: \"3337.54\"\nvwap: \"3.82\"\nbid: \"3.81\"\nask: \"3.83\"\nopen_24: \"3.88\"\npercent_change_24: \"-1.55\"\npair: \"APE/EUR\"\n\n\n \nVALUES(\n '2021-10-05T11:31:35.878Z',\n 'AAPL',\n 255,\n 123.33,\n 'B');\n\n */\nvar q = {};\nvar symbol = msg.payload.pair.replace(\"/\", \"_\");\n\n// q[\"query\"] = \"select temp_c, humidity, timestamp from iot where timestamp > (systimestamp() - 5000000)\"\nq[\"query\"] = \"INSERT INTO bs_ticker_\" + symbol + \n \" VALUES(\" + msg.payload.open + \",\" + \n \"\" + msg.payload.high + \",\" +\n \"\" + msg.payload.low + \",\" +\n \"\" + msg.payload.last + \",\" +\n \"\" + msg.payload.volume + \",\" +\n \"\" + msg.payload.bid + \",\" +\n \"\" + msg.payload.ask + \",\" +\n \"\" + msg.payload.open_24 + \",\" +\n \"\" + msg.payload.percent_change_24 + \",\" +\n \"\" + msg.timestamp*1000 + \");\";\nmsg.payload = q\nreturn msg;",
  110. "outputs": 1,
  111. "noerr": 0,
  112. "initialize": "",
  113. "finalize": "",
  114. "libs": [],
  115. "x": 580,
  116. "y": 120,
  117. "wires": [["97961487e6cdb936"]]
  118. }, {
  119. "id": "15d2128a7f055492",
  120. "type": "inject",
  121. "z": "f6ebb8e404985534",
  122. "name": "On deploy",
  123. "props": [{
  124. "p": "payload"
  125. }, {
  126. "p": "topic",
  127. "vt": "str"
  128. }, {
  129. "p": "timestamp",
  130. "v": "",
  131. "vt": "date"
  132. }
  133. ],
  134. "repeat": "",
  135. "crontab": "",
  136. "once": true,
  137. "onceDelay": 0.1,
  138. "topic": "Bitstamp Ticker",
  139. "payload": "",
  140. "payloadType": "date",
  141. "x": 130,
  142. "y": 240,
  143. "wires": [["38d461c4972558c8"]]
  144. }, {
  145. "id": "38d461c4972558c8",
  146. "type": "http request",
  147. "z": "f6ebb8e404985534",
  148. "name": "",
  149. "method": "GET",
  150. "ret": "obj",
  151. "paytoqs": "ignore",
  152. "url": "https://www.bitstamp.net/api/v2/ticker/",
  153. "tls": "",
  154. "persist": false,
  155. "proxy": "",
  156. "insecureHTTPParser": false,
  157. "authType": "",
  158. "senderr": false,
  159. "headers": [],
  160. "x": 390,
  161. "y": 240,
  162. "wires": [["d49e767fdb202e20"]]
  163. }, {
  164. "id": "d49e767fdb202e20",
  165. "type": "function",
  166. "z": "f6ebb8e404985534",
  167. "name": "splitTickers",
  168. "func": "var outputMsgs = [];\n\nmsg.payload.forEach(myFunction);\n\nfunction myFunction(value) {\n outputMsgs.push({ payload: value, timestamp: msg.timestamp });\n}\n\nreturn [outputMsgs];",
  169. "outputs": 1,
  170. "noerr": 0,
  171. "initialize": "",
  172. "finalize": "",
  173. "libs": [],
  174. "x": 570,
  175. "y": 240,
  176. "wires": [["b8345a0484d5c611"]]
  177. }, {
  178. "id": "b8345a0484d5c611",
  179. "type": "function",
  180. "z": "f6ebb8e404985534",
  181. "name": "BuildSQL-CreateTables",
  182. "func": "/*\ntimestamp: \"1671032171\"\nopen: \"3.82\"\nhigh: \"3.88\"\nlow: \"3.75\"\nlast: \"3.82\"\nvolume: \"3337.54\"\nvwap: \"3.82\"\nbid: \"3.81\"\nask: \"3.83\"\nopen_24: \"3.88\"\npercent_change_24: \"-1.55\"\npair: \"APE/EUR\"\n\nCREATE TABLE my_table(symb SYMBOL, price DOUBLE, ts TIMESTAMP, s STRING)\n timestamp(ts);\n */\n\nvar q = {};\n// q[\"query\"] = \"select temp_c, humidity, timestamp from iot where timestamp > (systimestamp() - 5000000)\"\nvar symbol = msg.payload.pair.replace(\"/\", \"_\");\nq[\"query\"] = \n \"CREATE TABLE IF NOT EXISTS bs_ticker_\" + symbol + \"(open DOUBLE, high DOUBLE, low DOUBLE, last DOUBLE, volume DOUBLE, bid DOUBLE, ask DOUBLE, open_24 DOUBLE, percent_change_24 DOUBLE, ts TIMESTAMP)timestamp(ts);\";\nmsg.payload = q\nreturn msg;",
  183. "outputs": 1,
  184. "noerr": 0,
  185. "initialize": "",
  186. "finalize": "",
  187. "libs": [],
  188. "x": 530,
  189. "y": 280,
  190. "wires": [["97961487e6cdb936"]]
  191. }, {
  192. "id": "067fb692727bf8c9",
  193. "type": "catch",
  194. "z": "f6ebb8e404985534",
  195. "name": "Catch All",
  196. "scope": null,
  197. "uncaught": true,
  198. "x": 840,
  199. "y": 80,
  200. "wires": [["f38c603f653186cb"]]
  201. }, {
  202. "id": "650da83460d687c3",
  203. "type": "function",
  204. "z": "f6ebb8e404985534",
  205. "name": "BuildSQL-DropTables",
  206. "func": "/*\ntimestamp: \"1671032171\"\nopen: \"3.82\"\nhigh: \"3.88\"\nlow: \"3.75\"\nlast: \"3.82\"\nvolume: \"3337.54\"\nvwap: \"3.82\"\nbid: \"3.81\"\nask: \"3.83\"\nopen_24: \"3.88\"\npercent_change_24: \"-1.55\"\npair: \"APE/EUR\"\n\nCREATE TABLE my_table(symb SYMBOL, price DOUBLE, ts TIMESTAMP, s STRING)\n timestamp(ts);\n */\n\nvar q = {};\n// q[\"query\"] = \"select temp_c, humidity, timestamp from iot where timestamp > (systimestamp() - 5000000)\"\nvar symbol = msg.payload.pair.replace(\"/\", \"_\");\nq[\"query\"] = \n \"DROP TABLE bs_ticker_\" + symbol + \";\";\nmsg.payload = q\nreturn msg;",
  207. "outputs": 1,
  208. "noerr": 0,
  209. "initialize": "",
  210. "finalize": "",
  211. "libs": [],
  212. "x": 540,
  213. "y": 380,
  214. "wires": [["97961487e6cdb936"]]
  215. }, {
  216. "id": "78f1d48e24430395",
  217. "type": "inject",
  218. "z": "f6ebb8e404985534",
  219. "name": "When you click",
  220. "props": [{
  221. "p": "payload"
  222. }, {
  223. "p": "topic",
  224. "vt": "str"
  225. }, {
  226. "p": "timestamp",
  227. "v": "",
  228. "vt": "date"
  229. }
  230. ],
  231. "repeat": "",
  232. "crontab": "",
  233. "once": false,
  234. "onceDelay": 0.1,
  235. "topic": "Bitstamp Ticker",
  236. "payload": "",
  237. "payloadType": "date",
  238. "x": 140,
  239. "y": 340,
  240. "wires": [["1841c9fc5cf66ce2"]]
  241. }, {
  242. "id": "1841c9fc5cf66ce2",
  243. "type": "http request",
  244. "z": "f6ebb8e404985534",
  245. "name": "",
  246. "method": "GET",
  247. "ret": "obj",
  248. "paytoqs": "ignore",
  249. "url": "https://www.bitstamp.net/api/v2/ticker/",
  250. "tls": "",
  251. "persist": false,
  252. "proxy": "",
  253. "insecureHTTPParser": false,
  254. "authType": "",
  255. "senderr": false,
  256. "headers": [],
  257. "x": 390,
  258. "y": 340,
  259. "wires": [["11038880c4bdabe5"]]
  260. }, {
  261. "id": "11038880c4bdabe5",
  262. "type": "function",
  263. "z": "f6ebb8e404985534",
  264. "name": "splitTickers",
  265. "func": "var outputMsgs = [];\n\nmsg.payload.forEach(myFunction);\n\nfunction myFunction(value) {\n outputMsgs.push({ payload: value, timestamp: msg.timestamp });\n}\n\nreturn [outputMsgs];",
  266. "outputs": 1,
  267. "noerr": 0,
  268. "initialize": "",
  269. "finalize": "",
  270. "libs": [],
  271. "x": 570,
  272. "y": 340,
  273. "wires": [["650da83460d687c3"]]
  274. }, {
  275. "id": "e2b640df5c6bd091",
  276. "type": "comment",
  277. "z": "f6ebb8e404985534",
  278. "name": "The Loop",
  279. "info": "Here we get the ticker everz minute and store the results in the db",
  280. "x": 100,
  281. "y": 40,
  282. "wires": []
  283. }, {
  284. "id": "b2b559311fe4e399",
  285. "type": "comment",
  286. "z": "f6ebb8e404985534",
  287. "name": "Create Tables - If not exist",
  288. "info": "Here we get the ticker and create a table for each pair",
  289. "x": 150,
  290. "y": 200,
  291. "wires": []
  292. }, {
  293. "id": "8d9caa02581087b1",
  294. "type": "comment",
  295. "z": "f6ebb8e404985534",
  296. "name": "Drop Tables - This will delete all data!",
  297. "info": "Here we get the ticker and drop the table for each pair",
  298. "x": 190,
  299. "y": 300,
  300. "wires": []
  301. }, {
  302. "id": "f38c603f653186cb",
  303. "type": "debug",
  304. "z": "f6ebb8e404985534",
  305. "name": "Errors",
  306. "active": true,
  307. "tosidebar": true,
  308. "console": false,
  309. "tostatus": false,
  310. "complete": "payload",
  311. "targetType": "msg",
  312. "statusVal": "",
  313. "statusType": "auto",
  314. "x": 850,
  315. "y": 120,
  316. "wires": []
  317. }
  318. ]