Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
The `stocks` module is a <a href="https://github.com/MichMich/MagicMirror">MagicMirror</a> addon.
This module displays a scrolling stocks ticker on your MagicMirror.

Data provided for free by <a href="https://iextrading.com/developer">IEX</a>


## Using the module

To use this module, add it to the modules array in the `config/config.js` file:
````javascript
modules: [
{
module: 'stocks',
{
module: 'stocks',
position: 'bottom_bar',
config: {
stocks: '.DJI,MSFT,AAPL,GOOG,INTC,CICS,TSLA,FB', // stock symbols
updateInterval: 37000 // update interval in milliseconds
}
}
config: {
stocks: 'MSFT,AAPL,GOOG,INTC,CICS,TSLA,FB', // stock symbols
updateInterval: 120000 // update interval in milliseconds
}
}
]
````

3 changes: 1 addition & 2 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = NodeHelper.create({

getStocks: function (url) {
var self = this;
console.log('requesting:' + url);
request({ url: url, method: 'GET' }, function (error, response, body) {
if (!error && response.statusCode == 200) {
var result = JSON.parse(body);
Expand All @@ -33,7 +32,6 @@ module.exports = NodeHelper.create({
var stockResults = [];

urls.forEach(url => {
console.log('url:' + url);
request({ url: url, method: 'GET' }, function (error, response, body) {
if (!error && response.statusCode == 200) {
stockResults.push(JSON.parse(body));
Expand All @@ -44,6 +42,7 @@ module.exports = NodeHelper.create({
}
else {
var err = error;
console.log('stocks fetch of url ' + url + ' failed (' + response.statusCode + ')');
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion stocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Module.register("stocks", {
var stocksArray = this.config.stocks.split(',');

stocksArray.forEach(function(stock) {
var requestUrl = url + stock + "/quote";
var requestUrl = url + encodeURIComponent(stock) + "/quote";
requestUrls.push(requestUrl);
});

Expand Down