public void FromOrderBook_1_Test() { const string source = "FakeExchange"; var timestamp = DateTime.UtcNow; var inverted = _btcusd.Invert(); var btcUsdOrderBook = new OrderBook(source, _btcusd, new List <LimitOrder> // bids { new LimitOrder(1 / 8825m, 9), new LimitOrder(1 / 8823m, 5) }, new List <LimitOrder> // asks { new LimitOrder(1 / 9000m, 10), new LimitOrder(1 / 8999.95m, 7), new LimitOrder(1 / 8900.12345677m, 3) }, timestamp); var synthOrderBook = SynthOrderBook.FromOrderBook(btcUsdOrderBook, inverted); Assert.Equal(source, synthOrderBook.Source); Assert.Equal(inverted, synthOrderBook.AssetPair); Assert.Equal("BTCUSD", synthOrderBook.ConversionPath); Assert.Equal(3, synthOrderBook.Bids.Count()); Assert.Equal(2, synthOrderBook.Asks.Count()); Assert.Equal(9000m, synthOrderBook.BestBid.Price, 8); Assert.Equal(8825m, synthOrderBook.Asks.Max(x => x.Price), 8); Assert.Equal(8900.12345677m, synthOrderBook.Bids.Min(x => x.Price), 8); Assert.Equal(8823m, synthOrderBook.BestAsk.Price, 8); Assert.Equal(0.00111111m, synthOrderBook.BestBid.Volume, 8); Assert.Equal(0.00101983m, synthOrderBook.Asks.Max(x => x.Volume), 8); Assert.Equal(0.00033707m, synthOrderBook.Bids.Min(x => x.Volume), 8); Assert.Equal(0.00056670m, synthOrderBook.BestAsk.Volume, 8); Assert.Equal(timestamp, synthOrderBook.Timestamp); Assert.Equal(1, synthOrderBook.OriginalOrderBooks.Count); }
public void FromOrderBook_0_Test() { const string source = "FakeExchange"; var timestamp = DateTime.UtcNow; var btcEurOrderBook = new OrderBook(source, _btceur, new List <LimitOrder> // bids { new LimitOrder(8825, 9), new LimitOrder(8823, 5) }, new List <LimitOrder> // asks { new LimitOrder(9000, 10), new LimitOrder(8999.95m, 7), new LimitOrder(8900.12345677m, 3) }, timestamp); var synthOrderBook = SynthOrderBook.FromOrderBook(btcEurOrderBook, _btceur); Assert.Equal(source, synthOrderBook.Source); Assert.Equal(_btceur, synthOrderBook.AssetPair); Assert.Equal("BTCEUR", synthOrderBook.ConversionPath); Assert.Equal(2, synthOrderBook.Bids.Count()); Assert.Equal(3, synthOrderBook.Asks.Count()); Assert.Equal(8825m, synthOrderBook.BestBid.Price); Assert.Equal(9000m, synthOrderBook.Asks.Max(x => x.Price)); Assert.Equal(8823m, synthOrderBook.Bids.Min(x => x.Price)); Assert.Equal(8900.12345677m, synthOrderBook.BestAsk.Price); Assert.Equal(9, synthOrderBook.BestBid.Volume); Assert.Equal(10, synthOrderBook.Asks.Max(x => x.Volume)); Assert.Equal(5, synthOrderBook.Bids.Min(x => x.Volume)); Assert.Equal(3, synthOrderBook.BestAsk.Volume); Assert.Equal(timestamp, synthOrderBook.Timestamp); Assert.Equal(1, synthOrderBook.OriginalOrderBooks.Count); }