Skip to content

Commit

Permalink
Minor brokerage testing improvements (#8209)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored Jul 18, 2024
1 parent ba626f1 commit 3bdde74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Brokerages/Brokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ protected bool TryHandleRemainingCrossZeroOrder(Order leanOrder, OrderEvent orde
catch (Exception err)
{
Log.Error(err);
OnMessage(new BrokerageMessageEvent(BrokerageMessageType.Warning, "CrossZeroOrderError", "An error occurred while trying to submit an cross zero order: " + err));
OnMessage(new BrokerageMessageEvent(BrokerageMessageType.Warning, "CrossZeroOrderError", "Error occurred submitting cross zero order: " + err.Message));
OnOrderEvent(new OrderEvent(leanOrder, DateTime.UtcNow, OrderFee.Zero) { Status = OrderStatus.Canceled });
}
#pragma warning restore CA1031 // Do not catch general exception types
Expand Down
1 change: 1 addition & 0 deletions Common/Orders/OrderEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public OrderEvent(Order order, DateTime utcTime, OrderFee orderFee, string messa
OrderId = order.Id;
Symbol = order.Symbol;
Status = order.Status;
Quantity = order.Quantity;
Direction = order.Direction;

//Initialize to zero, manually set fill quantity
Expand Down
3 changes: 2 additions & 1 deletion Tests/Brokerages/BrokerageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void HandleFillEvents(object sender, List<OrderEvent> ordeEvents)
_securityProvider[orderEvent.Symbol].Holdings.SetHoldings(orderEvent.FillPrice, orderEvent.FillQuantity);
}

Log.Trace("--HOLDINGS: " + _securityProvider[orderEvent.Symbol]);
Log.Trace("--HOLDINGS: " + _securityProvider[orderEvent.Symbol].Holdings);

// update order mapping
var order = _orderProvider.GetOrderById(orderEvent.OrderId);
Expand Down Expand Up @@ -314,6 +314,7 @@ public virtual void CancelOrders(OrderTestParameters parameters)
using var canceledOrderStatusEvent = new ManualResetEvent(false);
EventHandler<List<OrderEvent>> orderStatusCallback = (sender, fills) =>
{
order.Status = fills.First().Status;
if (fills[0].Status == OrderStatus.Canceled)
{
canceledOrderStatusEvent.Set();
Expand Down

0 comments on commit 3bdde74

Please sign in to comment.