google-stocks-watch
Stock ticker to pull the latest stock data and calculate gain or loss based on the purchase. Based on google-stocks NPM
Install
$ npm install google-stocks-watch --save
API
GoogleStocksWatch(options, callback)
constructor to initialize Google Stocks Watch
options
- options for the module
options.timerInterval
- (optional) how often ticker callback will be executed (in milliseconds) (default 10000)
options.stocks
- object containing initial stock purchase
stock.amount
- amount of purchased stocks
stock.price
- initial price
callback
- function callback to be executed every timerInterval
milliseconds. Has 2 arguments: error
and data
start()
function to start time ticker
stop()
function to stop time ticker
stocks
property which contains initial stocks
object
Usage
var GoogleStocksWatch = require('google-stocks-watch'),
googleStocksWatch;
var config = {
timerInterval: 8000,
stocks: {
'AAPL': {
amount: '2',
price: '130.10'
},
'GOOG': {
amount: '10',
price: '520.55'
}
}
};
googleStocksWatch = new GoogleStocksWatch(config, function(err, data) {
console.log(data);
});
googleStocksWatch.start();
returned format looks like this:
Example
npm run example
License
MIT license; see LICENSE.