Beispiel #1
0
        private void Recovers()
        {
            Recover <SnapshotOffer>(offer =>
            {
                if (offer.Snapshot is OrderbookSnapshot orderBook)
                {
                    _matchingEngine = MatchingEngine.FromSnapshot(orderBook, _log);
                }
            });

            Recover <Bid>(b => { _matchingEngine.WithBid(b); });
            Recover <Ask>(a => { _matchingEngine.WithAsk(a); });

            // Fill and Match can't modify the state of the MatchingEngine.
            Recover <Match>(m => { });
            Recover <Fill>(f => { });
        }
Beispiel #2
0
        public void ShouldRecreateFromNullOrderbookSnapshot()
        {
            var snapshot = new OrderbookSnapshot(TickerSymbol, DateTimeOffset.Now, 0.0d, 0.0d, null, null);
            var engine   = MatchingEngine.FromSnapshot(snapshot);

            var ask = new Ask(TickerSymbol, "foo", 12.0m, 5.0, DateTimeOffset.Now);

            // bid is lower than ask - no trades
            var bid = new Bid(TickerSymbol, "bar", 11.0m, 4.0, DateTimeOffset.Now);

            // verify that engine still works normally
            var bidEvents = engine.WithBid(bid);
            var askEvents = engine.WithAsk(ask);

            askEvents.Should().BeEmpty();
            bidEvents.Should().BeEmpty();

            engine.AskTrades.Count.Should().Be(1);
            engine.BidTrades.Count.Should().Be(1);
        }