public void TestIncreaseDecreaseAsk() { var depth = new Depth(); var cc = new ChangedChecker(depth); depth.AddOrder(1236, 300, false); Assert.True(cc.VerifyAskChanged(true, false, false, false, false)); cc.Reset(); depth.AddOrder(1235, 200, false); Assert.True(cc.VerifyAskChanged(true, true, false, false, false)); cc.Reset(); depth.AddOrder(1232, 100, false); Assert.True(cc.VerifyAskChanged(true, true, true, false, false)); cc.Reset(); depth.AddOrder(1235, 400, false); Assert.True(cc.VerifyAskChanged(false, true, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, 37, false); Assert.True(cc.VerifyAskChanged(false, false, true, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1235, -41, false); Assert.True(cc.VerifyAskChanged(false, true, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1232, 51, false); Assert.True(cc.VerifyAskChanged(true, false, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, -41, false); Assert.True(cc.VerifyAskChanged(false, false, true, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, 201, false); Assert.True(cc.VerifyAskChanged(false, false, true, false, false)); cc.Reset(); var ask0 = depth.Asks.First().Value; var ask1 = depth.Asks.ElementAt(1).Value; var ask2 = depth.Asks.ElementAt(2).Value; Assert.True(VerifyLevel(ask0, 1232, 1, 151)); Assert.True(VerifyLevel(ask1, 1235, 2, 559)); Assert.True(VerifyLevel(ask2, 1236, 1, 497)); Assert.Equal(3, depth.Asks.Count); }
public void TestIncreaseDecreaseBid() { var depth = new Depth(); var cc = new ChangedChecker(depth); depth.AddOrder(1236, 300, true); Assert.True(cc.VerifyBidChanged(true, false, false, false, false)); cc.Reset(); depth.AddOrder(1235, 200, true); Assert.True(cc.VerifyBidChanged(false, true, false, false, false)); cc.Reset(); depth.AddOrder(1232, 100, true); Assert.True(cc.VerifyBidChanged(false, false, true, false, false)); cc.Reset(); depth.AddOrder(1235, 400, true); Assert.True(cc.VerifyBidChanged(false, true, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, 37, true); Assert.True(cc.VerifyBidChanged(true, false, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1235, -41, true); Assert.True(cc.VerifyBidChanged(false, true, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1232, 60, true); Assert.True(cc.VerifyBidChanged(false, false, true, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, -41, true); Assert.True(cc.VerifyBidChanged(true, false, false, false, false)); cc.Reset(); depth.ChangeOrderQuantity(1236, 210, true); Assert.True(cc.VerifyBidChanged(true, false, false, false, false)); cc.Reset(); var bid0 = depth.Bids.ElementAt(0).Value; var bid1 = depth.Bids.ElementAt(1).Value; var bid2 = depth.Bids.ElementAt(2).Value; Assert.True(VerifyLevel(bid0, 1236, 1, 506)); Assert.True(VerifyLevel(bid1, 1235, 2, 559)); Assert.True(VerifyLevel(bid2, 1232, 1, 160)); Assert.Equal(3, depth.Bids.Count); }
public void ChangeSellOrderQuantityTest_ChecksIfMethodRemovesQuantityAsSpecified_AssertsVolumeForTheExpectedChangedLevel() { Depth depth = new Depth("XBT/USD", 10); depth.AddOrder(new Price(490), new Volume(100), OrderSide.Sell); depth.AddOrder(new Price(491), new Volume(100), OrderSide.Sell); depth.AddOrder(new Price(492), new Volume(200), OrderSide.Sell); DepthLevel resultingDepthLevel = (from depthLevel in depth.AskLevels where depthLevel.Price != null && depthLevel.Price.Value == 492 select depthLevel).ToList().Single(); // By only removing 100 volume from 200, we still have the depth level with a volume of 100 depth.ChangeOrderQuantity(new Price(492), -100, OrderSide.Sell); Assert.IsTrue(depth.AskLevels.Contains(resultingDepthLevel)); Assert.AreEqual(100, resultingDepthLevel.AggregatedVolume.Value, "Remaining volume after first decrease"); Assert.AreEqual(1, resultingDepthLevel.OrderCount, "Remaining volume after first decrease"); // By removing the remaining 100 volume, we wont have any volume left so the level needs to be removed depth.ChangeOrderQuantity(new Price(492), -100, OrderSide.Sell); Assert.IsFalse(depth.AskLevels.Contains(resultingDepthLevel)); }