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

Refresh & log updated portfolio balance so that advice & trading is not based on old data #67

Merged
merged 2 commits into from
Dec 21, 2013
Merged
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
19 changes: 19 additions & 0 deletions portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ var Manager = function(conf, checker) {
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