Пример #1
0
        public static void Main(string[] args)
        {
            MamaTransport transport = null;
            MamaQueue defaultQueue = null;
            MamaDictionary dictionary = null;
            ListenerCallback callback = new ListenerCallback();
            CommandLineProcessor options = new CommandLineProcessor(args);

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open ();
                if (options.hasLogLevel())
                {
                    Mama.enableLogging (options.getLogLevel());
                }

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription ();

                    aSubscription.addMsgListener(callback);
                    aSubscription.addStaleListener(callback);
                    aSubscription.addErrorListener(callback);

                    if (options.getSnapshot())
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);

                    aSubscription.create(transport,
                                        defaultQueue,
                                        options.getSource(),
                                        symbol,
                                        null);
                    mamdaSubscriptions.Add(aSubscription);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #2
0
            public void onTradeReport(
                MamdaSubscription sub,
                MamdaTradeListener listener,
                MamaMsg msg,
                MamdaTradeReport trade,
                MamdaTradeRecap recap)
            {
                Console.WriteLine("wSettlePrice: " + recap.getSettlePrice());
                Console.WriteLine("wSettleDate: " + recap.getSettleDate());

                Console.WriteLine(
                    "Trade ({0}:{1}): {2} @ {3} (seq#: {4}; time: {5}; acttime: {6}; qual: {7})",
                    sub.getSymbol(),
                    recap.getTradeCount(),
                    trade.getTradeVolume(),
                    trade.getTradePrice(),
                    trade.getEventSeqNum(),
                    trade.getEventTime(),
                    trade.getActivityTime(),
                    trade.getTradeQual());
            }
Пример #3
0
            public void onBookRecap(
                MamdaSubscription sub,
                MamdaOrderBookListener listener,
                MamaMsg msg,
                MamdaOrderBookDelta bookDelta,
                MamdaOrderBookRecap bookRecap)
            {
                if (myQuietModeLevel < 2)
                {
                    Console.WriteLine("RECAP!!!  (seq# {0}) ", msg.getSeqNum());
                }

                if (myCacheFullBooks)
                {
                    prettyPrint(bookRecap.getFullOrderBook());
                }
                else
                {
                    prettyPrint(bookDelta.getDeltaOrderBook());
                }
            }
Пример #4
0
        private static void subscribeToBooks(string symbol)
        {
            MamdaSubscription      aSubscription = new MamdaSubscription();
            MamdaOrderBookListener aBookListener = new MamdaOrderBookListener();
            ListenerCallback       callback      = new ListenerCallback();

            aBookListener.addHandler(callback);
            aSubscription.addMsgListener(aBookListener);
            aSubscription.addStaleListener(callback);
            aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);

            aSubscription.create(
                transport,
                defaultQueue,
                options.getSource(),
                symbol,
                null);

            //Add the Mamda Subscription to the ArrayList
            subscriptionList.Add(aSubscription);
        }
        public void SetUp()
        {
            try
            {
                MamaBridge mBridge = Mama.loadBridge("lbm");
                Mama.open();

                MamaDictionary mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaSecurityStatusFields.reset();
                MamdaSecurityStatusFields.setDictionary(mDictionary, null);

                mSubscription = new MamdaSubscription();
            }
            catch (Exception ex)
            {
                throw new MamdaDataException(ex.Message, ex);
            }
        }
Пример #6
0
            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);
                }
            }
Пример #7
0
        public void onQuoteUpdate(
            MamdaSubscription sub,
            MamdaQuoteListener listener,
            MamaMsg msg,
            MamdaQuoteUpdate quote,
            MamdaQuoteRecap recap)
        {
            Console.WriteLine(
                "Underlying quote: " +
                quote.getBidSize() + "x" + quote.getBidPrice() + "   " +
                quote.getAskPrice() + "x" + quote.getAskSize() + "   " +
                "mid=" + recap.getQuoteMidPrice());

            if (myPrintStrikes)
            {
                double lowStrike  = -1.0;
                double highStrike = -1.0;

                Console.WriteLine(
                    "  strikes within 15%: " + lowStrike + " " + highStrike);
            }
        }
 public void onBookAtomicEndBook(
     MamdaSubscription subscription,
     MamdaBookAtomicListener listener)
 {
     if (myQuietModeLevel < 2)
     {
         if (listener.getPriceLevelNumLevels() == 0)
         {
             Console.WriteLine();
             Console.WriteLine("END BOOK - " + subscription.getSymbol());
             Console.WriteLine(" - empty book message !!!");
             Console.WriteLine();
             Console.WriteLine();
         }
         else
         {
             Console.WriteLine();
             Console.WriteLine("END BOOK - " + subscription.getSymbol());
             Console.WriteLine();
             Console.WriteLine();
         }
     }
 }
Пример #9
0
        public void SetUp()
        {
            try
            {
                MamaBridge mBridge = Mama.loadBridge("lbm");
                Mama.open();

                MamaDictionary mDictionary = new MamaDictionary();
                mDictionary.create("dictionary.txt");

                MamdaCommonFields.setDictionary(mDictionary, null);
                MamdaTradeFields.reset();
                MamdaTradeFields.setDictionary(mDictionary, null);

                mSubscription  = new MamdaSubscription();
                mTradeListener = new MamdaTradeListener();
                mSubscription.addMsgListener(mTradeListener);
                recap = new MamdaConcreteTradeRecap();
            }
            catch (Exception ex)
            {
                throw new MamdaDataException(ex.Message, ex);
            }
        }
Пример #10
0
            public void onOptionSeriesUpdate(
				MamdaSubscription         subscription,
				MamdaOptionChainListener  listener,
				MamaMsg                   msg,
				MamdaOptionSeriesUpdate   update,
				MamdaOptionChain          chain)
            {
                printChain(chain);
            }
Пример #11
0
            public void onBookGap(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookGap        gapEvent,
				MamdaOrderBookRecap      fullBook)
            {
                ++myBookGapStats;
            }
Пример #12
0
            public void onError(
				MamdaSubscription   subscription,
				MamdaErrorSeverity  severity,
				MamdaErrorCode      errorCode,
				string              errorStr)
            {
                Console.WriteLine("Error (" + subscription.getSymbol() + ")");
            }
Пример #13
0
            public void onOptionChainRecap(
				MamdaSubscription         subscription,
				MamdaOptionChainListener  listener,
				MamaMsg                   msg,
				MamdaOptionChain          chain)
            {
                myGotRecap = true;
                printChain(chain);
            }
Пример #14
0
            public void onAuctionUpdate(
				MamdaSubscription   subscription,
				MamdaAuctionListener  listener,
				MamaMsg             msg,
				MamdaAuctionUpdate    update,
				MamdaAuctionRecap     recap)
            {
                Console.WriteLine("Auction Update ({0}, Uncross Price {1}({2}), Uncross Vol {3}({4}), Ind {5}({6})",
                                  subscription.getSymbol(),
                                  update.getUncrossPrice(),
                                  update.getUncrossPriceFieldState(),
                                  update.getUncrossVolume(),
                                  update.getUncrossVolumeFieldState(),
                                  update.getUncrossPriceInd(),
                                  update.getUncrossPriceIndFieldState());
            }
