コード例 #1
0
        /// <summary>
        /// Create a NewOrderSingle message.
        /// </summary>
        /// <param name="customFields"></param>
        /// <param name="orderType"></param>
        /// <param name="side"></param>
        /// <param name="symbol"></param>
        /// <param name="orderQty"></param>
        /// <param name="tif"></param>
        /// <param name="price">ignored if orderType=Market</param>
        /// <returns></returns>
        static public QuickFix.FIX44.NewOrderSingle NewOrderSingle(
            Dictionary <int, string> customFields,
            OrderType orderType, Side side, string symbol,
            int orderQty, TimeInForce tif, decimal price)
        {
            // hard-coded fields
            QuickFix.Fields.HandlInst fHandlInst = new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE);

            // from params
            QuickFix.Fields.OrdType      fOrdType      = FixEnumTranslator.ToField(orderType);
            QuickFix.Fields.Side         fSide         = FixEnumTranslator.ToField(side);
            QuickFix.Fields.Symbol       fSymbol       = new QuickFix.Fields.Symbol(symbol);
            QuickFix.Fields.TransactTime fTransactTime = new QuickFix.Fields.TransactTime(DateTime.Now);
            QuickFix.Fields.ClOrdID      fClOrdID      = GenerateClOrdID();

            QuickFix.FIX44.NewOrderSingle nos = new QuickFix.FIX44.NewOrderSingle(
                fClOrdID, fSymbol, fSide, fTransactTime, fOrdType);
            nos.OrderQty    = new QuickFix.Fields.OrderQty(orderQty);
            nos.TimeInForce = FixEnumTranslator.ToField(tif);

            if (orderType == OrderType.Limit)
            {
                nos.Price = new QuickFix.Fields.Price(price);
            }

            // add custom fields
            foreach (KeyValuePair <int, string> p in customFields)
            {
                nos.SetField(new QuickFix.Fields.StringField(p.Key, p.Value));
            }

            return(nos);
        }
コード例 #2
0
        public QuickFix.Message CreateNewOrderSingle(string clOrderId, string symbol, Fwk.Main.Common.Enums.Side?side, Fwk.Main.Common.Enums.OrdType?ordType,
                                                     Fwk.Main.Common.Enums.SettlType?settlType, Fwk.Main.Common.Enums.TimeInForce?timeInForce, DateTime?effectiveTime,
                                                     double?ordQty, double?price, double?stopPx, string account, string exchange)
        {
            QuickFix.FIX44.NewOrderSingle nos = new QuickFix.FIX44.NewOrderSingle();


            if (!string.IsNullOrEmpty(account))
            {
                nos.SetField(new Account(account));
            }

            if (!string.IsNullOrEmpty(clOrderId))
            {
                nos.SetField(new ClOrdID(clOrderId));
            }

            if (!string.IsNullOrEmpty(exchange))
            {
                nos.SetField(new SecurityExchange(exchange));
            }

            if (effectiveTime != null)
            {
                nos.SetField(new TransactTime(effectiveTime.Value));
            }

            if (!string.IsNullOrEmpty(symbol))
            {
                nos.SetField(new Symbol(symbol));
            }

            if (ordQty != null)
            {
                nos.SetField(new OrderQty(Convert.ToDecimal(ordQty.Value)));
            }

            if (ordType != null)
            {
                nos.SetField(new QuickFix.Fields.OrdType(Convert.ToChar(ordType.Value)));
            }

            if (price != null)
            {
                nos.SetField(new Price(Convert.ToDecimal(price.Value)));
            }

            if (stopPx != null)
            {
                nos.SetField(new StopPx(Convert.ToDecimal(stopPx.Value)));
            }

            if (side != null)
            {
                nos.SetField(new QuickFix.Fields.Side(Convert.ToChar(side.Value)));
            }

            if (timeInForce.HasValue)
            {
                nos.SetField(new QuickFix.Fields.TimeInForce(Convert.ToChar(timeInForce.Value)));
            }

            return(nos);
        }