private void createDeltaFromMamaMsgWithVectorFields(
            MamdaOrderBook delta,
            MamaMsg[] msgLevels)
        {
            /*
             * Books with vector fields always come in a single MamaMsg.
             */
            delta.clear();

            for (int i = 0; i < msgLevels.Length; i++)
            {
                MamaMsg plMsg = msgLevels[i];
                MamdaOrderBookPriceLevel level = new MamdaOrderBookPriceLevel();

                getLevelInfo(level, plMsg, delta);
                getEntries(level, plMsg);
                delta.addLevel(level);
            }
        }
Esempio n. 2
0
        private void createDeltaFromMamaMsgWithVectorFields(
			MamdaOrderBook delta,
			MamaMsg[] msgLevels)
        {
            /*
             * Books with vector fields always come in a single MamaMsg.
             */
            delta.clear();

            for (int i = 0; i < msgLevels.Length; i++)
            {
                MamaMsg plMsg = msgLevels[i];
                MamdaOrderBookPriceLevel level = new MamdaOrderBookPriceLevel();

                getLevelInfo(level, plMsg, delta);
                getEntries(level, plMsg);
                delta.addLevel(level);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns whether a complete book delta was received.
        /// 
        /// Books without vector fields (i.e. fixed field layout) might
        /// come in multiple MamaMsgs.  The MdMsgNum and MdTotalNum
        /// fields can be used to determine which message is which.
        /// 
        /// When a single price level is present, it may or may not be
        /// encapsulated in a nested message field.  Similarly, with single
        /// entries in a price level.
        /// </summary>
        /// <param name="delta"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool createDeltaFromMamaMsgWithoutVectorFields(
			MamdaOrderBook delta,
			MamaMsg msg)
        {
            int msgNum   = 1;
            int msgTotal = 1;

            if (msg.tryI32(MamaReservedFields.MsgNum, ref mMsgNum))
            {
                msgNum = mMsgNum.Value;
            }
            if (msg.tryI32(MamaReservedFields.MsgTotal, ref mMsgTotal))
            {
                msgTotal = mMsgTotal.Value;
            }

            if (msgNum == 1)
            {
                // Only clear the book if this is the first message in the
                // set of updates.
                delta.clear();
            }

            if (!mHaveSanityCheckedBookDict)
            {
                mHaveSanityCheckedBookDict = true;
                if (MamdaOrderBookFields.PRICE_LEVEL.Length == 0)
                {
                    throw new MamdaOrderBookException (
                        "data dictionary error: cannot find price level fields");
                }
            }

            //for optimised feed date, wNumLevels should be assumed = 1 if not sent
            int numLevelFieldInMsg = 1;
            if (msg.tryI32(MamdaOrderBookFields.NUM_LEVELS, ref mNumLevelFields))
            {
                numLevelFieldInMsg = mNumLevelFields.Value;
            }

            int maxLevelFields = MamdaOrderBookFields.PRICE_LEVEL.Length;
            if (numLevelFieldInMsg < maxLevelFields)
            {
                maxLevelFields = numLevelFieldInMsg;
            }

            for (int i = 1; i <= maxLevelFields; i++)
            {
                MamaMsg plMsg = msg.getMsg(MamdaOrderBookFields.PRICE_LEVEL[i], null);

                if (plMsg == null)
                {
                    if (numLevelFieldInMsg == 1)
                    {
                        /* Price level fields are probably be in the main
                         * message. */
                        plMsg = msg;
                    }
                    else
                    {
                        throw new MamdaDataException (
                            "cannot find price level fields in MamaMsg");
                    }
                }

                MamdaOrderBookPriceLevel level = new MamdaOrderBookPriceLevel();
                getLevelInfo(level, plMsg, delta);
                getEntries(level, plMsg);
                delta.addLevel (level);
            }
            return msgNum == msgTotal;
        }
        /// <summary>
        /// Returns whether a complete book delta was received.
        ///
        /// Books without vector fields (i.e. fixed field layout) might
        /// come in multiple MamaMsgs.  The MdMsgNum and MdTotalNum
        /// fields can be used to determine which message is which.
        ///
        /// When a single price level is present, it may or may not be
        /// encapsulated in a nested message field.  Similarly, with single
        /// entries in a price level.
        /// </summary>
        /// <param name="delta"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool createDeltaFromMamaMsgWithoutVectorFields(
            MamdaOrderBook delta,
            MamaMsg msg)
        {
            int msgNum   = 1;
            int msgTotal = 1;

            if (msg.tryI32(MamaReservedFields.MsgNum, ref mMsgNum))
            {
                msgNum = mMsgNum.Value;
            }
            if (msg.tryI32(MamaReservedFields.MsgTotal, ref mMsgTotal))
            {
                msgTotal = mMsgTotal.Value;
            }

            if (msgNum == 1)
            {
                // Only clear the book if this is the first message in the
                // set of updates.
                delta.clear();
            }

            if (!mHaveSanityCheckedBookDict)
            {
                mHaveSanityCheckedBookDict = true;
                if (MamdaOrderBookFields.PRICE_LEVEL.Length == 0)
                {
                    throw new MamdaOrderBookException(
                              "data dictionary error: cannot find price level fields");
                }
            }

            //for optimised feed date, wNumLevels should be assumed = 1 if not sent
            int numLevelFieldInMsg = 1;

            if (msg.tryI32(MamdaOrderBookFields.NUM_LEVELS, ref mNumLevelFields))
            {
                numLevelFieldInMsg = mNumLevelFields.Value;
            }

            int maxLevelFields = MamdaOrderBookFields.PRICE_LEVEL.Length;

            if (numLevelFieldInMsg < maxLevelFields)
            {
                maxLevelFields = numLevelFieldInMsg;
            }

            for (int i = 1; i <= maxLevelFields; i++)
            {
                MamaMsg plMsg = msg.getMsg(MamdaOrderBookFields.PRICE_LEVEL[i], null);

                if (plMsg == null)
                {
                    if (numLevelFieldInMsg == 1)
                    {
                        /* Price level fields are probably be in the main
                         * message. */
                        plMsg = msg;
                    }
                    else
                    {
                        throw new MamdaDataException(
                                  "cannot find price level fields in MamaMsg");
                    }
                }

                MamdaOrderBookPriceLevel level = new MamdaOrderBookPriceLevel();
                getLevelInfo(level, plMsg, delta);
                getEntries(level, plMsg);
                delta.addLevel(level);
            }
            return(msgNum == msgTotal);
        }