Add Trader#_consolidateTrades

This commit is contained in:
Maciej Małecki 2014-04-17 13:02:36 +02:00
parent 27f0119022
commit a6687964ba

View file

@ -163,6 +163,27 @@ Trader.prototype.tradeQueueFiatBalance = function (exchangeRate) {
return (satoshis / SATOSHI_FACTOR) * exchangeRate; return (satoshis / SATOSHI_FACTOR) * exchangeRate;
}; };
Trader.prototype._consolidateTrades = function () {
var queue = this._tradeQueue;
var tradeRec = {
fiat: 0,
satoshis: 0,
currency: 'USD'
};
while (true) {
var lastRec = queue.shift();
if (!lastRec) {
break;
}
tradeRec.fiat += lastRec.fiat;
tradeRec.satoshis += lastRec.satoshis;
tradeRec.currency = lastRec.currency;
}
return tradeRec;
};
Trader.prototype.startPolling = function () { Trader.prototype.startPolling = function () {
this.pollBalance(); this.pollBalance();
this.pollRate(); this.pollRate();