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

Commit

Permalink
actually refresh the portfolio before displaying balance
Browse files Browse the repository at this point in the history
bugfix for gekko having a stale internal state which doesn't match the actual balance in portfolio
  • Loading branch information
kuzetsa committed Dec 5, 2013
1 parent fa9f8f2 commit 72ab99f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,24 @@ var Manager = function(conf, checker) {
this.emit('ready');
};

// callback function to refresh portfolio stats
var refreshPortfolio = function() {
// 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);
});
};

// refresh portfolio stats every 11 minutes
setInterval(_.bind(refreshPortfolio, this), util.minToMs( 11 ));
// 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,
Expand Down

0 comments on commit 72ab99f

Please sign in to comment.