private void HandleReplace(ExecutionCommand command)
{
var order = command.Order;
if (this.summariesByOrderId[order.Id] != null && IsOrderDone(this.summariesByOrderId[order.Id].OrdStatus))
{
this.ExecOrderReplaceReject(order, "Order already done");
return;
}
var report = new ExecutionReport
{
DateTime = this.framework.Clock.DateTime,
Order = order,
OrderId = order.Id,
Instrument = order.Instrument,
InstrumentId = order.InstrumentId,
ExecType = ExecType.ExecReplace,
OrdStatus = OrderStatus.Replaced,
CurrencyId = order.Instrument.CurrencyId,
OrdType = order.Type,
Side = order.Side,
CumQty = order.CumQty,
LastQty = 0.0,
LeavesQty = command.Qty - order.CumQty,
LastPx = 0.0,
AvgPx = 0.0
};
report.OrdType = order.Type;
report.Price = command.Price;
report.StopPx = command.StopPx;
report.OrdQty = command.Qty;
report.TimeInForce = order.TimeInForce;
report.Text = order.Text;
this.summariesByOrderId[order.Id] = new ReportSummary(report);
EmitExecutionReport(report, Queued);
}