Start adding trading back to Trader
This commit is contained in:
parent
8cb9783bde
commit
b79bdf8789
1 changed files with 14 additions and 0 deletions
|
|
@ -16,6 +16,8 @@ var Trader = module.exports = function (db) {
|
|||
this.logger = new (winston.Logger)({
|
||||
transports: [new (winston.transports.Console)()]
|
||||
});
|
||||
|
||||
this._tradeQueue = [];
|
||||
};
|
||||
|
||||
Trader.prototype._findExchange = function (name) {
|
||||
|
|
@ -149,6 +151,18 @@ Trader.prototype.sendBitcoins = function (deviceFingerprint, tx, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
Trader.prototype.trade = function (fiat, satoshis, currency, callback) {
|
||||
this._tradeQueue.push({fiat: fiat, satoshis: satoshis, currency: currency});
|
||||
callback(null);
|
||||
};
|
||||
|
||||
Trader.prototype.tradeQueueFiatBalance = function (exchangeRate) {
|
||||
var satoshis = this._tradeQueue.reduce(function (memo, rec) {
|
||||
return memo + rec.satoshis;
|
||||
}, 0);
|
||||
return (satoshis / SATOSHI_FACTOR) * exchangeRate;
|
||||
};
|
||||
|
||||
Trader.prototype.startPolling = function () {
|
||||
this.pollBalance();
|
||||
this.pollRate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue