Example #1
0
            public void onMsg(
                MamaSubscription subscription,
                MamaMsg msg)
            {
                mamaMsgType   msgType   = msg.typeForMsg();
                mamaMsgStatus msgStatus = msg.getStatus();

                switch (msgType)
                {
                case mamaMsgType.MAMA_MSG_TYPE_DELETE:
                case mamaMsgType.MAMA_MSG_TYPE_EXPIRE:
                    subscription.deallocate();
                    return;
                }

                switch (msgStatus)
                {
                case mamaMsgStatus.MAMA_MSG_STATUS_BAD_SYMBOL:
                case mamaMsgStatus.MAMA_MSG_STATUS_EXPIRED:
                case mamaMsgStatus.MAMA_MSG_STATUS_TIMEOUT:
                    subscription.deallocate();
                    return;
                }

                for (int i = 0; i < mSubscription.mMsgListeners.Count; i++)
                {
                    MamdaMsgListener listener = (MamdaMsgListener)mSubscription.mMsgListeners[i];
                    listener.onMsg(mSubscription, msg, msgType);
                }
            }
        /// <summary>
        /// Implementation of the MamdaMsgListener Interface.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            string partId = getPartId(msg);

            // First handle the message internally. I.e. create listener
            // lists, notify handlers etc.
            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                handleFullImage(subscription, msg, msgType, partId);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS:                    /*Don't forward.*/
                return;

            default:
                break;
            }
            // Now pass to other listerners (if any)
            forwardMsg(subscription, msg, msgType, partId);
        }
        /// <summary>
        /// Implementation of MamdaListener interface.
        /// </summary>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            // If msg is a trade-related message, invoke the
            // appropriate callback:
            updateFieldStates();
            lock (this)
            {
                mUpdated = false;
                msg.iterateFields(mFieldIterator, null, null);
            }
            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                handleRecap(subscription, msg);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_PREOPENING:
            case mamaMsgType.MAMA_MSG_TYPE_SEC_STATUS:
            case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
            case mamaMsgType.MAMA_MSG_TYPE_QUOTE:
            case mamaMsgType.MAMA_MSG_TYPE_TRADE:
            case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
                handleSecurityStatus(subscription, msg);
                break;
            }
        }
        public void onMsg(MamdaSubscription subscription,
                          MamaMsg msg,
                          mamaMsgType msgType)
        {
            if (!MamdaOrderBookFields.isSet())
            {
                return;
            }

            try
            {
                switch (msgType)
                {
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_CLEAR:
                    handleClear(subscription, msg);
                    break;

                case mamaMsgType.MAMA_MSG_TYPE_BOOK_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_RECAP:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_SNAPSHOT:
                    handleRecap(subscription, msg);
                    break;

                case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
                    handleUpdate(subscription, msg);
                    break;
                }
            }
            catch (MamaException)
            {
            }
        }
Example #5
0
        private void handleAuctionMessage(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            updateFieldStates();

            lock (this)
            {
                msg.iterateFields(mFieldIterator, null, null);
            }

            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                handleRecap(subscription, msg);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                handleUpdate(subscription, msg);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            if (!MamdaOrderBookFields.isSet())
            {
                return;
            }

            // If msg is a order book related message, invoke the
            // appropriate callback:
            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_BOOK_CLEAR:
                handleClear(subscription, msg);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_BOOK_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_BOOK_RECAP:
            case mamaMsgType.MAMA_MSG_TYPE_BOOK_SNAPSHOT:
                handleRecap(subscription, msg);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
                handleUpdate(subscription, msg);
                break;
            }
        }
