Add Trader#_consolidateTrades
This commit is contained in:
parent
27f0119022
commit
a6687964ba
1 changed files with 21 additions and 0 deletions
|
|
@ -163,6 +163,27 @@ Trader.prototype.tradeQueueFiatBalance = function (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 () {
|
||||
this.pollBalance();
|
||||
this.pollRate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue