Skip to content

Commit

Permalink
test:feat: validate FillPrice and FillQuantity in Base Brokerage Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Dec 26, 2024
1 parent eca4f5b commit ee0210a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Tests/Brokerages/BrokerageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,26 @@ private void HandleFillEvents(object sender, List<OrderEvent> 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:
Log.Trace($"{nameof(BrokerageTests)}.{nameof(HandleFillEvents)}: Not Recofgnize order Event Direction = {orderEvent.Direction}");
break;
}

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);

Expand Down

0 comments on commit ee0210a

Please sign in to comment.