Example #7
0
 public void onMsg(
     MamdaSubscription subscription,
     MamaMsg msg,
     mamaMsgType msgType)
 {
     Console.WriteLine("Update ({0})", subscription.getSymbol());
 }
        /// <summary>
        /// Implementation of the MamdaMsgListener Interface.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            try
            {
                string symbol = msg.getString(MamdaCommonFields.ISSUE_SYMBOL);
                if (symbol == null)
                {
                    return;
                }
                // First handle the message internally. i.e. create listener
                // lists, notify handlers etc.
                switch (msgType)
                {
                case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                    handleFullImage(subscription, msg, msgType, symbol);
                    break;

                case mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS:                        /*Don't forward.*/
                    return;

                default:
                    break;
                }
                // Now pass to other listeners (if any)
                forwardMsg(subscription, msg, msgType, symbol);
            }
            catch (MamdaDataException)
            {
            }
        }
 /// <summary>
 /// Process initial images. This is most likely when we will be
 /// notify of the creation of a new security.
 /// </summary>
 /// <param name="subscription"></param>
 /// <param name="msg"></param>
 /// <param name="msgType"></param>
 /// <param name="symbol"></param>
 private void handleFullImage(
     MamdaSubscription subscription,
     MamaMsg msg,
     mamaMsgType msgType,
     string symbol)
 {
     if (!mListeners.containsKey(symbol))
     {
         checkSecurityCreateNotify(subscription, symbol);
     }
 }
 /// <summary>
 /// Generic method for dispatching messages to instances of
 /// MamaMsgListeners.
 /// </summary>
 /// <param name="listeners"></param>
 /// <param name="subscription"></param>
 /// <param name="msg"></param>
 /// <param name="msgType"></param>
 private void forwardMsg(
     ArrayList listeners,
     MamdaSubscription subscription,
     MamaMsg msg,
     mamaMsgType msgType)
 {
     foreach (MamdaMsgListener listener in listeners)
     {
         listener.onMsg(subscription, msg, msgType);
     }
 }
        /*      End Field State Accessors   */

        private void handleQuoteMsg(
            MamdaOptionContract contract,
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            MamdaQuoteListener quoteListener = contract.getQuoteListener();

            if (quoteListener != null)
            {
                quoteListener.onMsg(subscription, msg, msgType);
            }
        }
        private void handleTradeMsg(
            MamdaOptionContract contract,
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            MamdaTradeListener tradeListener = contract.getTradeListener();

            if (tradeListener != null)
            {
                tradeListener.onMsg(subscription, msg, msgType);
            }
        }
 /// <summary>
 /// Process initial images. This is most likely when we will be
 /// notify of consolidate/participant creation.
 /// </summary>
 /// <param name="subscription"></param>
 /// <param name="msg"></param>
 /// <param name="msgType"></param>
 /// <param name="partId"></param>
 private void handleFullImage(
     MamdaSubscription subscription,
     MamaMsg msg,
     mamaMsgType msgType,
     string partId)
 {
     if (partId == null)             /*This is a consolidated initial*/
     {
         checkConsolidatedCreateNotify(subscription);
     }
     else             /*This is a participant initial*/
     {
         ParticipantInfo partInfo = getParticipantInfo(partId);
         checkParticipantCreateNotify(subscription, partId, partInfo);
     }
 }
        /// <summary>
        /// Implementation of MamdaListener interface.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            if (!MamdaOptionFields.isSet())
            {
                return;
            }

            if (msgType == mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS)
            {
                foreach (MamdaOptionChainHandler handler in mHandlers)
                {
                    handler.onOptionChainRecap(subscription, this, msg, mChain);
                }
                return;
            }

            MamdaOptionContract contract = findContract(subscription, msg);

            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                handleQuoteMsg(contract, subscription, msg, msgType);
                handleTradeMsg(contract, subscription, msg, msgType);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_QUOTE:
                handleQuoteMsg(contract, subscription, msg, msgType);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_TRADE:
            case mamaMsgType.MAMA_MSG_TYPE_CANCEL:
            case mamaMsgType.MAMA_MSG_TYPE_ERROR:
            case mamaMsgType.MAMA_MSG_TYPE_CORRECTION:
                handleTradeMsg(contract, subscription, msg, msgType);
                break;
            }
        }
        private void forwardMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType,
            String symbol)
        {
            ArrayList securityListeners = (ArrayList)mListeners.valueOf(symbol);

            if ((securityListeners != null) && (securityListeners.Count > 0))
            {
                forwardMsg(
                    securityListeners,
                    subscription,
                    msg,
                    msgType);
            }
            else
            {
                /*Needed for new symbols created intraday*/
                checkSecurityCreateNotify(subscription, symbol);
            }
        }
Example #16
0
/*      End Field State Accessors       */

        // Implementation of MamdaListener interface.
        // NB! For internal use only.
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            // Listeners may be created on multiple threads and we only
            // want a single list of updaters.
            if (mUpdaters == null)
            {
                lock (mUpdatersGuard)
                {
                    if (!MamdaAuctionFields.isSet())
                    {
                        return;
                    }

                    if (mUpdaters == null)
                    {
                        AuctionUpdate[] updaters = createUpdaters();
                        Thread.MemoryBarrier();
                        mUpdaters = updaters;
                    }
                }
            }

            // If msg is a Auction-related message, invoke the
            // appropriate callback:
            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
            case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                handleAuctionMessage(subscription, msg, msgType);
                break;

            default:
                break;
            }
        }
