internal void OnExecutionReportLoaded(ExecutionReport report)
{
report.Order = report.Order ?? (report.OrderId == -1 ? ordersByClOrderId[report.ClOrderId] : ordersById[report.OrderId]);
report.Instrument = report.Order.Instrument;
report.ClientId = report.Order.ClientId;
var order = report.Order;
var orderStatus = order.Status;
Messages.Add(report);
order.OnExecutionReport(report);
if (orderStatus != order.Status)
this.framework.EventServer.OnOrderStatusChanged(order, true);
switch (report.ExecType)
{
case ExecType.ExecNew:
if (report.ClOrderId != null)
ordersByClOrderId[report.ClOrderId] = order;
this.framework.EventServer.OnNewOrder(order, true);
return;
case ExecType.ExecStopped:
case ExecType.ExecPendingCancel:
case ExecType.ExecPendingReplace:
break;
case ExecType.ExecRejected:
this.framework.EventServer.OnOrderRejected(order, true);
this.framework.EventServer.OnOrderDone(order, true);
CancelOCAOrder(order);
return;
case ExecType.ExecExpired:
this.framework.EventServer.OnOrderExpired(order, true);
this.framework.EventServer.OnOrderDone(order, true);
CancelOCAOrder(order);
return;
case ExecType.ExecTrade:
if (order.Status == OrderStatus.PartiallyFilled)
this.framework.EventServer.OnOrderPartiallyFilled(order, true);
else
{
this.framework.EventServer.OnOrderFilled(order, true);
this.framework.EventServer.OnOrderDone(order, true);
CancelOCAOrder(order);
}
return;
case ExecType.ExecCancelled:
this.framework.EventServer.OnOrderCancelled(order, true);
this.framework.EventServer.OnOrderDone(order, true);
CancelOCAOrder(order);
return;
case ExecType.ExecCancelReject:
this.framework.EventServer.OnOrderCancelRejected(order, true);
return;
case ExecType.ExecReplace:
this.framework.EventServer.OnOrderReplaced(order, true);
return;
case ExecType.ExecReplaceReject:
this.framework.EventServer.OnOrderReplaceRejected(order, true);
break;
default:
return;
}
}