Skip to content

Instantly share code, notes, and snippets.

@maxant
Last active August 29, 2015 14:12
Show Gist options
  • Save maxant/1b71358b41bf2fabeb68 to your computer and use it in GitHub Desktop.
Save maxant/1b71358b41bf2fabeb68 to your computer and use it in GitHub Desktop.
Trading cycle of engine
prepareMarket(self.market, timeout);
var sales = self.market.trade();
logger.info('trading completed');
noteMarketPricesAndVolumes(self.marketPrices, self.volumeRecords, sales);
persistSale(sales, function(err){
if(err) logger.warn(err);
else {
logger.info('persisting completed, notifying involved parties...');
_.each(sales, function(sale){
if(sale.buyer.event) sale.buyer.event(exports.EventType.PURCHASE, sale);
if(sale.seller.event) sale.seller.event(exports.EventType.SALE, sale);
});
}
...
setTimeout(loop, 0 + delay); //let the process handle other stuff too
...
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment