Class which encapsulates the messages used in the MAMA infrastructure
Inheritance: MamaWrapper
Ejemplo n.º 1
0
 public void onQuoteRecap(
     MamdaSubscription   sub,
     MamdaQuoteListener  listener,
     MamaMsg             msg,
     MamdaQuoteRecap     recap)
 {
 }
Ejemplo n.º 2
0
 public void onQuoteClosing(
     MamdaSubscription   sub,
     MamdaQuoteListener  listener,
     MamaMsg             msg,
     MamdaQuoteClosing   closingEvent,
     MamdaQuoteRecap     recap)
 {
 }
Ejemplo n.º 3
0
 public void Teardown()
 {
     // Reset member variables
     if (m_msg != null)
     {
         m_msg.destroy();
         m_msg = null;
     }
 }
Ejemplo n.º 4
0
        public void onQuoteRecap(
			MamdaSubscription   sub,
			MamdaQuoteListener  listener,
			MamaMsg             msg,
			MamdaQuoteRecap     recap)
        {
            Console.WriteLine ("Quote Recap (" + msg.getString
                            (MamdaCommonFields.ISSUE_SYMBOL)+ "): ");
        }
Ejemplo n.º 5
0
        public void onQuoteClosing(
			MamdaSubscription   sub,
			MamdaQuoteListener  listener,
			MamaMsg             msg,
			MamdaQuoteClosing   closingEvent,
			MamdaQuoteRecap     recap)
        {
            Console.WriteLine("Quote Closing (" + sub.getSymbol() + "): ");
        }
Ejemplo n.º 6
0
        public void onQuoteGap(
			MamdaSubscription   sub,
			MamdaQuoteListener  listener,
			MamaMsg             msg,
			MamdaQuoteGap       gapEvent,
			MamdaQuoteRecap     recap)
        {
            Console.WriteLine("Quote gap (" + gapEvent.getBeginGapSeqNum() +
                            "-" + gapEvent.getEndGapSeqNum() + ")");
        }
 public void addMamaHeaderFields(
                     MamaMsg msg,
                     byte msgType,
                     byte msgStatus,
                     uint seqNum)
 {
     msg.addU8(null, 1, msgType);
     msg.addU8(null, 2, msgStatus);
     msg.addU32(null, 10, seqNum);
     msg.addU64(null, 20, 1);
 }
Ejemplo n.º 8
0
        public void Setup()
        {
			Mama.loadBridge ("lbm");
			Mama.open ();
            // Create the message
            m_msg = new MamaMsg();

            // Create the array of messages
            m_vectorPrice = InitialisePriceArray(m_numberPrices, 69);
            m_vectorPrice2 = InitialisePriceArray(m_numberPrices, 144);
        }
 public void testOrigShortSaleCircuitBreaker()
 {
     mMsg = new MamaMsg();
     addMamaHeaderFields(mMsg,
                         (byte)mamaMsgType.MAMA_MSG_TYPE_CANCEL,
                         (byte)mamaMsgStatus.MAMA_MSG_STATUS_OK,
                         (uint)1);
     mMsg.addChar("wOrigShortSaleCircuitBreaker", 5249, 'C');
     ticker.callMamdaOnMsg(mSubscription, mMsg);
     Assert.AreEqual('C', ticker.myOrigShortSaleCircuitBreaker);
 }
Ejemplo n.º 10
0
        public void TestCorrTradeId()
        {
            mMsg = new MamaMsg();

            addMamaHeaderFields(mMsg,
                                (byte)mamaMsgType.MAMA_MSG_TYPE_CORRECTION,
                                (byte)mamaMsgStatus.MAMA_MSG_STATUS_OK,
                                (uint)1);
            mMsg.addString("wCorrTradeId", 4060, "B");
            ticker.callMamdaOnMsg(mSubscription, mMsg);
            Assert.AreEqual("B", ticker.myCorrTradeId);
        }
Ejemplo n.º 11
0
        public void onQuoteUpdate(
			MamdaSubscription   sub,
			MamdaQuoteListener  listener,
			MamaMsg             msg,
			MamdaQuoteUpdate    update,
			MamdaQuoteRecap     recap)
        {
            Console.WriteLine ("Quote ("  + msg.getString
                                (MamdaCommonFields.ISSUE_SYMBOL)   +
                                ":"        + recap.getQuoteCount()  +
                                "):  "     + update.getBidPrice()    +
                                " "        + update.getBidSize()     +
                                " X "      + update.getAskSize()     +
                                " "        + update.getAskPrice()    +
                                " (seq#: " + update.getEventSeqNum() +
                                "; time: " + update.getEventTime()   +
                                "; qual: " + update.getQuoteQual()   + ")");
        }
 public void callMamdaOnMsg(MamdaSubscription sub, MamaMsg msg)
 {
     try
     {
         ArrayList msgListeners = new ArrayList();
         msgListeners = sub.getMsgListeners();
         IEnumerator iter = msgListeners.GetEnumerator();
         int size = msgListeners.Count;
         for (int i = 0; i < size; i++)
         {
             iter.MoveNext();
             MamdaMsgListener listener = (MamdaMsgListener)iter.Current;
             listener.onMsg(sub, msg, msg.getType());
         }
     }
     catch (Exception ex)
     {
         throw new MamdaDataException(ex.Message, ex);
     }
 }
