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);
        }
Exemple #2
0
        //35 = D
        public override void onMessage(QuickFix42.NewOrderSingle message, SessionID sessionID)
        {
            Console.WriteLine("Receive message " + message.getHeader().getField(35) + ", session: " + sessionID.toString());
            try
            {
                ClOrdID      clordid = message.getClOrdID();
                string       clord   = clordid.getValue();
                Side         side    = message.getSide();
                char         s       = side.getValue();
                OrdType      ordtype = message.getOrdType();
                char         ord     = ordtype.getValue();
                TransactTime time    = message.getTransactTime();
                DateTime     dt      = time.getValue();

                QuickFix42.ExecutionReport executionReport = new QuickFix42.ExecutionReport(new OrderID("neworderid"), new ExecID("Hehe")
                                                                                            , new ExecTransType(ExecTransType.CORRECT), new ExecType(ExecType.NEW), new OrdStatus(OrdStatus.DONE_FOR_DAY),
                                                                                            new Symbol("VND"), new Side(Side.BUY), new LeavesQty(1), new CumQty(2), new AvgPx(100));

                bool x = Session.sendToTarget(executionReport, sessionID);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemple #3
0
        static void Main()
        {
            try
            {
                ClientInitiator      app            = new ClientInitiator();
                SessionSettings      settings       = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\initiator.cfg");
                QuickFix.Application application    = new ClientInitiator();
                FileStoreFactory     storeFactory   = new FileStoreFactory(settings);
                ScreenLogFactory     logFactory     = new ScreenLogFactory(settings);
                MessageFactory       messageFactory = new DefaultMessageFactory();

                SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);
                initiator.start();
                Thread.Sleep(3000);
                System.Collections.ArrayList list = initiator.getSessions();
                SessionID sessionID = (SessionID)list[0];
                Console.WriteLine("Press any key: ");
                string x = Console.ReadLine();
                QuickFix42.NewOrderSingle order = new QuickFix42.NewOrderSingle(new ClOrdID("Hello"), new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE), new Symbol("ABC"), new Side(Side.SELL), new TransactTime(DateTime.Now), new OrdType(OrdType.MARKET));
                bool sent = Session.sendToTarget(order, sessionID);
                Console.ReadLine();
                initiator.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
        }
Exemple #4
0
        public QuickFix42.NewOrderSingle sendKnightMarketOrder(string OrderID, string route, string symbol)
        {
            //int id = rand.Next(100000000, 200000000);
            //limitID = "t" + id.ToString();


            QuickFix42.NewOrderSingle msg2 = new QuickFix42.NewOrderSingle(new ClOrdID(OrderID), new HandlInst('1'), new Symbol(symbol), new Side(Side.BUY), new TransactTime(DateTime.UtcNow), new OrdType(OrdType.MARKET));
            //Additional required Fields
            msg2.set(new OrderQty(100));
            msg2.set(new Account("1234"));
            msg2.set(new TimeInForce(TimeInForce.DAY));

            //RMG Routing

            msg2.setField(57, route);

            if (route.Contains("ALGO"))
            {
                msg2.setField(9102, "T");
            }
            else
            {
                msg2.setField(9102, "X");
            }
            //msg2.setField(6210, "0");

            //Session.sendToTarget(msg2, oKnightSessionID);

            return(msg2);
        }
        public override void Send(FIXNewOrderSingle Order)
        {
            QuickFix42.NewOrderSingle order = new QuickFix42.NewOrderSingle(
                new QuickFix.ClOrdID(Order.ClOrdID),
                //new QuickFix.HandlInst(Order.HandlInst),
                new QuickFix.HandlInst(HandlInst.AUTOEXECPRIV), // GS FIX
                new QuickFix.Symbol(Order.Symbol.Substring(0, 6)),
                new QuickFix.Side(Order.Side),
                new QuickFix.TransactTime(Order.TransactTime),
                new QuickFix.OrdType(Order.OrdType));

            if ((Order.OrdType == FIXOrdType.Limit || Order.OrdType == FIXOrdType.StopLimit) && Order.ContainsField(EFIXField.Price))
            {
                order.set(new QuickFix.Price(Order.Price));
            }

            if ((Order.OrdType == FIXOrdType.Stop || Order.OrdType == FIXOrdType.StopLimit) && Order.ContainsField(EFIXField.StopPx))
            {
                order.set(new QuickFix.StopPx(Order.StopPx));
            }

            // 自己计算交易所
            if (Order.Symbol.StartsWith("60") || Order.Symbol.StartsWith("51"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHG"));// 上海
                order.set(new QuickFix.SecurityExchange("SS"));// 上海
            }
            else if (Order.Symbol.StartsWith("00") || Order.Symbol.StartsWith("30") || Order.Symbol.StartsWith("15"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHE"));// 深圳
                order.set(new QuickFix.SecurityExchange("SZ"));// 深圳
            }

            if (Order.Text.StartsWith(OpenPrefix))
            {
                order.setField(new QuickFix.CashMargin(CashMargin.MARGIN_OPEN));
            }
            else if (Order.Text.StartsWith(ClosePrefix))
            {
                order.setField(new QuickFix.CashMargin(CashMargin.MARGIN_CLOSE));
            }

            //order.set(new QuickFix.SecurityType(Order.SecurityType));
            order.set(new QuickFix.OrderQty(Order.OrderQty));
            //order.set(new QuickFix.Account(Order.Account));
            //order.set(new QuickFix.Rule80A(Order.Rule80A));
            //order.set(new QuickFix.CustomerOrFirm(Order.CustomerOrFirm));

            //if (Order.ContainsField(EFIXField.ClearingAccount))
            //    order.set(new QuickFix.ClearingAccount(Order.ClearingAccount));

            order.set(new QuickFix.Currency("CNY")); // GS FIX

            Session.sendToTarget(order, orderSessionID);
        }
        public QuickFix42.NewOrderSingle SendKnightMarketOrder(string orderId, string route, string symbol)
        {
            QuickFix42.NewOrderSingle msg2 = new QuickFix42.NewOrderSingle(new ClOrdID(orderId), new HandlInst('1'), new Symbol(symbol), new Side(Side.BUY), new TransactTime(DateTime.UtcNow), new OrdType(OrdType.MARKET));
            //Additional required Fields
            msg2.set(new OrderQty(100));
            msg2.set(new Account("1234"));
            msg2.set(new TimeInForce(TimeInForce.DAY));

            msg2.setField(57, route);
            msg2.setField(9102, route.Contains("ALGO") ? "T" : "X");

            return(msg2);
        }
Exemple #7
0
        public override void onMessage(QuickFix42.NewOrderSingle order, SessionID sessionID)
        {
            Symbol   symbol   = new Symbol();
            Side     side     = new Side();
            OrdType  ordType  = new OrdType();
            OrderQty orderQty = new OrderQty();
            Price    price    = new Price();
            ClOrdID  clOrdID  = new ClOrdID();

            order.get(ordType);

            if (ordType.getValue() != OrdType.LIMIT)
            {
                throw new IncorrectTagValue(ordType.getField());
            }

            order.get(symbol);
            order.get(side);
            order.get(orderQty);
            order.get(price);
            order.get(clOrdID);

            QuickFix42.ExecutionReport executionReport = new QuickFix42.ExecutionReport
                                                             (genOrderID(),
                                                             genExecID(),
                                                             new ExecTransType(ExecTransType.NEW),
                                                             new ExecType(ExecType.FILL),
                                                             new OrdStatus(OrdStatus.FILLED),
                                                             symbol,
                                                             side,
                                                             new LeavesQty(0),
                                                             new CumQty(orderQty.getValue()),
                                                             new AvgPx(price.getValue()));

            executionReport.set(clOrdID);
            executionReport.set(orderQty);
            executionReport.set(new LastShares(orderQty.getValue()));
            executionReport.set(new LastPx(price.getValue()));

            if (order.isSetAccount())
            {
                executionReport.set(order.getAccount());
            }

            try
            {
                Session.sendToTarget(executionReport, sessionID);
            }
            catch (SessionNotFound) {}
        }
        public QuickFix42.NewOrderSingle SendKnightMarketOrder(string orderId)
        {
            QuickFix42.NewOrderSingle msg2 = new QuickFix42.NewOrderSingle(new ClOrdID(orderId), new HandlInst('1'), new Symbol("BAC"), new Side(Side.BUY), new TransactTime(DateTime.UtcNow), new OrdType(OrdType.MARKET));
            //Additional required Fields
            msg2.set(new OrderQty(100));
            msg2.set(new Account("1234"));
            msg2.set(new TimeInForce(TimeInForce.DAY));

            //RMG Routing
            msg2.setField(57, "ALGO1");
            msg2.setField(9102, "T");

            Handler.Add(msg2);
            return(msg2);
        }
        public QuickFix42.NewOrderSingle SendMarketOrder(string clOrdId, string symbol, int qty, string side, string route, string clientid, string channel = "X")
        {
            Side       sd           = new Side(Side.BUY);
            LocateReqd lReqd        = new LocateReqd(true);
            bool       isLocateReqd = false;

            if (side.Equals("B") || side.Equals("b") || side.Equals("buy") || side.Equals("BUY"))
            {
                sd = new Side(Side.BUY);
            }
            else if (side.Equals("S") || side.Equals("s") || side.Equals("sell") || side.Equals("SELL"))
            {
                sd = new Side(Side.SELL);
            }
            else if (side.Equals("SS") || side.Equals("ss") || side.Equals("ssell") || side.Equals("SSELL") || side.Equals("SHORT") || side.Equals("short"))
            {
                sd           = new Side(Side.SELL_SHORT);
                isLocateReqd = true;
            }

            QuickFix42.NewOrderSingle msg = new QuickFix42.NewOrderSingle(new ClOrdID(clOrdId), new HandlInst('1'), new Symbol(symbol), sd, new TransactTime(DateTime.UtcNow), new OrdType(OrdType.MARKET));

            if (isLocateReqd)
            {
                msg.set(lReqd);
            }

            msg.set(new OrderQty(qty));
            msg.set(new Account("54321"));
            msg.set(new TimeInForce(TimeInForce.DAY));

            msg.setField(57, route);
            // msg.setField(50, route);
            msg.setField(9102, channel);

            if (route.Equals("JPMVWAP") || route.Equals("RAVAT") || route.Equals("TWAPJP") || route.Equals("MISMTW") || route.Equals("SGMISMTW"))
            {
                msg.setField(6203, DateTime.UtcNow.ToString());
                msg.setField(6205, DateTime.UtcNow.Add(new TimeSpan(0, 5, 0)).ToString());
            }

            Handler.Add(msg);
            return(msg);
        }
        public QuickFix42.NewOrderSingle SendKnightLimitOrder(string orderId, ref string limitId, double price)
        {
            limitId = orderId;

            QuickFix42.NewOrderSingle msg2 = new QuickFix42.NewOrderSingle(new ClOrdID(orderId), new HandlInst('1'), new Symbol("BAC"), new Side(Side.BUY), new TransactTime(DateTime.UtcNow), new OrdType(OrdType.LIMIT));
            //additional required fields
            msg2.set(new OrderQty(100));
            msg2.set(new Account("1234"));
            msg2.set(new TimeInForce(TimeInForce.DAY));
            Price p = new Price(price);

            msg2.set(p);

            //For RMG Routing
            msg2.setField(57, "ALGO1");
            msg2.setField(9102, "T");

            //Session.sendToTarget(msg2, oKnightSessionID);

            return(msg2);
        }
        public QuickFix42.NewOrderSingle SendLimitOrder(string clOrdId, string symbol, int qty, string side, double price, string route = "NEFAN", string channel = "X")
        {
            Side       sd           = new Side(Side.BUY);
            LocateReqd lReqd        = new LocateReqd(true);
            bool       isLocateReqd = false;

            if (side.Equals("B") || side.Equals("b") || side.Equals("buy") || side.Equals("BUY"))
            {
                sd = new Side(Side.BUY);
            }
            else if (side.Equals("S") || side.Equals("s") || side.Equals("sell") || side.Equals("SELL"))
            {
                sd = new Side(Side.SELL);
            }
            else if (side.Equals("SS") || side.Equals("ss") || side.Equals("ssell") || side.Equals("SSELL") || side.Equals("SHORT") || side.Equals("short"))
            {
                sd           = new Side(Side.SELL_SHORT);
                isLocateReqd = true;
            }

            QuickFix42.NewOrderSingle msg2 = new QuickFix42.NewOrderSingle(new ClOrdID(clOrdId), new HandlInst('1'), new Symbol(symbol), sd, new TransactTime(DateTime.UtcNow), new OrdType(OrdType.LIMIT));
            //additional required fields
            if (isLocateReqd)
            {
                msg2.set(lReqd);
            }

            msg2.set(new OrderQty(qty));
            msg2.set(new Account("12345"));
            msg2.set(new TimeInForce(TimeInForce.DAY));

            msg2.set(new Price(price));

            //For RMG Routing
            msg2.setField(57, route);
            msg2.setField(9102, channel);

            Handler.Add(msg2);
            return(msg2);
        }
Exemple #12
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()); }
        }
Exemple #13
0
        public Message NewOrder(MDEntryGroup entryGroup, double quantity)
        {
            bool isInvertedSecurity = entryGroup.OwnerEntry.IsInverted;
            Message message = null;
            Account account = new Account(GetOrderSession().getSenderCompID().ToLower());

            ClOrdID clOrdId = new ClOrdID("ClOrd_" + Guid.NewGuid());
            HandlInst handlInst = new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION);
            OrdType ordType = new OrdType(OrdType.LIMIT);
            TimeInForce timeInForce = new TimeInForce(TimeInForce.FILL_OR_KILL);
            TransactTime transactTime = new TransactTime();

            Price price = new Price(entryGroup.MDEntryPx);
            SecurityExchange securityExchange = new SecurityExchange(entryGroup.OwnerEntry.SecurityExchange);
            SecurityType securityType = new SecurityType(entryGroup.OwnerEntry.SecurityType);
            Symbol symbol = new Symbol(entryGroup.OwnerEntry.Symbol);
            SecurityID securityId = new SecurityID(entryGroup.OwnerEntry.SecurityID);
            OrderQty orderQty = new OrderQty(quantity);

            Side side = null;
            switch (entryGroup.MDEntryType)
            {
                case MDEntryType.BID:
                    side = new Side(Side.SELL);
                    break;
                case MDEntryType.OFFER:
                    side = new Side(Side.BUY);
                    break;
                default:
                    throw new Exception("Undefined entry type.");
            }

            //if (isInvertedSecurity && side.getValue() == Side.BUY)
            //    price = new Price(-price.getValue());

            message = new QuickFix42.NewOrderSingle();

            ((QuickFix42.NewOrderSingle) message).set(account);

            ((QuickFix42.NewOrderSingle) message).set(clOrdId);
            ((QuickFix42.NewOrderSingle) message).set(side);
            ((QuickFix42.NewOrderSingle) message).set(transactTime);
            ((QuickFix42.NewOrderSingle) message).set(ordType);

            ((QuickFix42.NewOrderSingle) message).set(price);
            ((QuickFix42.NewOrderSingle) message).set(orderQty);
            ((QuickFix42.NewOrderSingle) message).set(securityId);
            ((QuickFix42.NewOrderSingle) message).set(securityExchange);
            ((QuickFix42.NewOrderSingle) message).set(timeInForce);

            ((QuickFix42.NewOrderSingle) message).set(securityType);

            return message;
        }
Exemple #14
0
		public virtual void Send(FIXNewOrderSingle Order)
		{
			QuickFix.FIX42.NewOrderSingle newOrderSingle = new QuickFix42.NewOrderSingle(new ClOrdID(Order.ClOrdID), new HandlInst(Order.HandlInst), new Symbol(Order.Symbol), new QuickFix.Side(Order.Side), new TransactTime(Order.TransactTime), new QuickFix.OrdType(Order.OrdType));
			if (Order.ContainsField(1))
				newOrderSingle.set(new Account(Order.Account));
			if (Order.ContainsField(18))
				newOrderSingle.set(new ExecInst(Order.ExecInst));
			if (Order.ContainsField(110))
				newOrderSingle.set(new MinQty(Order.MinQty));
			if (Order.ContainsField(111))
				newOrderSingle.set(new MaxFloor(Order.MaxFloor));
			if (Order.ContainsField(100))
				newOrderSingle.set(new ExDestination(Order.ExDestination));
			if (Order.ContainsField(81))
				newOrderSingle.set(new ProcessCode(Order.ProcessCode));
			if (Order.ContainsField(65))
				newOrderSingle.set(new SymbolSfx(Order.SymbolSfx));
			if (Order.ContainsField(48))
				newOrderSingle.set(new SecurityID(Order.SecurityID));
			if (Order.ContainsField(22))
				newOrderSingle.set(new IDSource(Order.SecurityIDSource));
			if (Order.ContainsField(167))
				newOrderSingle.set(new QuickFix.SecurityType(Order.SecurityType));
			if (Order.ContainsField(200))
				newOrderSingle.set(new MaturityMonthYear(Order.MaturityMonthYear));
			if (Order.ContainsField(202))
				newOrderSingle.set(new StrikePrice(Order.StrikePrice));
			if (Order.ContainsField(206))
				newOrderSingle.set(new OptAttribute(Order.OptAttribute));
			if (Order.ContainsField(231))
				newOrderSingle.set(new ContractMultiplier(Order.ContractMultiplier));
			if (Order.ContainsField(223))
				newOrderSingle.set(new CouponRate(Order.CouponRate));
			if (Order.ContainsField(207))
				newOrderSingle.set(new SecurityExchange(Order.SecurityExchange));
			if (Order.ContainsField(106))
				newOrderSingle.set(new Issuer(Order.Issuer));
			if (Order.ContainsField(348))
				newOrderSingle.set(new EncodedIssuerLen(Order.EncodedIssuerLen));
			if (Order.ContainsField(349))
				newOrderSingle.set(new EncodedIssuer(Order.EncodedIssuer));
			if (Order.ContainsField(107))
				newOrderSingle.set(new SecurityDesc(Order.SecurityDesc));
			if (Order.ContainsField(350))
				newOrderSingle.set(new EncodedSecurityDescLen(Order.EncodedSecurityDescLen));
			if (Order.ContainsField(351))
				newOrderSingle.set(new EncodedSecurityDesc(Order.EncodedSecurityDesc));
			if (Order.ContainsField(140))
				newOrderSingle.set(new PrevClosePx(Order.PrevClosePx));
			if (Order.ContainsField(38))
				newOrderSingle.set(new OrderQty(Order.OrderQty));
			if (Order.ContainsField(152))
				newOrderSingle.set(new CashOrderQty(Order.CashOrderQty));
			if (Order.ContainsField(44))
				newOrderSingle.set(new Price(Order.Price));
			if (Order.ContainsField(99))
				newOrderSingle.set(new StopPx(Order.StopPx));
			if (Order.ContainsField(15))
				newOrderSingle.set(new QuickFix.Currency(Order.Currency));
			if (Order.ContainsField(376))
				newOrderSingle.set(new ComplianceID(Order.ComplianceID));
			if (Order.ContainsField(117))
				newOrderSingle.set(new QuoteID(Order.QuoteID));
			if (Order.ContainsField(59))
				newOrderSingle.set(new QuickFix.TimeInForce(Order.TimeInForce));
			if (Order.ContainsField(168))
				newOrderSingle.set(new EffectiveTime(Order.EffectiveTime));
			if (Order.ContainsField(126))
				newOrderSingle.set(new ExpireTime(Order.ExpireTime));
			if (Order.ContainsField(427))
				newOrderSingle.set(new GTBookingInst(Order.GTBookingInst));
			if (Order.ContainsField(12))
				newOrderSingle.set(new Commission(Order.Commission));
			if (Order.ContainsField(13))
				newOrderSingle.set(new QuickFix.CommType(Order.CommType));
			if (Order.ContainsField(120))
				newOrderSingle.set(new SettlCurrency(Order.SettlCurrency));
			if (Order.ContainsField(58))
				newOrderSingle.set(new Text(Order.Text));
			if (Order.ContainsField(354))
				newOrderSingle.set(new EncodedTextLen(Order.EncodedTextLen));
			if (Order.ContainsField(355))
				newOrderSingle.set(new EncodedText(Order.EncodedText));
			if (Order.ContainsField(192))
				newOrderSingle.set(new OrderQty2(Order.OrderQty2));
			if (Order.ContainsField(203))
				newOrderSingle.set(new CoveredOrUncovered(Order.CoveredOrUncovered));
			if (Order.ContainsField(210))
				newOrderSingle.set(new MaxShow(Order.MaxShow));
			if (Order.ContainsField(388))
				newOrderSingle.set(new DiscretionInst(Order.DiscretionInst));
			try
			{
				Session.sendToTarget((QuickFix.Message)newOrderSingle, this.fSessionID);
			}
			catch (Exception ex)
			{
				Console.WriteLine(BeAEwTZGlZaeOmY5cm.J00weU3cM6(1252) + ex.Message);
			}
		}
        public override void Send(FIXNewOrderSingle Order)
        {
            QuickFix42.NewOrderSingle order = new QuickFix42.NewOrderSingle(
                new QuickFix.ClOrdID(Order.ClOrdID),
                //new QuickFix.HandlInst(Order.HandlInst),
                new QuickFix.HandlInst(HandlInst.AUTOEXECPRIV), // GS FIX
                new QuickFix.Symbol(Order.Symbol.Substring(0,6)),
                new QuickFix.Side(Order.Side),
                new QuickFix.TransactTime(Order.TransactTime),
                new QuickFix.OrdType(Order.OrdType));

            if ((Order.OrdType == FIXOrdType.Limit || Order.OrdType == FIXOrdType.StopLimit) && Order.ContainsField(EFIXField.Price))
                order.set(new QuickFix.Price(Order.Price));

            if ((Order.OrdType == FIXOrdType.Stop || Order.OrdType == FIXOrdType.StopLimit) && Order.ContainsField(EFIXField.StopPx))
                order.set(new QuickFix.StopPx(Order.StopPx));

            // 自己计算交易所
            if (Order.Symbol.StartsWith("60") || Order.Symbol.StartsWith("51"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHG"));// 上海
                order.set(new QuickFix.SecurityExchange("SS"));// 上海
            }
            else if (Order.Symbol.StartsWith("00") || Order.Symbol.StartsWith("30") || Order.Symbol.StartsWith("15"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHE"));// 深圳
                order.set(new QuickFix.SecurityExchange("SZ"));// 深圳
            }

            if (Order.Text.StartsWith(OpenPrefix))
            {
                order.setField(new QuickFix.CashMargin(CashMargin.MARGIN_OPEN));
            }
            else if (Order.Text.StartsWith(ClosePrefix))
            {
                order.setField(new QuickFix.CashMargin(CashMargin.MARGIN_CLOSE));
            }

            //order.set(new QuickFix.SecurityType(Order.SecurityType));
            order.set(new QuickFix.OrderQty(Order.OrderQty));
            //order.set(new QuickFix.Account(Order.Account));
            //order.set(new QuickFix.Rule80A(Order.Rule80A));
            //order.set(new QuickFix.CustomerOrFirm(Order.CustomerOrFirm));

            //if (Order.ContainsField(EFIXField.ClearingAccount))
            //    order.set(new QuickFix.ClearingAccount(Order.ClearingAccount));

            order.set(new QuickFix.Currency("CNY")); // GS FIX

            Session.sendToTarget(order, orderSessionID);
        }
Exemple #16
0
 public sealed override void onMessage(QuickFix42.NewOrderSingle message, SessionID session)
 {
     Fix.Out(new StackTrace(new StackFrame(true)).GetFrame(0).GetMethod().ToString());
 }