Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Add check to end simulation and add drain function properly #1977

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions commands/sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ module.exports = function (program, conf) {
setImmediate(async () => await getNext())
}

if(totalTrades === 0) {
onCollectionCursorEnd()
}

collectionCursorStream.on('data', function(trade) {
lastTrade = trade
numTrades++
Expand Down
4 changes: 2 additions & 2 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,12 @@ module.exports = function (s, conf) {
update: onTrades,
exit: function (cb) {
if(tradeProcessingQueue.length()){
tradeProcessingQueue.drain = () => {
tradeProcessingQueue.drain(() => {
if(s.strategy.onExit) {
s.strategy.onExit.call( s.ctx, s )
}
cb()
}
})
} else {
if(s.strategy.onExit) {
s.strategy.onExit.call( s.ctx, s )
Expand Down