Example #17
0
		/// <summary>
		/// Implementation of MamdaListener interface.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		public void onMsg(
			MamdaSubscription	subscription,
			MamaMsg				msg,
			mamaMsgType			msgType)
		{
			if(!MamdaOptionFields.isSet())
			{
				return;
			}

			if (msgType == mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS)
			{
				foreach (MamdaOptionChainHandler handler in mHandlers)
				{
					handler.onOptionChainRecap(subscription, this, msg, mChain);
				}
				return;
			}

			MamdaOptionContract contract = findContract(subscription, msg);

			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
					handleQuoteMsg(contract, subscription, msg, msgType);
					handleTradeMsg(contract, subscription, msg, msgType);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_QUOTE:
					handleQuoteMsg(contract, subscription, msg, msgType);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_TRADE:
				case mamaMsgType.MAMA_MSG_TYPE_CANCEL:
				case mamaMsgType.MAMA_MSG_TYPE_ERROR:
				case mamaMsgType.MAMA_MSG_TYPE_CORRECTION:
					handleTradeMsg(contract, subscription, msg, msgType);
					break;
			}
		}
        private void forwardMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType,
            String partId)
        {
            if (partId == null)             /*Participant message*/
            {
                /* We may not have an entry for this partId at this stage as
                 * we may not be receiving initial values for the subscription. */
                ParticipantInfo partInfo = getParticipantInfo(partId);

                /* Need to check if we have notified. We may well not be receiving
                 * initials*/
                checkParticipantCreateNotify(subscription, partId, partInfo);

                /* We may have a ParticipantInfo entry for the partId but there is
                 * still no guarantee that any listeners have been registered.
                 * This is quite acceptable as users may not be interested in all
                 * participants. */
                if (partInfo.mParticipantListeners.Count > 0)
                {
                    forwardMsg(partInfo.mParticipantListeners, subscription, msg, msgType);
                }
            }
            else             /*Consolidated message*/
            {
                /* We may not have notified the user that a consolidated message
                 * has arrived. If not using initials this can be the case.*/
                checkConsolidatedCreateNotify(subscription);

                /* Forward the message if we have any listeners*/
                if (mConsolidatedListeners.Count > 0)
                {
                    forwardMsg(mConsolidatedListeners, subscription, msg, msgType);
                }
            }
        }
        /// <summary>
        /// Implementation of MamdaListener interface.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            if (!MamdaFundamentalFields.isSet())
            {
                return;
            }
            // If msg is a trade-related message, invoke the
            // appropriate callback:
            switch (msgType)
            {
            case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
            case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                handleRecap(subscription, msg);
                break;

            case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                handleUpdate(subscription, msg);
                break;
            }
        }
