Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #67 from kuzetsa/refresh-balance
Browse files Browse the repository at this point in the history
Refresh & log updated portfolio balance so that advice & trading is not based on old data
  • Loading branch information
askmike committed Dec 21, 2013
2 parents 9ed10bc + 72ab99f commit a212f15
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ var Manager = function(conf) {
this.emit('ready');
};

// callback function to DISPLAY portfolio stats
var refreshPortfolioBeforeYouCanDisplay = function() {
log.info('refreshed', this.exchange.name, 'portfolio:');
_.each(this.portfolio, function(fund) {
log.info('\t', fund.name + ':', fund.amount);
});
};

// callback function to REFRESH portfolio stats
var displayPortfolio = function() {
// lazy way to do it without a major rewrite
async.series([
this.setPortfolio
], _.bind(refreshPortfolioBeforeYouCanDisplay, this));
};

// refresh and display portfolio stats every 11 minutes
setInterval(_.bind(displayPortfolio, this), util.minToMs( 11 ));

async.series([
this.setPortfolio,
this.setFee
Expand Down

0 comments on commit a212f15

Please sign in to comment.