Пример #15
0
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);
            myQuietModeLevel				  = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                /*Get the data dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaAuctionFields.setDictionary(dictionary, null);

                mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count];
                int i=0;
                foreach (string symbol in options.getSymbolList())
                {
                    mamdaSubscriptions[i] =  new MamdaSubscription();
                    MamdaAuctionListener aAuctionListener = new MamdaAuctionListener();
                    AuctionTicker        aTicker        = new AuctionTicker();

                    aAuctionListener.addHandler(aTicker);
                    mamdaSubscriptions[i].addMsgListener(aAuctionListener);
                    mamdaSubscriptions[i].addStaleListener(aTicker);
                    mamdaSubscriptions[i].addErrorListener(aTicker);

                    mamdaSubscriptions[i].create(transport,
                                        defaultQueue,
                                        options.getSource (),
                                        symbol,
                                        null);
                    i++;
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #16
0
            public void onError(
				MamdaSubscription   subscription,
				MamdaErrorSeverity	severity,
				MamdaErrorCode		errorCode,
				String              errorMessage)
            {
                if (myQuiteModeLevel < 2)
                {
                    Console.WriteLine ("Error (" + subscription.getSymbol() + "): "
                        + errorMessage);
                }
            }
Пример #17
0
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();


            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            myCacheFullBooks = options.cacheFullBooks();
            myPrintEntries   = options.getPrintEntries();
            mySnapshot       = options.getSnapshot();
            myPrecision      = options.getPrecision();
            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription      aSubscription = new MamdaSubscription();
                    MamdaOrderBookListener aBookListener;
                    if (myCacheFullBooks)
                    {
                        aBookListener = new MamdaOrderBookListener();
                    }
                    else
                    {
                        aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook());
                    }

                    BookTicker aTicker = new BookTicker();

                    aBookListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);

                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);
                    if (mySnapshot)
                    {
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
                    }
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #18
0
            public void onBookGap(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookGap        gapEvent,
				MamdaOrderBookRecap      fullBook)
            {
                Console.WriteLine (
                    "Received book gap " + sub.getSymbol ()
                        + " Start: " + gapEvent.getBeginGapSeqNum()
                        + " End: "   + gapEvent.getEndGapSeqNum());
            }
Пример #19
0
            public void onBookRecap(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookDelta      bookDelta,
				MamdaOrderBookRecap      bookRecap)
            {
                if (myQuietModeLevel < 2)
                {
                    Console.WriteLine ("RECAP!!!  (seq# {0}) ", msg.getSeqNum());
                }

                if (myCacheFullBooks)
                {
                    prettyPrint(bookRecap.getFullOrderBook());
                }
                else
                {
                    prettyPrint(bookDelta.getDeltaOrderBook());
                }
            }
Пример #20
0
            public void onBookClear(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookDelta      bookDelta,
				MamdaOrderBookRecap      fullBook)
            {
                if (myQuietModeLevel < 2)
                {
                    Console.WriteLine ("CLEAR!!!  (seq# {0}) ", msg.getSeqNum());
                }
            }
Пример #21
0
        public static void Main(string[] args)
        {
            MamaTransport        baseTransport     = null;
            MamaTransport        optionTransport   = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options           = new CommandLineProcessor(args);


            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                // Initialize transports.  We're assuming that options and
                // underlyings might be on different transports.  Note:
                // some companies might use multiple transports for
                // underlyings (e.g., CTA and NASDAQ), which case it would
                // be necessary to create three transports here and be
                // sure to pass the correct transport later.
                baseTransport = new MamaTransport();
                baseTransport.create(options.getTransport(), myBridge);
                optionTransport = baseTransport;
                defaultQueue    = Mama.getDefaultEventQueue(myBridge);

                // Fetch and initialize the data dictionary
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = baseTransport;
                }
                dictionarySource.transport = dictTransport;
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaFundamentalFields.setDictionary(dictionary, null);
                MamdaOptionFields.setDictionary(dictionary, null);

                // Create listeners for each chain.  Two subscriptions are
                // necessary.
                foreach (string symbol in options.getSymbolList())
                {
                    // Create chain and listener objects.
                    MamdaTradeListener aBaseTradeListener = new MamdaTradeListener();
                    MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener();
                    MamdaOptionChain   anOptionChain      = new MamdaOptionChain(symbol);
                    anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener);
                    anOptionChain.setUnderlyingTradeListener(aBaseTradeListener);
                    MamdaOptionChainListener anOptionListener =
                        new MamdaOptionChainListener(anOptionChain);

                    // Create our handlers (the UnderlyingTicker and
                    // OptionChainDisplay could be a single class).
                    UnderlyingTicker aBaseTicker =
                        new UnderlyingTicker(anOptionChain, true);
                    OptionChainDisplay aDisplay =
                        new OptionChainDisplay(anOptionChain);

                    // Create subscriptions for underlying and option chain:
                    MamdaSubscription aBaseSubscription    = new MamdaSubscription();
                    MamdaSubscription anOptionSubscription =
                        new MamdaSubscription();

                    // Register for underlying quote and trade events.
                    aBaseTradeListener.addHandler(aBaseTicker);
                    aBaseQuoteListener.addHandler(aBaseTicker);
                    aBaseSubscription.addMsgListener(aBaseTradeListener);
                    aBaseSubscription.addMsgListener(aBaseQuoteListener);

                    aBaseSubscription.create(
                        baseTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    mamdaSubscriptions.Add(aBaseSubscription);
                    // Register for underlying option events.
                    anOptionListener.addHandler(aDisplay);

                    // We set the timeout to 1 for this example because we
                    // currently use the timeout feature to determine when
                    // to say that we have received all of the initials.
                    // There will be a separate time interval for this in
                    // the future.
                    anOptionSubscription.setTimeout(1);
                    anOptionSubscription.addMsgListener(anOptionListener);
                    anOptionSubscription.addStaleListener(aDisplay);
                    anOptionSubscription.addErrorListener(aDisplay);
                    anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    anOptionSubscription.create(
                        optionTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    optionSubscriptions.Add(anOptionSubscription);
                }

                //Start dispatching on the default event queue
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);

                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #22
0
 public void onStale(
     MamdaSubscription subscription,
     mamaQuality quality)
 {
     Console.WriteLine("Stale (" + subscription.getSymbol() + ")");
 }
Пример #23
0
            public void onBookClear(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookDelta      bookDelta,
				MamdaOrderBookRecap      fullBook)
            {
                Console.WriteLine("BookClear");
            }
Пример #24
0
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor (args);
            myQuietModeLevel = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            myCacheFullBooks = options.cacheFullBooks();
            myPrintEntries = options.getPrintEntries();
            mySnapshot = options.getSnapshot();
            myPrecision = options.getPrecision();
            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource ();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaOrderBookFields.setDictionary (dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();
                    MamdaOrderBookListener aBookListener;
                    if (myCacheFullBooks)
                    {
                        aBookListener = new MamdaOrderBookListener();
                    }
                    else
                    {
                        aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook());
                    }

                    BookTicker aTicker = new BookTicker();

                    aBookListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);

                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);
                    if (mySnapshot)
                    {
                        aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
                    }
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                /*Get the data dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaAuctionFields.setDictionary(dictionary, null);

                mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count];
                int i = 0;
                foreach (string symbol in options.getSymbolList())
                {
                    mamdaSubscriptions[i] = new MamdaSubscription();
                    MamdaAuctionListener aAuctionListener = new MamdaAuctionListener();
                    AuctionTicker        aTicker          = new AuctionTicker();

                    aAuctionListener.addHandler(aTicker);
                    mamdaSubscriptions[i].addMsgListener(aAuctionListener);
                    mamdaSubscriptions[i].addStaleListener(aTicker);
                    mamdaSubscriptions[i].addErrorListener(aTicker);

                    mamdaSubscriptions[i].create(transport,
                                                 defaultQueue,
                                                 options.getSource(),
                                                 symbol,
                                                 null);
                    i++;
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);

            myQuietModeLevel = options.getQuietModeLevel();


            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

            try
            {
                //Initialize MAMA API
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                myMamaSource = new MamaSource();
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaCommonFields.setDictionary(dictionary, null);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                myQueueGroup = new MamaQueueGroup(myBridge, options.getNumThreads());

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();

                    MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener();
                    AtomicBookTicker        aTicker       = new AtomicBookTicker();

                    aBookListener.addBookHandler(aTicker);
                    aBookListener.addLevelHandler(aTicker);

                    if (options.getPrintEntries())
                    {   // Entries
                        aBookListener.addLevelEntryHandler(aTicker);
                    }

                    aSubscription.addMsgListener(aBookListener);
                    aSubscription.addStaleListener(aTicker);
                    aSubscription.addErrorListener(aTicker);
                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);

                    aSubscription.create(transport,
                                         myQueueGroup.getNextQueue(),
                                         options.getSource(),
                                         symbol,
                                         null);

                    mamdaSubscriptions.Add(aSubscription);
                }

                //Start dispatching on the default MAMA event queue
                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
        public static void Main(string[] args)
        {
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            CommandLineProcessor options      = new CommandLineProcessor(args);
            double throttleRate = options.getThrottleRate();


            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            if ((throttleRate > 100.0) || (throttleRate <= 0.0))
            {
                throttleRate = 100.0;
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);
                //Get the Data dictionary.....
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);

                //Initialise the dictionary and fields
                MamdaCommonFields.setDictionary(dictionary, null);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription aSubscription = new MamdaSubscription();
                    aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    aSubscription.setTimeout(60.0);
                    aSubscription.create(
                        transport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);

                    /* For each subscription a MamdaMultiSecurityicipantManager is
                     * added as the message listener. The callbacks on the
                     * MamdaMultiSecurityHandler will be invokes as new group members
                     * become available.*/
                    MamdaMultiSecurityManager multiSecurityManager =
                        new MamdaMultiSecurityManager(symbol);
                    multiSecurityManager.addHandler(new MultiSecurityHandler());

                    aSubscription.addMsgListener(multiSecurityManager);

                    aSubscription.activate();

                    mamdaSubscriptions.Add(aSubscription);
                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #28