Example #20
0
        public void onMsg(MamdaSubscription subscription,
                           MamaMsg           msg,
                           mamaMsgType       msgType)
        {
            if(!MamdaOrderBookFields.isSet())
            {
                return;
            }

            try
            {
                switch (msgType)
                {
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_CLEAR:
                    handleClear (subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_RECAP:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_SNAPSHOT:
                    handleRecap (subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
                    handleUpdate (subscription, msg);
                    break;
                }
            }
            catch (MamaException)
            {
            }
        }
Example #21
0
		// Implementation of MamdaListener interface.
		// NB! For internal use only.
		public void onMsg(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType		  msgType)
		{			
			// Listeners may be created on multiple threads and we only
			// want a single list of updaters.
			if (mUpdaters == null)
			{
				lock (mUpdatersGuard)
				{
					if(!MamdaQuoteFields.isSet())
					{
						return;
					}

					if (mUpdaters == null)
					{
						QuoteUpdate[] updaters = createUpdaters();
						Thread.MemoryBarrier();
						mUpdaters = updaters;
					}
				}
			}

			// If msg is a quote-related message, invoke the
			// appropriate callback:
            
            //Clear conflate count
            mQuoteCache.mConflateCount  = 1; 
             
			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
				case mamaMsgType.MAMA_MSG_TYPE_PREOPENING:
				case mamaMsgType.MAMA_MSG_TYPE_SNAPSHOT:
					handleRecap(subscription, msg);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_QUOTE:
					handleQuote(subscription, msg);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
				case mamaMsgType.MAMA_MSG_TYPE_TRADE:
					handleUpdate(subscription, msg);
					break;
			}
		}
		/// <summary>
		/// Implementation of the MamdaMsgListener Interface.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		public void onMsg(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType       msgType)
		{
			try
			{
				string symbol = msg.getString(MamdaCommonFields.ISSUE_SYMBOL);
				if(symbol == null)
				{
					return;
				}
				// First handle the message internally. i.e. create listener
				// lists, notify handlers etc.
				switch (msgType)
				{
					case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
					case mamaMsgType.MAMA_MSG_TYPE_RECAP:
						handleFullImage(subscription, msg, msgType, symbol);
						break;
					case mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS:/*Don't forward.*/
						return;
					default:
						break;
				}
				// Now pass to other listeners (if any)
				forwardMsg(subscription, msg, msgType, symbol);
			}
			catch (MamdaDataException ex)
			{
			}
		}
		/// <summary>
		/// Generic method for dispatching messages to instances of
		/// MamaMsgListeners.
		/// </summary>
		/// <param name="listeners"></param>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		private void forwardMsg(
			ArrayList           listeners,
			MamdaSubscription   subscription,
			MamaMsg             msg,
			mamaMsgType         msgType)
		{
			foreach (MamdaMsgListener listener in listeners)
			{
				listener.onMsg(subscription, msg, msgType);
			}
		}
		private void forwardMsg(
			MamdaSubscription  subscription,
			MamaMsg            msg,
			mamaMsgType        msgType,
			String             symbol)
		{
			ArrayList securityListeners = (ArrayList)mListeners.valueOf(symbol);
			if ((securityListeners != null) && (securityListeners.Count > 0))
			{
				forwardMsg(
					securityListeners,
					subscription,
					msg,
					msgType);
			}
			else
			{
				/*Needed for new symbols created intraday*/
				checkSecurityCreateNotify(subscription, symbol);
			}
		}
