FX by 1 min

This flow pulls FX(EURUSD, USDJPY, ..) information in every 1 minutes, and show them with debug node. You can add some kind of DB(Cloudant out, for example) node at the bottom of flow, then you can save those information in that DB.

[{"id":"4c5d29dc.9f9578","type":"tab","label":"FX by 1min","disabled":false,"info":""},{"id":"b1b11140.4e4ef","type":"inject","z":"4c5d29dc.9f9578","name":"","topic":"","payload":"Every 1 min.","payloadType":"str","repeat":"","crontab":"*/1 0-23 * * *","once":false,"onceDelay":"","x":141,"y":61,"wires":[["d5a57d99.f0188"]]},{"id":"f2f2649a.0d0d98","type":"debug","z":"4c5d29dc.9f9578","name":"","active":true,"console":"false","complete":"false","x":530,"y":180,"wires":[]},{"id":"d5a57d99.f0188","type":"http request","z":"4c5d29dc.9f9578","name":"FX info","method":"GET","ret":"txt","paytoqs":false,"url":"http://www.gaitame.com/rate/neo20/rate_UTF8.asp","tls":"","persist":false,"proxy":"","authType":"","x":140,"y":180,"wires":[["25f8eff8.20688"]]},{"id":"25f8eff8.20688","type":"function","z":"4c5d29dc.9f9578","name":"JSON for Cloudant","func":"var lines = msg.payload.split( \"\\r\" ).join( \"\" ).split( \"\\n\" );\n\nvar dt = new Date();\nvar yyyy = dt.getFullYear();\nvar mm = dt.getMonth() + 1;\nvar dd = dt.getDate();\nvar hh = dt.getHours();\nvar nn = dt.getMinutes();\nvar ss = dt.getSeconds();\nvar tz = dt.getTimezoneOffset() / -60;\nvar datetime = yyyy + '-' + ( mm < 10 ? '0' : '' ) + mm + '-' + ( dd < 10 ? '0' : '' ) + dd\n  + ' ' + ( hh < 10 ? '0' : '' ) + hh + ':' + ( nn < 10 ? '0' : '' ) + nn + ':' + ( ss < 10 ? '0' : '' ) + ss\n  + ( tz >= 0 ? '+' : '-' ) + Math.abs( tz );\nvar rate = { _id: datetime };\n\nfor( var i = 0; i < lines.length; i ++ ){\n  var line = lines[i];\n  var x = line.split( \",\" );\n  if( x.length > 1 ){\n    var name = x[0];\n    var bid = x[1];\n    rate[name] = parseFloat( bid );\n  }\n}\n\nmsg.payload = rate;\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":180,"wires":[["f2f2649a.0d0d98"]]}]

Flow Info

Created 5 months, 1 week ago
Rating: not yet rated

Owner

Node Types

Core
  • debug (x1)
  • function (x1)
  • http request (x1)
  • inject (x1)
  • tab (x1)

Tags

  • fx
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option