|
[{"id":"9237c789.3558f8","type":"notify","title":"","name":"","x":908.4394721984863,"y":236.6212673187256,"wires":[]},{"id":"8b351a1e.4bf998","type":"function","name":"Make price object","func":"\nif ( ~msg.payload.indexOf('quote') ) { \n var quote = JSON.parse(msg.payload.slice(6,-2)).query.results.row;\n if (typeof quote.length == \"undefined\") { quote = [ quote ]; }\n for (var i=0; i < quote.length; i++) {\n var da = quote[i].date.split('/');\n quote[i].date = da[1]+'/'+da[0]+'/'+da[2];\n var ti = quote[i].time.split(':');\n var hr = parseInt(ti[0]);\n var mn = ti[1].slice(0,-2);\n var pm = ti[1].slice(-2);\n if (pm == \"pm\") { hr += 12; }\n quote[i].time = hr+\":\"+mn;\n quote[i].price = quote[i].price * 1;\n quote[i].change = quote[i].change * 1;\n quote[i].high = quote[i].high * 1 || \"N/A\";\n quote[i].low = quote[i].low * 1 || \"N/A\";\n quote[i].open = quote[i].col1 * 1 || \"N/A\";\n delete(quote[i].col1);\n quote[i].vol = quote[i].col2 * 1;\n delete(quote[i].col2);\n }\n if (quote.length == 1) { quote = quote[0]; }\n msg.payload = quote;\n msg2 = {topic:\"Stock Price\", payload:quote.symbol +\" is \"+quote.price};\n return [msg,msg2];\n}\nreturn null;","outputs":"2","x":714.5302963256836,"y":215.1666774749756,"wires":[["5791bbc4.9ab40c"],["9237c789.3558f8"]]},{"id":"a9d8f720.136c3","type":"httpget","name":"Get Quote","baseurl":"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes.csv%3Fs%3D","append":"%26f%3Dsl1d1t1c1ohgv%26e%3D.json'%20and%20columns%3D'symbol%2Cprice%2Cdate%2Ctime%2Cchange%2Ccol1%2Chigh%2Clow%2Ccol2'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=quote","x":538.439380645752,"y":215.62126636505127,"wires":[["8b351a1e.4bf998"]]},{"id":"5791bbc4.9ab40c","type":"debug","name":"","complete":true,"x":907.4394721984863,"y":193.62126636505127,"wires":[]},{"id":"8f99a64e.7bd208","type":"inject","name":"","topic":"","payload":"IBM","repeat":"600","once":true,"x":401.1666793823242,"y":215.1666774749756,"wires":[["a9d8f720.136c3"]]}] |
Should be modified to use HTTP Request node.