private QuickFix.FIX42.NewOrderSingle QueryNewOrderSingle42() { QuickFix.Fields.OrdType ordType = null; QuickFix.FIX42.NewOrderSingle newOrderSingle = new QuickFix.FIX42.NewOrderSingle( QueryClOrdID(), new HandlInst('1'), QuerySymbol(), QuerySide(), new TransactTime(DateTime.Now), ordType = QueryOrdType()); newOrderSingle.Set(QueryOrderQty()); newOrderSingle.Set(QueryTimeInForce()); if (ordType.getValue() == OrdType.LIMIT || ordType.getValue() == OrdType.STOP_LIMIT) { newOrderSingle.Set(QueryPrice()); } if (ordType.getValue() == OrdType.STOP || ordType.getValue() == OrdType.STOP_LIMIT) { newOrderSingle.Set(QueryStopPx()); } QueryHeader(newOrderSingle.Header); return(newOrderSingle); }
/// <summary> /// Send a market order to flatten position /// </summary> /// <param name="_account">account number must be read in from MGT.XML file</param> /// <param name="SecEx">Exchange</param> /// <param name="symbol">Exchange symbol for contract</param> /// <param name="secID">unique identifier supplied by the exchnage for this contract /// For eurex this is the ticker and expiration</param> /// <param name="qty">order quantity</param> /// <param name="bs">buy or sell</param> /// <param name="gateway">TT gateway name</param> public void ttNewOrderSingle(string _account, string SecEx, string symbol, string secID, decimal qty, char bs, string gateway) { try { //log.WriteLog(string.Format("{0} {1} {2} {3} {4} {5} {6}", _account, SecEx, symbol, secID, qty, bs, gateway)); QuickFix.FIX42.NewOrderSingle nos = new QuickFix.FIX42.NewOrderSingle(); string id = uniqueID(); nos.Set(new QuickFix.Fields.ClOrdID(id)); inflightOrders.Add(id); nos.Set(new QuickFix.Fields.SecurityExchange(SecEx)); nos.Set(new QuickFix.Fields.Symbol(symbol)); nos.Set(new QuickFix.Fields.SecurityID(secID)); nos.Set(new QuickFix.Fields.OrderQty(qty)); nos.Set(new QuickFix.Fields.Side(bs)); nos.Set(new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.MARKET)); nos.Set(new QuickFix.Fields.Account(_account)); //To add a TT custom tag to a QuickFix Message you must use SetString or similar //the Set method of the QuickFix.FIX42 message only allows setting standard FIX 4.2 fields //SetString(TTAccountType.FIELD, TT.TTAccountType.M1); //TODO is ACCOUNT_IS_HOUSE_TRADER_AND_IS_CROSS_MARGINED = M1?? nos.CustomerOrFirm.setValue(QuickFix.Fields.AccountType.ACCOUNT_IS_HOUSE_TRADER_AND_IS_CROSS_MARGINED); //Alternative code that can only be used if FA is setup to accept tag 47 and 204 instead of custom tag 18205 //nos.Set(new QuickFix.Fields.Rule80A(QuickFix.Fields.Rule80A.AGENCY_SINGLE_ORDER)); //nos.Set(new QuickFix.Fields.CustomerOrFirm(QuickFix.Fields.CustomerOrFirm.CUSTOMER)); //required for environments with multiple gateways with same products nos.ExchangeGateway.setValue(gateway); QuickFix.Session.SendToTarget(nos, orderSessionID); } catch (Exception ex) { log.WriteLog(ex.ToString()); } }
private QuickFix.FIX42.NewOrderSingle QueryNewOrderSingle42() { QuickFix.Fields.OrdType ordType = null; QuickFix.FIX42.NewOrderSingle newOrderSingle = new QuickFix.FIX42.NewOrderSingle( QueryClOrdID(), new HandlInst('1'), QuerySymbol(), QuerySide(), new TransactTime(DateTime.Now), ordType = QueryOrdType()); newOrderSingle.Set(QueryOrderQty()); newOrderSingle.Set(QueryTimeInForce()); if (ordType.getValue() == OrdType.LIMIT || ordType.getValue() == OrdType.STOP_LIMIT) newOrderSingle.Set(QueryPrice()); if (ordType.getValue() == OrdType.STOP || ordType.getValue() == OrdType.STOP_LIMIT) newOrderSingle.Set(QueryStopPx()); QueryHeader(newOrderSingle.Header); return newOrderSingle; }
/// <summary> /// Creates a FIX4.2 NewOrderSingle message for Redi /// </summary> /// <param name="order"></param> /// <returns></returns> public QuickFix.FIX42.NewOrderSingle NewOrderSingle(Order order) { var newOrderSingle = new QuickFix.FIX42.NewOrderSingle(); var clOrdId = new QuickFix.Fields.ClOrdID(order.OrderID); newOrderSingle.SetField(clOrdId); if (!string.IsNullOrEmpty(_account)) { var account = new QuickFix.Fields.Account(_account); newOrderSingle.SetField(account); } var currency = new QuickFix.Fields.Currency(order.OrderCurrency); newOrderSingle.SetField(currency); var handlInst = new QuickFix.Fields.HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE); newOrderSingle.SetField(handlInst); //only limit and market orders are supported. if (order.GetType() == typeof(LimitOrder)) { var execInst = new QuickFix.Fields.ExecInst("h"); newOrderSingle.SetField(execInst); newOrderSingle.Set(new OrdType(OrdType.LIMIT)); newOrderSingle.Set(new Price(((LimitOrder)order).LimitPrice)); } else if (order.GetType() == typeof(MarketOrder)) { newOrderSingle.Set(new OrdType(OrdType.MARKET)); } var orderQty = new QuickFix.Fields.OrderQty(order.OrderSize); newOrderSingle.SetField(orderQty); var exDestination = new QuickFix.Fields.ExDestination(";"); newOrderSingle.SetField(exDestination); var country = new QuickFix.Fields.DeliverToLocationID("1"); newOrderSingle.SetField(country); var side = new QuickFix.Fields.Side(Convert.ToChar(order.OrderSide)); newOrderSingle.SetField(side); var symbol = new QuickFix.Fields.Symbol(order.Security.Symbol); newOrderSingle.SetField(symbol); var tif = new QuickFix.Fields.TimeInForce(FixCommon.Converter.ConvertTif.GetFixValue(order.OrderTif)); newOrderSingle.SetField(tif); var transactTime = new QuickFix.Fields.TransactTime(order.OrderDateTime); newOrderSingle.SetField(transactTime); return(newOrderSingle); }