Skip to content

Commit

Permalink
improve setting portfolio at poloniex
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Oct 14, 2016
1 parent ebeaf8e commit d7eb86b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions exchanges/poloniex.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ Trader.prototype.getPortfolio = function(callback) {
if(err)
return this.retry(this.getPortfolio, args);

var portfolio = [];
_.each(data, function(amount, asset) {

// because of the huge amounts of currencies, only
// include the ones relevant.
if(asset === this.currency || asset === this.asset)
portfolio.push({name: asset, amount: parseFloat(amount)});
}, this);
var assetAmount = parseFloat( data[this.asset] );
var currencyAmount = parseFloat( data[this.currency] );

if(!_.isNumber(assetAmount) || !_.isNumber(currencyAmount)) {
log.info('asset:', this.asset);
log.info('currency:', this.currency);
log.info('exchange data:', data);
util.die('Gekko was unable to set the portfolio');
}

var portfolio = [
{ name: this.asset, amount: assetAmount },
{ name: this.currency, amount: currencyAmount }
];

callback(err, portfolio);
}.bind(this);
Expand Down

0 comments on commit d7eb86b

Please sign in to comment.