public OnExecutionCommand ( |
||
command | ||
return | void |
public void Replace(Order order, double price, double stopPx, double qty) { if (order.IsNotSent) { throw new ArgumentException($"Can not replace order that is not sent {order}"); } var command = new ExecutionCommand(ExecutionCommandType.Replace, order) { DateTime = this.framework.Clock.DateTime, Id = order.Id, OrderId = order.Id, ClOrderId = order.ClOrderId, ProviderOrderId = order.ProviderOrderId, ProviderId = order.ProviderId, RouteId = order.RouteId, PortfolioId = order.PortfolioId, TransactTime = order.TransactTime, Instrument = order.Instrument, InstrumentId = order.InstrumentId, Provider = order.Provider, Portfolio = order.Portfolio, Side = order.Side, OrdType = order.Type, TimeInForce = order.TimeInForce, Price = order.Price, StopPx = order.StopPx, Qty = order.Qty, OCA = order.OCA, Text = order.Text, Account = order.Account, ClientID = order.ClientID, ClientId = order.ClientId }; Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); if (IsPersistent) { Server?.Save(command, -1); } order.Provider.Send(command); }
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); }
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); }
public void Send(Order order) { if (!order.IsNotSent) { throw new ArgumentException($"Can not send order that has been already sent {order}"); } this.framework.EventServer.OnSendOrder(order); if (order.Id == -1) { Register(order); } if (order.IsOCA) { List <Order> list; this.ordersByOCAList.TryGetValue(order.OCA, out list); this.ordersByOCAList[order.OCA] = list = list ?? new List <Order>(); list.Add(order); } Orders.Add(order); this.ordersById[order.Id] = order; if (this.framework.Mode == FrameworkMode.Realtime) { this.ordersByClOrderId[order.ClOrderId] = order; } order.DateTime = this.framework.Clock.DateTime; order.Status = OrderStatus.PendingNew; var command = new ExecutionCommand(ExecutionCommandType.Send, order) { DateTime = order.DateTime, Id = order.Id, OrderId = order.Id, ClOrderId = order.ClOrderId, ProviderOrderId = order.ProviderOrderId, ProviderId = order.ProviderId, RouteId = order.RouteId, PortfolioId = order.PortfolioId, TransactTime = order.TransactTime, Instrument = order.Instrument, InstrumentId = order.InstrumentId, Provider = order.Provider, Portfolio = order.Portfolio, Side = order.Side, OrdType = order.Type, TimeInForce = order.TimeInForce, Price = order.Price, StopPx = order.StopPx, Qty = order.Qty, OCA = order.OCA, Text = order.Text, Account = order.Account, ClientID = order.ClientID, ClientId = order.ClientId }; Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); this.framework.EventServer.OnPendingNewOrder(order, true); if (IsPersistent) { Server?.Save(command, -1); } order.Provider.Send(command); }
public void Load(string name = null, int clientId = -1) { var messages = LoadMessages(name, clientId); foreach (var msg in messages) { msg.IsLoaded = true; var typeId = msg.TypeId; switch (typeId) { case DataObjectType.ExecutionReport: this.framework.EventServer.OnExecutionReport((ExecutionReport)msg); break; case DataObjectType.ExecutionCommand: { var command = (ExecutionCommand)msg; switch (command.Type) { case ExecutionCommandType.Send: { var order = new Order(command); command.Order = order; command.Instrument = this.framework.InstrumentManager.GetById(command.InstrumentId); command.Portfolio = this.framework.PortfolioManager.GetById(command.PortfolioId); command.Provider = this.framework.ProviderManager.GetExecutionProvider(command.ProviderId); order.Instrument = command.Instrument; order.Portfolio = command.Portfolio; order.Provider = command.Provider; lock (this.obj) this.counter = Math.Max(this.counter, order.Id); this.framework.EventServer.OnSendOrder(order); Orders.Add(order); this.ordersById[order.Id] = order; if (this.framework.Mode == FrameworkMode.Realtime) { this.ordersByClOrderId[order.ClOrderId] = order; } Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); this.framework.EventServer.OnPendingNewOrder(order, true); break; } case ExecutionCommandType.Cancel: case ExecutionCommandType.Replace: this.ordersById[command.OrderId].OnExecutionCommand(command); break; } break; } default: if (typeId == DataObjectType.AccountReport) { this.framework.EventServer.OnAccountReport((AccountReport)msg); } break; } } }
public void Replace(Order order, double price, double stopPx, double qty) { if (order.IsNotSent) throw new ArgumentException($"Can not replace order that is not sent {order}"); var command = new ExecutionCommand(ExecutionCommandType.Replace, order) { DateTime = this.framework.Clock.DateTime, Id = order.Id, OrderId = order.Id, ClOrderId = order.ClOrderId, ProviderOrderId = order.ProviderOrderId, ProviderId = order.ProviderId, RouteId = order.RouteId, PortfolioId = order.PortfolioId, TransactTime = order.TransactTime, Instrument = order.Instrument, InstrumentId = order.InstrumentId, Provider = order.Provider, Portfolio = order.Portfolio, Side = order.Side, OrdType = order.Type, TimeInForce = order.TimeInForce, Price = order.Price, StopPx = order.StopPx, Qty = order.Qty, OCA = order.OCA, Text = order.Text, Account = order.Account, ClientID = order.ClientID, ClientId = order.ClientId }; Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); if (IsPersistent) Server?.Save(command, -1); order.Provider.Send(command); }
public void Send(Order order) { if (!order.IsNotSent) throw new ArgumentException($"Can not send order that has been already sent {order}"); this.framework.EventServer.OnSendOrder(order); if (order.Id == -1) Register(order); if (order.IsOCA) { List<Order> list; this.ordersByOCAList.TryGetValue(order.OCA, out list); this.ordersByOCAList[order.OCA] = list = list ?? new List<Order>(); list.Add(order); } Orders.Add(order); this.ordersById[order.Id] = order; if (this.framework.Mode == FrameworkMode.Realtime) this.ordersByClOrderId[order.ClOrderId] = order; order.DateTime = this.framework.Clock.DateTime; order.Status = OrderStatus.PendingNew; var command = new ExecutionCommand(ExecutionCommandType.Send, order) { DateTime = order.DateTime, Id = order.Id, OrderId = order.Id, ClOrderId = order.ClOrderId, ProviderOrderId = order.ProviderOrderId, ProviderId = order.ProviderId, RouteId = order.RouteId, PortfolioId = order.PortfolioId, TransactTime = order.TransactTime, Instrument = order.Instrument, InstrumentId = order.InstrumentId, Provider = order.Provider, Portfolio = order.Portfolio, Side = order.Side, OrdType = order.Type, TimeInForce = order.TimeInForce, Price = order.Price, StopPx = order.StopPx, Qty = order.Qty, OCA = order.OCA, Text = order.Text, Account = order.Account, ClientID = order.ClientID, ClientId = order.ClientId }; Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); this.framework.EventServer.OnPendingNewOrder(order, true); if (IsPersistent) Server?.Save(command, -1); order.Provider.Send(command); }
public void Load(string name = null, int clientId = -1) { var messages = LoadMessages(name, clientId); foreach (var msg in messages) { msg.IsLoaded = true; var typeId = msg.TypeId; switch (typeId) { case DataObjectType.ExecutionReport: this.framework.EventServer.OnExecutionReport((ExecutionReport)msg); break; case DataObjectType.ExecutionCommand: { var command = (ExecutionCommand)msg; switch (command.Type) { case ExecutionCommandType.Send: { var order = new Order(command); command.Order = order; command.Instrument = this.framework.InstrumentManager.GetById(command.InstrumentId); command.Portfolio = this.framework.PortfolioManager.GetById(command.PortfolioId); command.Provider = this.framework.ProviderManager.GetExecutionProvider(command.ProviderId); order.Instrument = command.Instrument; order.Portfolio = command.Portfolio; order.Provider = command.Provider; lock (this.obj) this.counter = Math.Max(this.counter, order.Id); this.framework.EventServer.OnSendOrder(order); Orders.Add(order); this.ordersById[order.Id] = order; if (this.framework.Mode == FrameworkMode.Realtime) this.ordersByClOrderId[order.ClOrderId] = order; Messages.Add(command); order.OnExecutionCommand(command); this.framework.EventServer.OnExecutionCommand(command); this.framework.EventServer.OnPendingNewOrder(order, true); break; } case ExecutionCommandType.Cancel: case ExecutionCommandType.Replace: this.ordersById[command.OrderId].OnExecutionCommand(command); break; } break; } default: if (typeId == DataObjectType.AccountReport) this.framework.EventServer.OnAccountReport((AccountReport)msg); break; } } }