0
            public void onQuoteClosing(
				MamdaSubscription   sub,
				MamdaQuoteListener  listener,
				MamaMsg             msg,
				MamdaQuoteClosing   quoteClosing,
				MamdaQuoteRecap     recap)
            {
            }
Пример #29
0
            public void onStale(
				MamdaSubscription   subscription,
				mamaQuality         quality)
            {
                Console.WriteLine("Stale ({0} - {1})", subscription.getSymbol(), quality);
            }
Пример #30
0
            public void onQuoteUpdate(
				MamdaSubscription   sub,
				MamdaQuoteListener  listener,
				MamaMsg             msg,
				MamdaQuoteUpdate    update,
				MamdaQuoteRecap     recap)
            {
                // Do something with a specific quote.
                myDisplay.printlnContract(myContract);
            }
Пример #31
0
 public void onStale(
     MamdaSubscription subscription,
     mamaQuality quality)
 {
     prettyPrint("Stale ({0} - {1})", subscription.getSymbol(), quality);
 }
Пример #32
0
            public void onTradeClosing(
				MamdaSubscription        sub,
				MamdaTradeListener       listener,
				MamaMsg                  msg,
				MamdaTradeClosing        tradeClosing,
				MamdaTradeRecap          recap)
            {
            }
Пример #33
0
            public void onOptionChainGap(
				MamdaSubscription         subscription,
				MamdaOptionChainListener  listener,
				MamaMsg                   msg,
				MamdaOptionChain          chain)
            {
                printChain(chain);
            }
