/// <summary> /// This function sets up the OrderProfile and submits /// the order using the InstrumentTradeSubscription SendOrder method. /// </summary> /// <param name="buySell">The side of the market to place the order on.</param> private void SendOrder(TTOrder tto, ZOrder o) { ZOrderSide orderSide = o.Side; string qtyStr = o.Qty.ToString(); string priceStr = GetPriceString(o); ZOrderType orderType = o.Type; string stopPriceStr = o.StopPrice.ToString(); // TODO: WE NEED TO DEAL WITH STOP ORDERS!!! TTInstrument ttinstr = _instruments[o.Iid]; cout("TengineTT::SendOrder: {0}", o.ToString()); try { //OrderProfile op = new OrderProfile(ttinstr.DefaultOrderFeed, ttinstr.Instrument, this.DefaultCustomer); OrderProfile op = tto.Profile; op.BuySell = TranslateSide(orderSide); // Set for Buy or Sell. op.QuantityToWork = Quantity.FromString(ttinstr.Instrument, qtyStr); // Set the quantity. if (orderType == ZOrderType.Market) // Market Order { op.OrderType = OrderType.Market; } else if (orderType == ZOrderType.Limit) // Limit Order { // Set the limit order price. op.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr); } else if (orderType == ZOrderType.StopMarket) // Stop Market Order { op.OrderType = OrderType.Market; // Set the order type to "Market" for a market order. op.Modifiers = OrderModifiers.Stop; // Set the order modifiers to "Stop" for a stop order. op.StopPrice = Price.FromString(ttinstr.Instrument, stopPriceStr); // Set the stop price. } else if (orderType == ZOrderType.StopLimit) // Stop Limit Order { op.OrderType = OrderType.Limit; // Set the order type to "Limit" for a limit order. op.Modifiers = OrderModifiers.Stop; // Set the order modifiers to "Stop" for a stop order. op.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr); // Set the limit order price. op.StopPrice = Price.FromString(ttinstr.Instrument, stopPriceStr); // Set the stop price. } //_orders[op.SiteOrderKey] m_dtrd[ttinstr.InstrumentKey].SendOrder(op); // Send the order. cout("TengineTT::SendOrder: TT Order Send {0} {1}|{2}@{3}", op.SiteOrderKey, op.BuySell.ToString(), op.QuantityToWork.ToString(), LimitOrMarketPrice(op)); /*// Update the GUI. * txtOrderBook.Text += String.Format("Send {0} {1}|{2}@{3}{4}", * orderProfile.SiteOrderKey, * orderProfile.BuySell.ToString(), * orderProfile.QuantityToWork.ToString(), * orderProfile.OrderType == OrderType.Limit ? orderProfile.LimitPrice.ToString() : "Market Price", * System.Environment.NewLine);*/ } catch (Exception err) { ErrorMessage(err.Message); } }
public override void DeleteOrder(uint oid) { ZOrder o = orders[oid]; TTOrder tto = _orders[oid]; tto.Order.Delete(); o.SetState(ZOrderState.Cancelled); // TODO: set the state when we receive "order deleted" callback }
public override void SubmitOrder(uint oid) { ZOrder o = orders[oid]; var order = _orders[oid]; GetBook(o).Insert(order); o.SetState(ZOrderState.Working); }
public override void DeleteOrder(uint oid) { ZOrder o = orders[oid]; //var order = _orders[oid]; //GetBook(o).Remove(order); o.SetState(ZOrderState.Cancelled); }
/// <summary> /// This function sets up the OrderProfile and submits /// the order using the InstrumentTradeSubscription SendOrder method. /// </summary> /// <param name="buySell">The side of the market to place the order on.</param> private void SendOrder(TTInstrument ttinstr, ZOrder o) { var orderSide = o.Side; var qtyStr = o.Qty.ToString(); var priceStr = o.Price.ToString(); var orderType = o.Type; var stopPriceStr = o.StopPrice.ToString(); // TODO: WE NEED TO DEAL WITH STOP ORDERS!!! cout("TeTTApi::SendOrder: {0}", o.ToString()); try { CustomerDefaultEntry m_defaultCustomer = null; OrderProfile orderProfile = new OrderProfile(ttinstr.DefaultOrderFeed, ttinstr.Instrument, m_defaultCustomer.Customer); orderProfile.BuySell = TranslateSide(orderSide); // Set for Buy or Sell. orderProfile.QuantityToWork = Quantity.FromString(ttinstr.Instrument, qtyStr); // Set the quantity. if (orderType == ZOrderType.Market) // Market Order { orderProfile.OrderType = OrderType.Market; } else if (orderType == ZOrderType.Limit) // Limit Order { // Set the limit order price. orderProfile.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr); } else if (orderType == ZOrderType.StopMarket) // Stop Market Order { orderProfile.OrderType = OrderType.Market; // Set the order type to "Market" for a market order. orderProfile.Modifiers = OrderModifiers.Stop; // Set the order modifiers to "Stop" for a stop order. orderProfile.StopPrice = Price.FromString(ttinstr.Instrument, stopPriceStr); // Set the stop price. } else if (orderType == ZOrderType.StopLimit) // Stop Limit Order { orderProfile.OrderType = OrderType.Limit; // Set the order type to "Limit" for a limit order. orderProfile.Modifiers = OrderModifiers.Stop; // Set the order modifiers to "Stop" for a stop order. orderProfile.LimitPrice = Price.FromString(ttinstr.Instrument, priceStr); // Set the limit order price. orderProfile.StopPrice = Price.FromString(ttinstr.Instrument, stopPriceStr); // Set the stop price. } //m_instrumentTradeSubscription.SendOrder(orderProfile); // Send the order. cout("TT Order Send {0} {1}|{2}@{3}", orderProfile.SiteOrderKey, orderProfile.BuySell.ToString(), orderProfile.QuantityToWork.ToString(), LimitOrMarketPrice(orderProfile)); /*// Update the GUI. * txtOrderBook.Text += String.Format("Send {0} {1}|{2}@{3}{4}", * orderProfile.SiteOrderKey, * orderProfile.BuySell.ToString(), * orderProfile.QuantityToWork.ToString(), * orderProfile.OrderType == OrderType.Limit ? orderProfile.LimitPrice.ToString() : "Market Price", * System.Environment.NewLine);*/ } catch (Exception err) { ErrorMessage(err.Message); } }
public override void SubmitOrder(uint oid) { ZOrder o = orders[oid]; //var order = _orders[oid]; //GetBook(o).Insert(order); var ttinstr = _instruments[o.Iid]; SendOrder(ttinstr, o); o.SetState(ZOrderState.Working); }
public override uint CreateOrder(uint iid, ZOrderSide side, int price, uint qty, ZOrderType type, ZOrderTimeInForce tif) { uint oid = GenerateOrderId(); var o = new ZOrder(oid, iid, side, price, qty, type, tif); orders[oid] = o; //_orders[o.Oid] = new OME.EquityOrder(_instruments[o.Iid], OME.Order.OrderTypes.GoodUntilCancelled, GetSide(o), o.Price, o.Qty); return(oid); }
private OME.Orders GetBook(ZOrder o) { if (o.IsBuy) { return(_buyOrderBook[o.Iid]); } else { return(_sellOrderBook[o.Iid]); } }
public override void SubmitOrder(uint oid) { ZOrder o = orders[oid]; TTOrder tto = _orders[oid]; //var order = _orders[oid]; //GetBook(o).Insert(order); /*var ttinstr = _instruments[o.Iid]; * SendOrder(ttinstr, o);*/ SendOrder(tto, o); o.SetState(ZOrderState.Working); // TODO: set the state when we receive "order added" callback }
public override uint CreateOrder(uint iid, ZOrderSide side, int price, uint qty, ZOrderType type, ZOrderTimeInForce tif) { uint oid = GenerateOrderId(); var o = new ZOrder(oid, iid, side, price, qty, type, tif); orders[oid] = o; // Add this to the OrderMap which will allow us to convert to/from TTAPI orders var ttinstr = _instruments[iid]; OrderProfile op = new OrderProfile(ttinstr.DefaultOrderFeed, ttinstr.Instrument, this.DefaultCustomer); var tto = new TTOrder(op); _orders.Add(tto.Key, tto, oid); return(oid); }
// Get the integer price from a ZOrder object and divide it by the proper power of 10 to get the converted decimal price (as a string) private string GetPriceString(ZOrder o) { return(_instruments[o.Iid].ConvertPrice(o.Price).ToString()); }
private OME.Order.BuyOrSell GetSide(ZOrder o) { return((o.Side == ZOrderSide.Buy) ? OME.Order.BuyOrSell.Buy : OME.Order.BuyOrSell.Sell); }