Example #25
0
        /// <summary>
        /// Implementation of MamdaListener interface.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
            MamdaSubscription subscription,
            MamaMsg msg,
            mamaMsgType msgType)
        {
            // Ensure only a single instance is created.
            // Listeners may be created on separate threads.
            if (mUpdaters == null)
            {
                lock (mUpdatersGuard)
                {
                    if (!MamdaTradeFields.isSet())
                    {
                        return;
                    }

                    if (mUpdaters == null)
                    {
                        TradeUpdate[] updaters = createUpdaters();
                        Thread.MemoryBarrier();
                        mUpdaters = updaters;
                    }
                }
            }

            // If msg is a trade-related message, invoke the
            // appropriate callback:
            mTradeCache.mWasIrregular = mTradeCache.mIsIrregular;
            mTradeCache.mConflateCount = 1;

            switch (msgType)
            {
                case mamaMsgType.MAMA_MSG_TYPE_SNAPSHOT:
                case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                case mamaMsgType.MAMA_MSG_TYPE_PREOPENING:
                    handleRecap(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_TRADE:
                    handleTrade(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_CANCEL:
                    handleCancelOrError(subscription, msg, true);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_ERROR:
                    handleCancelOrError(subscription, msg, false);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_CORRECTION:
                    handleCorrection(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_CLOSING:
                    handleClosing(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                    if (mProcessUpdateAsTrade)
                    {
                        handleUpdate(subscription, msg);
                    }
                    break;
            }
        }
Example #26
0
        /*      End Field State Accessors   */

        private void handleQuoteMsg(
			MamdaOptionContract  contract,
			MamdaSubscription    subscription,
			MamaMsg              msg,
			mamaMsgType          msgType)
		{
			MamdaQuoteListener quoteListener = contract.getQuoteListener();
			if (quoteListener != null)
			{
				quoteListener.onMsg(subscription, msg, msgType);
			}
		}
Example #27
0
            public void onMsg(
				MamdaSubscription subscription,
				MamaMsg msg,
				mamaMsgType msgType)
            {
                Console.WriteLine("Update ({0})", subscription.getSymbol());
            }
		private void forwardMsg(
			MamdaSubscription  subscription,
			MamaMsg            msg,
			mamaMsgType        msgType,
			String             partId)
		{
			if (partId == null) /*Participant message*/
			{
				/* We may not have an entry for this partId at this stage as
				   we may not be receiving initial values for the subscription. */
				ParticipantInfo partInfo = getParticipantInfo(partId);

				/* Need to check if we have notified. We may well not be receiving
				 * initials*/
				checkParticipantCreateNotify(subscription, partId, partInfo);

				/* We may have a ParticipantInfo entry for the partId but there is
				   still no guarantee that any listeners have been registered. 
				   This is quite acceptable as users may not be interested in all
				   participants. */
				if (partInfo.mParticipantListeners.Count > 0)
				{
					forwardMsg(partInfo.mParticipantListeners, subscription, msg, msgType);
				}
			}
			else /*Consolidated message*/
			{
				/* We may not have notified the user that a consolidated message
				   has arrived. If not using initials this can be the case.*/
				checkConsolidatedCreateNotify(subscription);

				/* Forward the message if we have any listeners*/
				if (mConsolidatedListeners.Count > 0)
				{   
					forwardMsg(mConsolidatedListeners, subscription, msg, msgType);
				}
			}
		}
		/// <summary>
		/// Implementation of MamdaListener interface.
		/// </summary>
		public void onMsg(
			MamdaSubscription subscription,
			MamaMsg msg,
			mamaMsgType msgType)
		{
			// If msg is a trade-related message, invoke the
			// appropriate callback:
            updateFieldStates();
			lock (this)
			{
				mUpdated = false;             
				msg.iterateFields(mFieldIterator, null, null);
			}
			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
					handleRecap(subscription, msg);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_PREOPENING:
	            case mamaMsgType.MAMA_MSG_TYPE_SEC_STATUS:
				case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
				case mamaMsgType.MAMA_MSG_TYPE_QUOTE:
				case mamaMsgType.MAMA_MSG_TYPE_TRADE:
				case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
					handleSecurityStatus(subscription, msg);
					break;
			}
		}
		/// <summary>
		/// Process initial images. This is most likely when we will be
		/// notify of consolidate/participant creation.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		/// <param name="partId"></param>
		private void handleFullImage(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType       msgType,
			string            partId)
		{
			if (partId == null) /*This is a consolidated initial*/
			{
				checkConsolidatedCreateNotify(subscription);
			}
			else /*This is a participant initial*/
			{
				ParticipantInfo partInfo = getParticipantInfo(partId);
				checkParticipantCreateNotify(subscription, partId, partInfo);
			}
		}
Example #31
0
        /*      End Field State Accessors       */
        // Implementation of MamdaListener interface.
        // NB! For internal use only.
        public void onMsg(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType		  msgType)
        {
            // Listeners may be created on multiple threads and we only
            // want a single list of updaters.
            if (mUpdaters == null)
            {
                lock (mUpdatersGuard)
                {
                    if(!MamdaAuctionFields.isSet())
                    {
                        return;
                    }

                    if (mUpdaters == null)
                    {
                        AuctionUpdate[] updaters = createUpdaters();
                        Thread.MemoryBarrier();
                        mUpdaters = updaters;
                    }
                }
            }

            // If msg is a Auction-related message, invoke the
            // appropriate callback:
            switch (msgType)
            {
                case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                    handleAuctionMessage(subscription, msg, msgType);
                    break;
                default:
                    break;
            }
        }
		/// <summary>
		/// Implementation of MamdaListener interface.
		/// </summary>
		public void onMsg(
			MamdaSubscription	subscription,
			MamaMsg				msg,
			mamaMsgType			msgType)
		{
			if (mUpdaters == null)
			{
				lock (mUpdatersGuard)
				{
					if(!MamdaOrderImbalanceFields.isSet())
					{
						return;
					}

					if (mUpdaters == null)
					{
						ImbalanceOrderUpdate[] updaters = createUpdaters();
						Thread.MemoryBarrier();
						mUpdaters = updaters;
					}
				}
			}

			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
				case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                    updateFieldStates();
					updateOrderImbalanceFields(subscription, msg, msgType);
					break;
				default:
					break;
			}
		}
Example #33
0
        private void handleAuctionMessage(
			MamdaSubscription  subscription,
			MamaMsg            msg,
            mamaMsgType        msgType)
        {
            updateFieldStates();

            lock (this)
            {
                msg.iterateFields(mFieldIterator, null, null);
            }

            switch(msgType)
            {
                case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_RECAP:
                    handleRecap(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
                    handleUpdate(subscription, msg);
                    break;
                default:
                    break;

            }
        }
Example #34
0
		/// <summary>
		/// Implementation of MamdaListener interface.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		public void onMsg(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType       msgType)
		{
			if (!MamdaFundamentalFields.isSet())
			{
				return;
			}
			// If msg is a trade-related message, invoke the
			// appropriate callback:
			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
					handleRecap (subscription, msg);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
					handleUpdate (subscription, msg);
					break;
			}
		}
Example #35
0
 /// <summary>
 /// Return the type name.
 /// </summary>
 public string stringForType(mamaMsgType type)
 {
     EnsurePeerCreated();
     return Marshal.PtrToStringAnsi(NativeMethods.mamaMsgType_stringForType((int)type));
 }
		/// <summary>
		/// Process initial images. This is most likely when we will be
		/// notify of the creation of a new security.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		/// <param name="symbol"></param>
		private void handleFullImage(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType       msgType,
			string            symbol)
		{
			if(!mListeners.containsKey(symbol))
			{
				checkSecurityCreateNotify(subscription, symbol);
			}
		}
Example #37
0
		private void handleTradeMsg(
			MamdaOptionContract  contract,
			MamdaSubscription    subscription,
			MamaMsg              msg,
			mamaMsgType          msgType)
		{
			MamdaTradeListener tradeListener = contract.getTradeListener();
			if (tradeListener != null)
			{
				tradeListener.onMsg(subscription, msg, msgType);
			}
		}	
        private void updateOrderImbalanceFields(
			MamdaSubscription	subscription,
			MamaMsg				msg,
			mamaMsgType			msgType)
		{
			string securityStatus = null;
			lock (this)
			{
				MamaMsgField msgField = null;
	            
				/*The wSecStatusQual will not always be in the message 
				so you need to account for this by checking for it.
				*/
				try
				{
					msgField = msg.getField(MamdaOrderImbalanceFields.SECURITY_STATUS_QUAL, null);
				}
				catch (MamdaDataException ex)
				{
					throw new MamaException(MamaStatus.mamaStatus.MAMA_STATUS_PLATFORM, ex.Message);
				}
				if (msgField == null) //does not exist
					return;

				securityStatus = msgField.getString();

				if (isImbalanceType(securityStatus))
				{
					clearCache(mOrderImbalanceCache);
				}
				msg.iterateFields(mFieldIterator, null,null);
			}

			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
					handleRecap(subscription, msg);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_UPDATE:
				{
					int value = 0;
					if (securityStatus != null)
					{
						value = MamdaOrderImbalanceType.stringToValue(securityStatus);
						if (MamdaOrderImbalanceType.isMamdaImbalanceOrder(value))
						{
							handleOrderImbalance(subscription,msg); 
						}
						else
						{
							handleNoOrderImbalance(subscription, msg); 
						}
					}
				}
				break;
			default:
				break;
			}
	        
		}
Example #39
0
        /// <summary>
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="msg"></param>
        /// <param name="msgType"></param>
        public void onMsg(
			MamdaSubscription subscription,
			MamaMsg msg,
			mamaMsgType msgType)
        {
            if(!MamdaOrderBookFields.isSet())
            {
                return;
            }

            // If msg is a order book related message, invoke the
            // appropriate callback:
            switch (msgType)
            {
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_CLEAR:
                    handleClear(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_INITIAL:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_RECAP:
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_SNAPSHOT:
                    handleRecap(subscription, msg);
                    break;
                case mamaMsgType.MAMA_MSG_TYPE_BOOK_UPDATE:
                    handleUpdate(subscription, msg);
                    break;
            }
        }
		/// <summary>
		/// Implementation of the MamdaMsgListener Interface.
		/// </summary>
		/// <param name="subscription"></param>
		/// <param name="msg"></param>
		/// <param name="msgType"></param>
		public void onMsg(
			MamdaSubscription subscription,
			MamaMsg           msg,
			mamaMsgType       msgType)
		{
			string partId = getPartId(msg);
			// First handle the message internally. I.e. create listener
			// lists, notify handlers etc.
			switch (msgType)
			{
				case mamaMsgType.MAMA_MSG_TYPE_INITIAL:
				case mamaMsgType.MAMA_MSG_TYPE_RECAP:
					handleFullImage(subscription, msg, msgType, partId);
					break;
				case mamaMsgType.MAMA_MSG_TYPE_END_OF_INITIALS:/*Don't forward.*/
					return;
				default:
					break;
			}
			// Now pass to other listerners (if any)
			forwardMsg(subscription, msg, msgType, partId);
		}