Skip to content

Commit

Permalink
Retry exchange operations before failing.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreialecu authored and askmike committed Jul 24, 2017
1 parent 919eb1a commit 52b105e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions plugins/trader/portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Manager.prototype.setPortfolio = function(callback) {

}.bind(this);

this.exchange.getPortfolio(set);
util.retry(this.exchange.getPortfolio, set);
};

Manager.prototype.setFee = function(callback) {
Expand All @@ -104,17 +104,20 @@ Manager.prototype.setFee = function(callback) {
if(_.isFunction(callback))
callback();
}.bind(this);
this.exchange.getFee(set);
util.retry(this.exchange.getFee, set);
};

Manager.prototype.setTicker = function(callback) {
var set = function(err, ticker) {
this.ticker = ticker;

if(err)
util.die(err);

if(_.isFunction(callback))
callback();
}.bind(this);
this.exchange.getTicker(set);
util.retry(this.exchange.getTicker, set);
};

// return the [fund] based on the data we have in memory
Expand Down Expand Up @@ -225,7 +228,9 @@ Manager.prototype.buy = function(amount, price) {
amount,
this.asset,
'at',
this.exchange.name
this.exchange.name,
'price:',
price
);
this.exchange.buy(amount, price, this.noteOrder);
};
Expand Down Expand Up @@ -270,7 +275,9 @@ Manager.prototype.sell = function(amount, price) {
amount,
this.asset,
'at',
this.exchange.name
this.exchange.name,
'price:',
price
);
this.exchange.sell(amount, price, this.noteOrder);
};
Expand Down

0 comments on commit 52b105e

Please sign in to comment.