Пример #34
0
            public void onTradeGap(
				MamdaSubscription   sub,
				MamdaTradeListener  listener,
				MamaMsg             msg,
				MamdaTradeGap       gap,
				MamdaTradeRecap     recap)
            {
            }
Пример #35
0
            public void onOptionContractCreate(
				MamdaSubscription         subscription,
				MamdaOptionChainListener  listener,
				MamaMsg                   msg,
				MamdaOptionContract       contract,
				MamdaOptionChain          chain)
            {
                // (Optional: create a trade/quote handler for the
                // individual option contract.)
                OptionContractTicker aTicker =
                    new OptionContractTicker(contract, chain, this);
                contract.addQuoteHandler(aTicker);
                contract.addTradeHandler(aTicker);
            }
Пример #36
0
            public void onTradeReport(
				MamdaSubscription   sub,
				MamdaTradeListener  listener,
				MamaMsg             msg,
				MamdaTradeReport    trade,
				MamdaTradeRecap     recap)
            {
                // Do something with a specific trade report.
                myDisplay.printlnContract(myContract);
            }
Пример #37
0
            public void onStale(
				MamdaSubscription   subscription,
				mamaQuality         quality)
            {
                Console.WriteLine("Stale (" + subscription.getSymbol() + ")");
            }
Пример #38
0
            public void onBookRecap(
				MamdaSubscription        sub,
				MamdaOrderBookListener   listener,
				MamaMsg                  msg,
				MamdaOrderBookDelta      bookDelta,
				MamdaOrderBookRecap      bookRecap)
            {
                ++myRecapStats;
            }
