/// <summary> /// Processes a new fill, eventually creating new trades /// </summary> /// <param name="fill">The new fill order event</param> /// <param name="conversionRate">The current market conversion rate into the account currency</param> public void ProcessFill(OrderEvent fill, decimal conversionRate) { // If we have multiple fills per order, we assign the order fee only to its first fill // to avoid counting the same order fee multiple times. var orderFee = 0m; if (!_ordersWithFeesAssigned.Contains(fill.OrderId)) { orderFee = fill.OrderFee; _ordersWithFeesAssigned.Add(fill.OrderId); } switch (_groupingMethod) { case FillGroupingMethod.FillToFill: ProcessFillUsingFillToFill(fill.Clone(), orderFee, conversionRate); break; case FillGroupingMethod.FlatToFlat: ProcessFillUsingFlatToFlat(fill.Clone(), orderFee, conversionRate); break; case FillGroupingMethod.FlatToReduced: ProcessFillUsingFlatToReduced(fill.Clone(), orderFee, conversionRate); break; } }