public Order OnExecutionCommand(ExecutionCommand command) { Order order = this.orders[command.Id]; if (order == null) { order = new Order(); this.orders[command.Id] = order; order.dateTime = command.dateTime; order.id = command.id; order.providerId = command.providerId; order.portfolioId = command.portfolioId; order.transactTime = command.transactTime; order.instrument = command.instrument; order.provider = command.provider; order.portfolio = command.portfolio; order.side = command.side; order.type = command.orderType; order.timeInForce = command.timeInForce; order.price = command.price; order.stopPx = command.stopPx; order.qty = command.qty; order.oCA = command.oCA; order.text = command.text; } command.order = order; order.OnExecutionCommand(command); return order; }
public virtual void Send(ExecutionCommand command) { switch (command.Type) { case ExecutionCommandType.Send: this.OnSendCommand(command); return; case ExecutionCommandType.Cancel: this.OnCancelCommand(command); return; case ExecutionCommandType.Replace: this.OnReplaceCommand(command); return; default: return; } }
public override void Send(ExecutionCommand command) { SellSideStrategy sellSideStrategy = this.strategyBySynthInstrument[command.order.instrument.Id]; switch (command.Type) { case ExecutionCommandType.Send: sellSideStrategy.OnSendCommand(command); return; case ExecutionCommandType.Cancel: sellSideStrategy.OnCancelCommand(command); return; case ExecutionCommandType.Replace: sellSideStrategy.OnReplaceCommand(command); return; default: return; } }
public override void Write(BinaryWriter writer, object obj) { byte value = 0; writer.Write(value); ExecutionCommand executionCommand = obj as ExecutionCommand; writer.Write(executionCommand.id); writer.Write(executionCommand.providerId); writer.Write(executionCommand.portfolioId); writer.Write(executionCommand.transactTime.Ticks); writer.Write((byte)executionCommand.Type); writer.Write(executionCommand.instrumentId); writer.Write((int)executionCommand.Side); writer.Write((int)executionCommand.orderType); writer.Write((int)executionCommand.timeInForce); writer.Write(executionCommand.Price); writer.Write(executionCommand.StopPx); writer.Write(executionCommand.Qty); writer.Write(executionCommand.OCA); writer.Write(executionCommand.Text); }
public void Cancel(Order order) { ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Cancel, order); executionCommand.dateTime = this.framework.Clock.DateTime; executionCommand.providerId = order.providerId; executionCommand.portfolioId = order.portfolioId; executionCommand.transactTime = order.transactTime; executionCommand.instrument = order.instrument; executionCommand.provider = order.provider; executionCommand.portfolio = order.portfolio; executionCommand.side = order.side; executionCommand.orderType = order.Type; executionCommand.timeInForce = order.timeInForce; executionCommand.price = order.price; executionCommand.stopPx = order.stopPx; executionCommand.qty = order.qty; executionCommand.oCA = order.oCA; executionCommand.text = order.text; order.OnExecutionCommand(executionCommand); this.framework.eventServer.OnExecutionCommand(executionCommand); order.Provider.Send(executionCommand); }
public override void Send(ExecutionCommand command) { if (base.IsDisconnected) { this.Connect(); } switch (command.Type) { case ExecutionCommandType.Send: this.Send(command.Order); return; case ExecutionCommandType.Cancel: this.Cancel(command.Order); return; case ExecutionCommandType.Replace: this.Replace(command); return; default: return; } }
public void OnExecutionCommand(ExecutionCommand command) { this.commands.Add(command); this.messages.Add(command); }
public override void Send(ExecutionCommand command) { if(command.RouteId == id) return; IExecutionProvider provider; if (command.RouteId != 0) { provider = framework.ProviderManager.GetExecutionProvider(command.RouteId); } else { provider = ExecutionProvider; } provider.Send(command); }
public ExecutionCommand(ExecutionCommand command) { this.id = command.id; this.providerId = command.providerId; this.portfolioId = command.portfolioId; this.transactTime = command.transactTime; this.dateTime = command.dateTime; this.instrument = command.instrument; this.provider = command.provider; this.portfolio = command.portfolio; this.side = command.side; this.orderType = command.OrdType; this.timeInForce = command.timeInForce; this.price = command.price; this.stopPx = command.stopPx; this.qty = command.qty; this.oCA = command.oCA; this.text = command.text; }
public void Send(ExecutionCommand command) { throw new NotImplementedException(); }
public virtual void OnReplaceCommand(ExecutionCommand command) { }
public OnExecutionCommand(ExecutionCommand command) { this.command = command; }
public virtual void Send(ExecutionCommand command) { Console.WriteLine("Provider::Send is not implemented in the base class"); }
public virtual void OnCancelCommand(ExecutionCommand command) { }
public virtual void OnSendCommand(ExecutionCommand command) { }
public override void Send(ExecutionCommand command) { switch (command.Type) { case ExecutionCommandType.Send: this.Send(command.Order); return; case ExecutionCommandType.Cancel: this.Cancel(command.Order); return; case ExecutionCommandType.Replace: this.Replace(command); return; default: return; } }
private void CmdNewOrderList(ExecutionCommand command) { // 先查出所有的单子 List<Order> orders = command.Order.GetSameTimeOrderList(); OrderField[] fields = new OrderField[orders.Count]; for (int i = 0; i < orders.Count; ++i) { string altSymbol; string altExchange; string apiSymbol; string apiExchange; double apiTickSize; GetApi_Symbol_Exchange_TickSize(orders[i].Instrument, out altSymbol, out altExchange, out apiSymbol, out apiExchange, out apiTickSize); ToOrderStruct(ref fields[i], orders[i], apiSymbol, apiExchange); } orderMap.DoOrderSend(ref fields, orders); }
public void Send(Order order) { if (order.id == -1) { this.Register(order); } if (order.IsOCA) { List<Order> list; this.oCAGroups.TryGetValue(order.oCA, out list); if (list == null) { list = new List<Order>(); this.oCAGroups[order.oCA] = list; } list.Add(order); } this.orders.Add(order); order.dateTime = this.framework.Clock.DateTime; ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Send, order); executionCommand.dateTime = order.dateTime; executionCommand.id = order.id; executionCommand.providerId = order.providerId; executionCommand.portfolioId = order.portfolioId; executionCommand.transactTime = order.transactTime; executionCommand.instrument = order.instrument; executionCommand.provider = order.provider; executionCommand.portfolio = order.portfolio; executionCommand.side = order.side; executionCommand.orderType = order.Type; executionCommand.timeInForce = order.timeInForce; executionCommand.price = order.price; executionCommand.stopPx = order.stopPx; executionCommand.qty = order.qty; executionCommand.oCA = order.oCA; executionCommand.text = order.text; order.OnExecutionCommand(executionCommand); this.framework.eventServer.OnExecutionCommand(executionCommand); order.Provider.Send(executionCommand); }
internal void OnExecutionCommand(ExecutionCommand command) { this.OnEvent(command); }
private void CmdNewOrderSingle(ExecutionCommand command) { string altSymbol; string altExchange; string apiSymbol; string apiExchange; double apiTickSize; GetApi_Symbol_Exchange_TickSize(command.Instrument, out altSymbol, out altExchange, out apiSymbol, out apiExchange, out apiTickSize); OrderField[] fields = new OrderField[1]; ToOrderStruct(ref fields[0], command.Order, apiSymbol, apiExchange); double price = fields[0].Price; //市价修正,如果不连接行情,此修正不执行,得策略层处理 MarketDataRecord record; if (marketDataRecords.TryGetValue(command.Instrument.Symbol, out record)) { switch(command.OrdType) { case SQ.OrderType.Market: case SQ.OrderType.MarketOnClose: case SQ.OrderType.Stop: case SQ.OrderType.TrailingStop: { if (command.Side == SQ.OrderSide.Buy) { price = record.DepthMarket.LastPrice + LastPricePlusNTicks * apiTickSize; } else { price = record.DepthMarket.LastPrice - LastPricePlusNTicks * apiTickSize; } // 市价单使用限价单模拟 if(SwitchMakertOrderToLimitOrder) { fields[0].Type = XAPI.OrderType.Limit; } } break; } if (HasPriceLimit) { //price = FixPrice(price, command.Side, apiTickSize, record.DepthMarket.LowerLimitPrice, record.DepthMarket.UpperLimitPrice); price = FixPrice(record,price, command.Side, apiTickSize); } fields[0].Price = price; } orderMap.DoOrderSend(ref fields, command.Order); }
private void Replace(ExecutionCommand command) { Order order = command.order; base.EmitExecutionReport(new ExecutionReport { dateTime = this.framework.Clock.DateTime, order = order, commandID = order.id, instrument = order.instrument, ordQty = order.Qty, execType = ExecType.ExecReplace, ordStatus = OrderStatus.Replaced, currencyId = order.instrument.currencyId, ordType = order.type, side = order.side, cumQty = order.cumQty, lastQty = 0.0, leavesQty = order.leavesQty, lastPx = 0.0, avgPx = 0.0, //ordType = order.type, price = command.price, stopPx = order.stopPx, //ordQty = order.qty, timeInForce = order.timeInForce, text = order.text }); }
private void CmdCancelOrder(ExecutionCommand command) { orderMap.DoOrderCancel(command.Order); }