diff --git a/src/service/broker.ts b/src/service/broker.ts index 2e4790683..dd20ec28c 100644 --- a/src/service/broker.ts +++ b/src/service/broker.ts @@ -264,7 +264,7 @@ export class OrderBroker implements Interfaces.IOrderBroker { this._oeGateway.OrderUpdate.on(this.onOrderUpdate); - this._orderPersister.load(this._baseBroker.exchange(), this._baseBroker.pair).then(osrs => { + this._orderPersister.load(this._baseBroker.exchange(), this._baseBroker.pair, 25000).then(osrs => { _.each(osrs, osr => { this._exchIdsToClientIds[osr.exchangeId] = osr.orderId; @@ -279,7 +279,7 @@ export class OrderBroker implements Interfaces.IOrderBroker { this._log("loaded %d osrs from %d orders", this._allOrdersFlat.length, Object.keys(this._allOrders).length); }); - this._tradePersister.load(this._baseBroker.exchange(), this._baseBroker.pair).then(trades => { + this._tradePersister.load(this._baseBroker.exchange(), this._baseBroker.pair, 10000).then(trades => { _.each(trades, t => this._trades.push(t)); this._log("loaded %d trades", this._trades.length); }); diff --git a/src/service/persister.ts b/src/service/persister.ts index 1bfa309e9..5b8a5dc0e 100644 --- a/src/service/persister.ts +++ b/src/service/persister.ts @@ -24,11 +24,12 @@ export function loadDb() { export class Persister { _log : Utils.Logger = Utils.log("tribeca:exchangebroker:persister"); - public load = (exchange : Models.Exchange, pair : Models.CurrencyPair) : Q.Promise => { + public load = (exchange : Models.Exchange, pair : Models.CurrencyPair, limit : number = null) : Q.Promise => { var deferred = Q.defer(); this.collection.then(coll => { var selector = {exchange: exchange, pair: pair}; - coll.find(selector, (err, docs) => { + var options = (limit !== null ? {limit: limit}: {}); + coll.find(selector, options, (err, docs) => { if (err) deferred.reject(err); else { docs.toArray((err, arr) => {