Ejemplo n.º 1
0
        public void NewOrder(string clrID, char handinst, char sideID, char orderType, string symbolID, string exchange, float?price, long Quantity)
        {
            ClOrdID      clOrdID = new ClOrdID(clrID);
            HandlInst    inst    = new HandlInst('1');//似乎国信只支持直通私有
            Side         side    = new Side(sideID);
            OrdType      ordType = new OrdType(orderType);
            Symbol       symbol  = new Symbol(symbolID);
            TransactTime time    = new TransactTime();

            QuickFix42.NewOrderSingle message = new QuickFix42.NewOrderSingle(clOrdID, inst, symbol, side, time, ordType);
            message.setString(38, Quantity.ToString());
            if (ordType.getValue() == OrdType.LIMIT)
            {
                message.setString(44, price.Value.ToString());
            }
            message.setString(15, "CNY");
            if (exchange == "SH")
            {
                message.setString(207, "XSHG");
            }
            else if (exchange == "SZ")
            {
                message.setString(207, "XSHE");
            }
            SendToServer(message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// send a new order
        /// </summary>
        /// <param name="instrument">string array containing either
        /// {SecurityExchange, Symbol,SecurityType,MaturityMonthYear} or
        /// {SecurityExchange, Symbol,SecurityID}</param>
        /// <param name="gateway"></param>
        /// <param name="account"></param>
        /// <param name="orderType"></param>
        /// <param name="tradePrice"></param>
        /// <param name="qty"></param>
        /// <param name="bs"></param>
        public void ttNewOrderSingle(string[] instrument, string gateway,
                                     string account, char orderType, double tradePrice, double qty, char bs)
        {
            //string[] instrument must contain:
            //{SecurityExchange, Symbol,SecurityType,MaturityMonthYear} or
            //{SecurityExchange, Symbol,SecurityID}

            try
            {
                QuickFix42.NewOrderSingle nos = new QuickFix42.NewOrderSingle();

                nos.set(new QuickFix.ClOrdID(uniqueID()));

                #region DefineInstrument
                nos.set(new QuickFix.SecurityExchange(instrument[0]));
                nos.set(new QuickFix.Symbol(instrument[1]));

                if (instrument.GetLength(0) == 4)
                {
                    nos.set(new QuickFix.SecurityType(instrument[2]));
                    nos.set(new QuickFix.MaturityMonthYear(instrument[3]));
                }
                else if (instrument.GetLength(0) == 3)
                {
                    nos.set(new QuickFix.SecurityID(instrument[2]));
                }
                else
                {
                    throw new System.Exception("Incorrect parameters for insturment definition");
                }
                #endregion

                nos.set(new QuickFix.OrderQty(qty));
                nos.set(new QuickFix.Side(bs));
                nos.set(new QuickFix.Account(account));

                nos.set(new QuickFix.OrdType(orderType));
                if (orderType == QuickFix.OrdType.LIMIT)
                {
                    nos.set(new QuickFix.Price(tradePrice));
                }

                //Use this code if FA is setup to accept tag 47 and 204 instead of custom tag 18205
                //nos.set(new QuickFix.Rule80A(QuickFix.Rule80A.AGENCY_SINGLE_ORDER));
                //nos.set(new QuickFix.CustomerOrFirm(QuickFix.CustomerOrFirm.CUSTOMER));
                nos.setString(TT.TTAccountType.FIELD, TT.TTAccountType.A1);

                //To add a TT custom tag to a QuickFix Message you must use setField or similar
                //the set method of the QuickFix42 message only allows setting standard FIX 4.2 fields
                //required for environments with multiple gateways with same products
                if (gateway != null)
                {
                    nos.setString(TT.ExchangeGateway.FIELD, gateway);
                }

                nos.setString(TT.FFT2.FIELD, "FFT2");
                nos.setString(TT.FFT3.FIELD, "FFT3");

                QuickFix.Session.sendToTarget(nos, orderSessionID);
            }
            catch (Exception ex)
            { Console.WriteLine(ex.ToString()); }
        }