Ejemplo n.º 13
0
        private void CheckMessageArray(MamaMsg[] messages, int numberMessages, int offset)
        {
            // Verify that the array has the correct number of messages
            if (messages.Length != numberMessages)
            {
                throw new ArgumentOutOfRangeException("numberMessages");
            }

            // Chech each item in the array
            for (int nextMessage = 0; nextMessage < numberMessages; nextMessage++)
            {
                // Get the int32 field
                int intValue = messages[nextMessage].getI32(string.Empty, (ushort)(nextMessage + 1));

                // Verify that it has the correct value
                if (intValue != (nextMessage + offset))
                {
                    throw new InvalidOperationException();
                }
            }
        }
Ejemplo n.º 14
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;
			}
		}
Ejemplo n.º 15
0
            public void onTradeCorrection(
				MamdaSubscription        sub,
				MamdaTradeListener       listener,
				MamaMsg                  msg,
				MamdaTradeCorrection     correctionEvent,
				MamdaTradeRecap          recap)
            {
            }
Ejemplo n.º 16
0
        private MamdaOptionContract.PutOrCall extractPutCall(
                MamaMsg        msg,
                string         fullSymbol)
            {
                MamdaOptionContract.PutOrCall putCall = MamdaOptionContract.PutOrCall.Unknown;
                int putCallInt = 0;               
                if (!msg.tryField (MamdaOptionFields.PUT_CALL, ref tmpfield_))
                {   
                    
                   Console.WriteLine("findContract:CANNOT find put/call in msg:"+fullSymbol+putCall);
                }
                else
                {
                    switch(tmpfield_.getType())
                    {
                        case mamaFieldType.MAMA_FIELD_TYPE_I8:
                        case mamaFieldType.MAMA_FIELD_TYPE_U8:
                        case mamaFieldType.MAMA_FIELD_TYPE_I16:
                        case mamaFieldType.MAMA_FIELD_TYPE_U16:                  
                            putCallInt = tmpfield_.getU16();
                        switch(putCallInt)
                        {
                            case 1:
                                putCall = MamdaOptionContract.PutOrCall.Put;
                                break;
                            case 2:
                                putCall = MamdaOptionContract.PutOrCall.Call;
                                break;
                            case 99:
                                putCall = MamdaOptionContract.PutOrCall.Unknown;
                                break;
                            default:
                                putCall =  MamdaOptionContract.PutOrCall.Unknown;                       
                                Console.WriteLine("Unhandled value for wPutCall."+ putCallInt);
                                break;
                        }
                        break; 
                        case mamaFieldType.MAMA_FIELD_TYPE_STRING:                       
                        string putCallStr = tmpfield_.getString();                      
                        switch (putCallStr[0])
                        {
                            case '1':
                            case 'P':
                                putCall = MamdaOptionContract.PutOrCall.Put;
                                break;
                            case '2':
                            case 'C':
                                putCall = MamdaOptionContract.PutOrCall.Call;
                                break;
                            default:
                                putCall = MamdaOptionContract.PutOrCall.Unknown; 
                                if ((putCallStr=="99") && (putCallStr=="Z"))
                                {
                                    Console.WriteLine("Unhandled value for wPutCall."+ putCallStr);

                                }
                                break;
                        }
                        break;
                        default:
                            putCall = MamdaOptionContract.PutOrCall.Unknown;               
                            Console.WriteLine("Unhandled type for wPutCall. Expected string or integer but returned: "+tmpfield_.getType());
                            break;
                    }
                }
                return putCall;
            }