Пример #39
0
            public void onQuoteGap(
				MamdaSubscription   sub,
				MamdaQuoteListener  listener,
				MamaMsg             msg,
				MamdaQuoteGap       gap,
				MamdaQuoteRecap     recap)
            {
            }
 public void onStale(
     MamdaSubscription subscription,
     mamaQuality quality)
 {
 }
Пример #41
0
            public void onTradeCancelOrError(
				MamdaSubscription        sub,
				MamdaTradeListener       listener,
				MamaMsg                  msg,
				MamdaTradeCancelOrError  cancelOrError,
				MamdaTradeRecap          recap)
            {
            }
Пример #42
0
 public void onSecurityStatusUpdate(
     MamdaSubscription            subscription,
     MamdaSecurityStatusListener  listener,
     MamaMsg                      msg,
     MamdaSecurityStatusUpdate    update,
     MamdaSecurityStatusRecap     recap)
 {
     Console.WriteLine ("SecStatus update (" + subscription.getSymbol ()
      + "    Status:" + listener.getSecurityStatusStr ());
 }
Пример #43
0
            public void onTradeCorrection(
				MamdaSubscription        sub,
				MamdaTradeListener       listener,
				MamaMsg                  msg,
				MamdaTradeCorrection     tradeCorrection,
				MamdaTradeRecap          recap)
            {
            }
Пример #44
0
        public static void Main(string[] args)
        {
            MamaTransport        transport          = null;
            MamaTransport        dictTransport      = null;
            string               dictTransportName  = null;
            MamaQueue            defaultQueue       = null;
            MamaDictionary       dictionary         = null;
            CommandLineProcessor options            = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport = new MamaTransport();
                myMamaSource = new MamaSource ();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = transport;
                }
                dictionarySource.transport = dictTransport;

                /*Get the data dictionary*/
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);

                MamdaSecurityStatusFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription  aSubscription =  new MamdaSubscription();
                    MamdaSecurityStatusListener aSecListener = new MamdaSecurityStatusListener();
                    SecTicker        aTicker        = new SecTicker();

                    aSecListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aSecListener);

                    aSubscription.create(transport,
                                        defaultQueue,
                                        options.getSource (),
                                        symbol,
                                        null);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #45
