public void Cancel(Order order)
{
if (order.IsNotSent)
throw new ArgumentException($"Can not cancel order that is not sent {order}");
var command = new ExecutionCommand(ExecutionCommandType.Cancel, order)
{
DateTime = this.framework.Clock.DateTime,
OrderId = order.Id,
ClOrderId = order.ClOrderId,
ProviderOrderId = order.ProviderOrderId,
ProviderId = order.ProviderId,
RouteId = order.RouteId,
PortfolioId = order.PortfolioId
};
command.DateTime = order.DateTime;
command.Instrument = order.Instrument;
command.InstrumentId = order.InstrumentId;
command.Provider = order.Provider;
command.Portfolio = order.Portfolio;
command.Side = order.Side;
command.OrdType = order.Type;
command.TimeInForce = order.TimeInForce;
command.Price = order.Price;
command.StopPx = order.StopPx;
command.Qty = order.Qty;
command.OCA = order.OCA;
command.Text = order.Text;
command.Account = order.Account;
command.ClientID = order.ClientID;
command.ClientId = order.ClientId;
Messages.Add(command);
order.OnExecutionCommand(command);
this.framework.EventServer.OnExecutionCommand(command);
if (IsPersistent)
Server?.Save(command, -1);
order.Provider.Send(command);
}