Ejemplo n.º 17
0
        private MamdaOptionContract findContract(
            MamdaSubscription  subscription,
            MamaMsg            msg)
        {
            /*
            * NOTE: fields which are enums can be pubished as integers if feedhandler
            * uses mama-publish-enums-as-ints.  It may also be possible for a feed to
            * publish the numerical value as a string. All enumerated fields must be handled
            * by getting the value based on the field type.
            */

            // Look up the strike price and expiration date
            string contractSymbol = null;
            if (!msg.tryString(MamdaOptionFields.CONTRACT_SYMBOL, ref contractSymbol))
            {
                throw new MamdaDataException ("cannot find contract symbol");
            }

            string fullSymbol = contractSymbol;
            MamdaOptionContract contract = mChain.getContract(fullSymbol);
            if (contract == null)
            {
                string expireDateStr = String.Empty;
                double strikePrice = 0.0;
                string putCall = String.Empty;
                uint openInterest = 0;
                
                msg.tryString(MamdaOptionFields.EXPIRATION_DATE, ref expireDateStr);
                msg.tryF64(MamdaOptionFields.STRIKE_PRICE, ref strikePrice);

                if (msg.tryField (MamdaOptionFields.PUT_CALL, ref tmpfield_))
                {
                    putCall = getFieldAsString(tmpfield_);
                }

                int symbolLen = fullSymbol.Length;
                string symbol   = null;
                string exchange = null;
                int dotIndex = fullSymbol.LastIndexOf('.');
                if (dotIndex > 0)
                {
                    // Have exchange in symbol.
                    exchange = fullSymbol.Substring(dotIndex + 1);
                    symbol   = fullSymbol.Substring(0, dotIndex);
                }
                else
                {
                    exchange = "";
                    symbol = fullSymbol;
                }

                DateTime expireDate = DateTime.MinValue;
                try
                {
                    expireDate = mDateFormat.Parse(expireDateStr);
                }
                catch (FormatException e)
                {
                    throw new MamdaDataException (
                        String.Format("cannot parse expiration date: {0}", expireDateStr));
                }

                MamdaOptionContract.PutOrCall putCallchar = extractPutCall(msg,fullSymbol);
                contract = new MamdaOptionContract(
                    symbol,
                    exchange,
                    expireDate,
                    strikePrice,
                    putCallchar);

               MamdaOptionContract.ExerciseStyle exerciseStyleChar = extractExerciseStyle(msg,fullSymbol);
               contract.setExerciseStyle(exerciseStyleChar);

               
                if (msg.tryU32 (MamdaOptionFields.OPEN_INTEREST, ref openInterest))
                {
                    contract.setOpenInterest( (long)openInterest );
                }

                mChain.addContract(fullSymbol, contract);

                mLastActionContract = contract;
                mLastActionContractFieldState = MamdaFieldState.MODIFIED;
                mLastAction = MamdaOptionAction.Add;
                mLastActionFieldState = MamdaFieldState.MODIFIED;
                foreach (MamdaOptionChainHandler handler in mHandlers)
                {
                    handler.onOptionContractCreate(subscription, this, msg, contract, mChain);
                }
            }
            return contract;
        }
Ejemplo n.º 18
0
		private void handleTradeMsg(
			MamdaOptionContract  contract,
			MamdaSubscription    subscription,
			MamaMsg              msg,
			mamaMsgType          msgType)
		{
			MamdaTradeListener tradeListener = contract.getTradeListener();
			if (tradeListener != null)
			{
				tradeListener.onMsg(subscription, msg, msgType);
			}
		}	
Ejemplo n.º 19
0
 private MamdaOptionContract.ExerciseStyle extractExerciseStyle(
         MamaMsg            msg,
         string             fullSymbol)
     {
         MamdaOptionContract.ExerciseStyle exerciseStyle = MamdaOptionContract.ExerciseStyle.Unknown;
         int exerciseStyleInt = 0;   
        
         if (!msg.tryField (MamdaOptionFields.EXERCISE_STYLE, ref tmpfield_) )
         {
             Console.WriteLine("findContract:CANNOT find exercisestyle in msg:"+fullSymbol+exerciseStyle);                    
         }
         else
         {
             switch(tmpfield_.getType())
             {
                 case mamaFieldType.MAMA_FIELD_TYPE_I8:
                 case mamaFieldType.MAMA_FIELD_TYPE_U8:
                 case mamaFieldType.MAMA_FIELD_TYPE_I16:
                 case mamaFieldType.MAMA_FIELD_TYPE_U16:                
                     exerciseStyleInt =tmpfield_.getU16();
                 switch(exerciseStyleInt)
                 {
                     case 1:                                    
                         exerciseStyle = MamdaOptionContract.ExerciseStyle.American;
                         break;
                     case 2:
                         exerciseStyle = MamdaOptionContract.ExerciseStyle.European;
                         break;
                     case 3:                                    
                         exerciseStyle = MamdaOptionContract.ExerciseStyle.Capped;
                         break;
                     case 99:
                         exerciseStyle = MamdaOptionContract.ExerciseStyle.Unknown;
                         break;
                     default:
                         exerciseStyle = MamdaOptionContract.ExerciseStyle.Unknown;
                         Console.Write("Unhandled value for wExerciseStyle."+exerciseStyleInt);
                         break;
                     }
                     break;       
                     case mamaFieldType.MAMA_FIELD_TYPE_STRING:                      
                     string exerciseStyleStr = tmpfield_.getString();                             ;
                     switch (exerciseStyleStr[0])
                     {
                         case '1':
                         case 'A':                                        
                             exerciseStyle = MamdaOptionContract.ExerciseStyle.American;
                             break;
                         case '2':
                         case 'E':                                        
                             exerciseStyle = MamdaOptionContract.ExerciseStyle.European;
                             break;
                         case '3':
                         case 'C':                                       
                             exerciseStyle = MamdaOptionContract.ExerciseStyle.Capped;
                             break;
                         default:
                             exerciseStyle = MamdaOptionContract.ExerciseStyle.Unknown;
                             if ((exerciseStyleStr=="99") && (exerciseStyleStr=="Z"))
                             {
                                 Console.WriteLine("Unhandled value for wExerciseStyle."+exerciseStyleStr);
                             }
                             break;
                     }
                     break;
                 default:
                 exerciseStyle = MamdaOptionContract.ExerciseStyle.Unknown;
                 Console.WriteLine("Unhandled type for wExerciseStyle. Expected string or integer but returned:"+ tmpfield_.getType());
                 break;
             }
         }
         return  exerciseStyle;
     }
