Skip to content

Commit

Permalink
Fix issue with callbacks in portfolioManager
Browse files Browse the repository at this point in the history
There's cases where a callback can be missing to one of the
calls in the portfolioManager which caused an error (and halting the
trader). Added a check if we actually had a callback before triggering
it which keeps things running smoothly.
  • Loading branch information
iceydee authored and askmike committed Jan 21, 2014
1 parent ec50219 commit 1dbd59c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,26 @@ Util.inherits(Manager, events.EventEmitter);
Manager.prototype.setPortfolio = function(callback) {
var set = function(err, portfolio) {
this.portfolio = portfolio;
callback();
if (typeof(callback) === 'function')
callback();
};
this.exchange.getPortfolio(_.bind(set, this));
}

Manager.prototype.setFee = function(callback) {
var set = function(err, fee) {
this.fee = fee;
callback();
if (typeof(callback) === 'function')
callback();
};
this.exchange.getFee(_.bind(set, this));
}

Manager.prototype.setTicker = function(callback) {
var set = function(err, ticker) {
this.ticker = ticker;
callback();
if (typeof(callback) === 'function')
callback();
}
this.exchange.getTicker(_.bind(set, this));
}
Expand Down

0 comments on commit 1dbd59c

Please sign in to comment.