0
            public void onTradeRecap(
				MamdaSubscription   sub,
				MamdaTradeListener  listener,
				MamaMsg             msg,
				MamdaTradeRecap     recap)
            {
                // Refresh the "display" of this contract.
                myDisplay.printlnContract(myContract);
            }
        public static void Main(string[] args)
        {
            MamaTransport        transport         = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options           = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                Mama.enableLogging(options.getLogLevel());
            }

            try
            {
                // Initialize MAMDA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();
                transport    = new MamaTransport();
                myMamaSource = new MamaSource();
                transport.create(options.getTransport(), myBridge);
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = transport;
                }
                dictionarySource.transport = dictTransport;

                /*Get the data dictionary*/
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);

                MamdaFundamentalFields.setDictionary(dictionary, null);

                foreach (string symbol in options.getSymbolList())
                {
                    MamdaSubscription        aSubscription = new MamdaSubscription();
                    MamdaFundamentalListener aSecListener  = new MamdaFundamentalListener();
                    FundTicker aTicker = new FundTicker();

                    aSecListener.addHandler(aTicker);
                    aSubscription.addMsgListener(aSecListener);

                    aSubscription.create(transport,
                                         defaultQueue,
                                         options.getSource(),
                                         symbol,
                                         null);
                }

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Пример #47
0
        public static void Main(string[] args)
        {
            MamaTransport        baseTransport     = null;
            MamaTransport        optionTransport   = null;
            MamaTransport        dictTransport     = null;
            string               dictTransportName = null;
            MamaQueue            defaultQueue      = null;
            MamaDictionary       dictionary        = null;
            CommandLineProcessor options = new CommandLineProcessor(args);

            if (options.hasLogLevel())
            {
                logLevel_ = options.getLogLevel();
                Mama.enableLogging(logLevel_);
            }

            try
            {
                // Initialize MAMA
                myBridge = new MamaBridge(options.getMiddleware());
                Mama.open();

                // Initialize transports.  We're assuming that options and
                // underlyings might be on different transports.  Note:
                // some companies might use multiple transports for
                // underlyings (e.g., CTA and NASDAQ), which case it would
                // be necessary to create three transports here and be
                // sure to pass the correct transport later.
                baseTransport = new MamaTransport();
                baseTransport.create(options.getTransport(), myBridge);
                optionTransport = baseTransport;
                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // Fetch and initialize the data dictionary
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = options.getDictSource();
                dictTransportName = options.getDictTransport();
                if (null != dictTransportName)
                {
                    dictTransport = new MamaTransport();
                    dictTransport.create(dictTransportName, myBridge);
                }
                else
                {
                    dictTransport = baseTransport;
                }
                dictionarySource.transport = dictTransport;
                dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource);
                MamdaQuoteFields.setDictionary(dictionary, null);
                MamdaTradeFields.setDictionary(dictionary, null);
                MamdaFundamentalFields.setDictionary(dictionary, null);
                MamdaOptionFields.setDictionary(dictionary, null);

                // Create listeners for each chain.  Two subscriptions are
                // necessary.
                foreach (string symbol in options.getSymbolList())
                {
                    // Create chain and listener objects.
                    MamdaTradeListener aBaseTradeListener = new MamdaTradeListener();
                    MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener();
                    MamdaOptionChain anOptionChain = new MamdaOptionChain(symbol);
                    anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener);
                    anOptionChain.setUnderlyingTradeListener(aBaseTradeListener);
                    MamdaOptionChainListener  anOptionListener =
                        new MamdaOptionChainListener(anOptionChain);

                    // Create our handlers (the UnderlyingTicker and
                    // OptionChainDisplay could be a single class).
                    UnderlyingTicker  aBaseTicker =
                        new UnderlyingTicker(anOptionChain, true);
                    OptionChainDisplay  aDisplay =
                        new OptionChainDisplay(anOptionChain);

                    // Create subscriptions for underlying and option chain:
                    MamdaSubscription  aBaseSubscription = new MamdaSubscription();
                    MamdaSubscription  anOptionSubscription =
                        new MamdaSubscription();

                    // Register for underlying quote and trade events.
                    aBaseTradeListener.addHandler(aBaseTicker);
                    aBaseQuoteListener.addHandler(aBaseTicker);
                    aBaseSubscription.addMsgListener(aBaseTradeListener);
                    aBaseSubscription.addMsgListener(aBaseQuoteListener);

                    aBaseSubscription.create(
                        baseTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    mamdaSubscriptions.Add(aBaseSubscription);
                    // Register for underlying option events.
                    anOptionListener.addHandler(aDisplay);

                    // We set the timeout to 1 for this example because we
                    // currently use the timeout feature to determine when
                    // to say that we have received all of the initials.
                    // There will be a separate time interval for this in
                    // the future.
                    anOptionSubscription.setTimeout(1);
                    anOptionSubscription.addMsgListener(anOptionListener);
                    anOptionSubscription.addStaleListener(aDisplay);
                    anOptionSubscription.addErrorListener(aDisplay);
                    anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP);
                    anOptionSubscription.create(
                        optionTransport,
                        defaultQueue,
                        options.getSource(),
                        symbol,
                        null);
                    optionSubscriptions.Add(anOptionSubscription);
                }

                //Start dispatching on the default event queue
                Mama.start(myBridge);
                GC.KeepAlive(dictionary);

                Console.WriteLine("Press ENTER or Ctrl-C to quit...");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
 public void onStale(
     MamdaSubscription subscription,
     mamaQuality quality)
 {
     Console.WriteLine("Stale ({0} - {1})", subscription.getSymbol(), quality);
 }