Ejemplo n.º 20
0
        /// <summary>
        /// Handler for option chain structural updates.
        /// </summary>
        /// <param name="subscription"></param>
        /// <param name="listener"></param>
        /// <param name="msg"></param>
        /// <param name="updateEvent"></param>
        /// <param name="chain"></param>
        public void onOptionSeriesUpdate(
			MamdaSubscription         subscription,
			MamdaOptionChainListener  listener,
			MamaMsg                   msg,
			MamdaOptionSeriesUpdate   updateEvent,
			MamdaOptionChain          chain)
        {
            resetRange();
        }
Ejemplo n.º 21
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);
			}
		}
Ejemplo n.º 22
0
 /// <summary>
 /// FieldIterator callback
 /// </summary>
 //////////////////////////////////////////////////////////////////////////////////////////////////
 public void onField(MamaMsg msg,
     MamaMsgField field,
     object closure)
 {
     MamaFieldDescriptor descriptor = field.getDescriptor();
     Console.WriteLine(descriptor.getName() + " : " + field.getAsString());
 }
 public void onQuoteUpdate(
     MamdaSubscription subscription,
     MamdaQuoteListener listener,
     MamaMsg msg,
     MamdaQuoteUpdate update,
     MamdaQuoteRecap recap)
 {
     myShortSaleCircuitBreaker = update.getShortSaleCircuitBreaker();
     Console.WriteLine("myShortSaleCircuitBreaker: " + myShortSaleCircuitBreaker);
 }
Ejemplo n.º 24
0
		public void onMsg(MamaSubscription subscription, MamaMsg msg)
		{
			Console.WriteLine("Received msg:");
			displayAllFields(msg);
		}
Ejemplo n.º 25
0
        public void onMsg(MamaSubscription subscription,
            MamaMsg msg)
        {

            if (msg.getType() == mamaMsgType.MAMA_MSG_TYPE_INITIAL)
            {
                stats.mInitialMsgCount++;
            }
            else
                stats.mOtherMsgCount++;

            if (mamaLogLevel > MamaLogLevel.MAMA_LOG_LEVEL_NORMAL)
            {
                Console.WriteLine("msg.getSymbol msg.getStatus");
            }
        }
Ejemplo n.º 26
0
		private void displayAllFields(MamaMsg msg)
		{
			MamaMsgIterator iterator = new MamaMsgIterator(null);
			MamaMsgField field;
			msg.begin(ref iterator);
			while ((field = iterator.getField()) != null)
			{
				displayField(field);
				iterator++;
			}
		}
Ejemplo n.º 27
0
            public void onTradeReport(
				MamdaSubscription   sub,
				MamdaTradeListener  listener,
				MamaMsg             msg,
				MamdaTradeReport    trade,
				MamdaTradeRecap     recap)
            {
            }
Ejemplo n.º 28
0
            public void onTradeGap(
				MamdaSubscription   sub,
				MamdaTradeListener  listener,
				MamaMsg             msg,
				MamdaTradeGap       gapEvent,
				MamdaTradeRecap     recap)
            {
            }
Ejemplo n.º 29
0
            public void onQuoteUpdate(
				MamdaSubscription   sub,
				MamdaQuoteListener  listener,
				MamaMsg             msg,
				MamdaQuoteUpdate    updateEvent,
				MamdaQuoteRecap     recap)
            {
            }
Ejemplo n.º 30
0
            public void onTradeCancelOrError(
				MamdaSubscription        sub,
				MamdaTradeListener       listener,
				MamaMsg                  msg,
				MamdaTradeCancelOrError  cancelEvent,
				MamdaTradeRecap          recap)
            {
            }