Esempio n. 1
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;
        }
Esempio n. 2
0
        public Order(MDEntryGroup entryGroup, double quantity)
        {
            int propIndex = -1;
            SecurityEntry ownerEntry = entryGroup.OwnerEntry;
            propIndex = ownerEntry.GetGroupIndex(entryGroup);

            weakCopy = entryGroup.OwnerEntry.WeakClone();
            currentMDGroup = weakCopy.GetGroup((uint)propIndex);

            OrderMessage = FixApplication.Current.NewOrder(entryGroup, quantity);
        }
Esempio n. 3
0
        public Order(IProposal proposal, double quantity)
        {
            int propIndex = -1;
            SecurityEntry ownerEntry = ((MDEntryGroup) proposal).OwnerEntry;
            propIndex = ownerEntry.GetGroupIndex((MDEntryGroup)proposal);

            weakCopy = ((Proposal) proposal).OwnerEntry.WeakClone();
            currentMDGroup = weakCopy.GetGroup((uint) propIndex);

            OrderMessage = FixApplication.Current.NewOrder(proposal, quantity);
        }
Esempio n. 4
0
 public int GetGroupIndex(MDEntryGroup entryGroup)
 {
     for (int i = 0; i < MDGroupCount; i++)
     {
         if (MDEntryGroups[i] == entryGroup)
             return i;
     }
     return -1;
 }
Esempio n. 5
0
        internal MDEntryGroup Clone(SecurityEntry newOwner)
        {
            MDEntryGroup newGroup = new MDEntryGroup(newOwner);

            Utils.CopyPropertiesAndFields(this, newGroup);

            return newGroup;
        }
Esempio n. 6
0
        private static void FillData(MDEntryGroup entryGroup, ref Dictionary<string, string> dict)
        {
            if (entryGroup == null)
                return;

            string px = entryGroup.MDEntryPx.ToString(Constants.FloatingPointFormat);
            string size = entryGroup.MDEntrySize.ToString("F0");

            switch (entryGroup.MDEntryType)
            {
                case QuickFix.MDEntryType.BID:
                    dict["bPx"] = px;
                    dict["bCount"] = size;
                    break;

                case QuickFix.MDEntryType.OFFER:
                    dict["aPx"] = px;
                    dict["aCount"] = size;
                    break;

                default:
                    throw new Exception("Undefined entry type.");
            }
        }