diff --git a/Tests/Brokerages/BrokerageTests.cs b/Tests/Brokerages/BrokerageTests.cs index 362b492a41ca..42792064a2a2 100644 --- a/Tests/Brokerages/BrokerageTests.cs +++ b/Tests/Brokerages/BrokerageTests.cs @@ -156,8 +156,25 @@ private void HandleFillEvents(object sender, List ordeEvents) OrderFillEvent.Set(); } + var eventFillPrice = orderEvent.FillPrice; + var eventFillQuantity = orderEvent.FillQuantity; + + Assert.Greater(eventFillPrice, 0m); + + switch (orderEvent.Direction) + { + case OrderDirection.Buy: + Assert.Greater(eventFillQuantity, 0m); + break; + case OrderDirection.Sell: + Assert.Less(eventFillQuantity, 0m); + break; + default: + throw new ArgumentException($"{nameof(BrokerageTests)}.{nameof(HandleFillEvents)}: Not Recognize order Event Direction = {orderEvent.Direction}"); + } + var holding = SecurityProvider.GetSecurity(orderEvent.Symbol).Holdings; - holding.SetHoldings(orderEvent.FillPrice, holding.Quantity + orderEvent.FillQuantity); + holding.SetHoldings(eventFillPrice, holding.Quantity + eventFillQuantity); Log.Trace("--HOLDINGS: " + _securityProvider[orderEvent.Symbol].Holdings);