Example #1
0
        private static MamaDictionary buildDataDictionary(
			MamaTransport transport,
			MamaQueue defaultQueue,
			MamaSource dictionarySource)
        {
            bool[] gotDict = new bool[] { false };
            MamaDictionaryCallback dictionaryCallback = new DictionaryCallback(gotDict);
            lock (dictionaryCallback)
            {
                MamaSubscription subscription = new MamaSubscription ();

                MamaDictionary dictionary = new MamaDictionary();
                dictionary.create(
                    defaultQueue,
                    dictionaryCallback,
                    dictionarySource,
                    3,
                    10);

                Mama.start(myBridge);
                if (!gotDict[0])
                {
                    if (!Monitor.TryEnter(dictionaryCallback, 30000))
                    {
                        Console.Error.WriteLine("Timed out waiting for dictionary.");
                        Environment.Exit(0);
                    }
                    Monitor.Exit(dictionaryCallback);
                }
                return dictionary;
            }
        }
Example #2
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);
            }
        }
Example #3
0
        private void initializeMama()
        {
            mamaBridge = Mama.loadBridge(mamaMiddlewareName);

            Console.WriteLine(Mama.getVersion(mamaBridge));

            Mama.open();

            if (mamaHighWaterMark > 0 || mamaLowWaterMark > 0)
            {
                if (mamaHighWaterMark > 0)
                {
                    Mama.setDefaultQueueHighWatermark(mamaHighWaterMark);
                }

                if (mamaLowWaterMark > 0)
                {
                    try
                    {
                        Mama.setDefaultQueueLowWatermark(mamaLowWaterMark);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Could not set default queue low water mark MamaStatus: " + e);
                    }
                }
            }

            // create the transport
            mamaTransport = new MamaTransport();

            mamaTransport.setTransportCallback(this);

            // the default throttle rate is 500 msg/sec
            if (mamaThrottle != -1)
            {
                mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_DEFAULT, mamaThrottle);
            }

            // the default recap throttle rate is 250 msg/sec
            if (mamaRecapThrottle != -1)
            {
                mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_RECAP, mamaRecapThrottle);
            }

            mamaTransport.create(mamaTransportName, mamaBridge);

            // create default queue and, if required, queue group
            createQueues();

            mamaDictionarySource = new MamaSource();
            mamaDictionarySource.symbolNamespace = mamaDictionarySourceName;
            mamaDictionarySource.transport       = mamaTransport;

            // download dictionary
            mamaDictionary = new MamaDictionary();

            mamaDictionary.create(
                mamaDefaultQueue,
                this,
                mamaDictionarySource,
                3,
                10.0f);

            loadSymbolMap();

            Mama.start(mamaBridge);

            if (!dictionaryComplete)
            {
                throw new Exception("Can't create dictionary.");
            }
        }
        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);
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            // Parse the command line options to override defaults
            String middlewareName     = "qpid";
            String transportName      = "sub";
            String sourceName         = "OM";
            String symbolName         = null;
            String dictionaryFile     = "/opt/openmama/data/dictionaries/data.dict";
            bool   requiresDictionary = true;
            bool   requiresInitial    = true;

            if (args.Length == 0)
            {
                usageAndExit();
            }

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-B":
                    requiresDictionary = false;
                    break;

                case "-d":
                    dictionaryFile = args[++i];
                    break;

                case "-I":
                    requiresInitial = false;
                    break;

                case "-m":
                    middlewareName = args[++i];
                    break;

                case "-s":
                    symbolName = args[++i];
                    break;

                case "-S":
                    sourceName = args[++i];
                    break;

                case "-t":
                    transportName = args[++i];
                    break;

                case "-v":
                    Mama.enableLogging(MamaLogLevel.MAMA_LOG_LEVEL_FINEST);
                    break;

                default:
                    usageAndExit();
                    break;
                }
            }

            // Symbol name is mandatory here, so error if it's null
            if (symbolName == null)
            {
                usageAndExit();
            }

            // Load the requested OpenMAMA middleware bridge (and default payload too)
            MamaBridge bridge = Mama.loadBridge(middlewareName);

            // Time to initialize OpenMAMA's underlying bridges with an "open"
            Mama.open();

            // Get default event queue from the bridge for testing
            MamaQueue queue = Mama.getDefaultEventQueue(bridge);

            // Set up the required transport on the specified bridge
            MamaTransport transport = new MamaTransport();

            transport.create(transportName, bridge);

            // Set up the data dictionary
            MamaDictionary dictionary = null;

            if (requiresDictionary)
            {
                dictionary = new MamaDictionary();
                dictionary.create(dictionaryFile);
            }

            // Set up the OpenMAMA source (symbol namespace)
            MamaSource source = new MamaSource();

            source.symbolNamespace = sourceName;
            source.transport       = transport;

            // Set up the event handlers for OpenMAMA
            SubscriptionEventHandler eventHandler = new SubscriptionEventHandler();

            eventHandler.mDictionary = dictionary;

            // Set up the OpenMAMA Subscription (interest in a topic)
            MamaSubscription subscription = new MamaSubscription();

            subscription.setRequiresInitial(requiresInitial);
            subscription.create(queue, eventHandler, source, symbolName);

            // Kick off OpenMAMA now (blocking call, non-blocking call also available)
            Mama.start(bridge);

            // Clean up connection on termination
            Mama.close();
        }
        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);
            }
        }
Example #7
0
 public void onPublisherDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Publisher disconnected.");
 }
Example #8
0
 public void onConnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Connect");
 }
Example #9
0
 public void onReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Reconnected.");
 }
Example #10
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);
            }
        }
Example #11
0
        public static void Main(string[] args)
        {
            CommandLineProcessor options      = new CommandLineProcessor(args);
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            double intervalSecs = options.getTimerInterval();

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

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

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                mySource = new MamaSource();

                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // We might as well also enforce strict checking of order book updates
                MamdaOrderBook.setStrictChecking(true);

                /*Get the Data Dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport       = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                if (intervalSecs == 0)
                {
                    intervalSecs = 5;
                }

                foreach (string symbol in options.getSymbolList())
                {
                    BookSelfTest          aSelfTest    = new BookSelfTest();
                    MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker(
                        transport,
                        defaultQueue,
                        aSelfTest,
                        options.getSource(),
                        symbol,
                        intervalSecs);
                    obookCheckers.Add(aBookChecker);
                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Example #12
0
        public static void Main(string[] args)
        {
            try
            {
                options = new CommandLineProcessor(args);

                //Getting the log File name
                myLogFileName = options.getLogFileName();

                if (myLogFileName != null)
                {
                    myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate);
                    myOut = new StreamWriter(myOutFile);
                    myOut.WriteLine("Date/Time"+ "," + "ChurnStats" +","
                        + "UpdateStats" + "," + "PeakMsgCount" + ","
                        + "RecapStats" + "," + "BookGapStats" + ","
                        +"freeMemory" +"," +"Memory Used");
                }
                else
                {
                    myOut = Console.Out;
                }

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

                transport = new MamaTransport();
                transport.create(options.getTransport(), bridge);

                defaultQueue = Mama.getDefaultEventQueue(bridge);

                //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())
                {
                    subscribeToBooks(symbol);
                }

                myChurnRate = options.getChurnRate();

                Thread.Sleep(10000);

                //Getting the TimerInterval from the cmd prompt
                myChurnInterval = options.getTimerInterval();

                //Churn Timer
                if (myChurnRate > 0)
                {
                    myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval);
                }

                //Stats Timer
                myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0);

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(bridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();

                if (myOutFile != null)
                {
                    myOut.Close();
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                Environment.Exit(1);
            }
        }
Example #13
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)
        {
            try
            {
                options = new CommandLineProcessor(args);

                //Getting the log File name
                myLogFileName = options.getLogFileName();

                if (myLogFileName != null)
                {
                    myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate);
                    myOut     = new StreamWriter(myOutFile);
                    myOut.WriteLine("Date/Time" + "," + "ChurnStats" + ","
                                    + "UpdateStats" + "," + "PeakMsgCount" + ","
                                    + "RecapStats" + "," + "BookGapStats" + ","
                                    + "freeMemory" + "," + "Memory Used");
                }
                else
                {
                    myOut = Console.Out;
                }

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

                transport = new MamaTransport();
                transport.create(options.getTransport(), bridge);

                defaultQueue = Mama.getDefaultEventQueue(bridge);

                //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())
                {
                    subscribeToBooks(symbol);
                }

                myChurnRate = options.getChurnRate();

                Thread.Sleep(10000);

                //Getting the TimerInterval from the cmd prompt
                myChurnInterval = options.getTimerInterval();

                //Churn Timer
                if (myChurnRate > 0)
                {
                    myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval);
                }

                //Stats Timer
                myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0);

                Console.WriteLine("Hit Enter or Ctrl-C to exit.");
                Mama.start(bridge);
                GC.KeepAlive(dictionary);
                Console.ReadLine();

                if (myOutFile != null)
                {
                    myOut.Close();
                }
            }
            catch (Exception e)
            {
                Console.Error.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);
            }
        }
Example #16
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);
            }
        }
Example #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);
            }
        }
Example #18
0
 public void onQuality(MamaTransport transport)
 {
     Console.WriteLine("Transport Quality.");
 }
        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);
            }
        }
Example #20
0
 public void onAcceptReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Accept Reconnect.");
 }
Example #21
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);
            }
        }
Example #22
0
 public void onNamingServiceDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Naming Service Disconnected.");
 }
        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);
            }
        }
Example #24
0
        public static void Main(string[] args)
        {
            CommandLineProcessor options      = new CommandLineProcessor(args);
            MamaTransport        transport    = null;
            MamaQueue            defaultQueue = null;
            MamaDictionary       dictionary   = null;
            double               intervalSecs = options.getTimerInterval();
            if (options.hasLogLevel())
            {
                myLogLevel = options.getLogLevel();
                Mama.enableLogging(myLogLevel);
            }

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

                transport = new MamaTransport();
                transport.create(options.getTransport(), myBridge);
                mySource = new MamaSource();

                defaultQueue = Mama.getDefaultEventQueue(myBridge);

                // We might as well also enforce strict checking of order book updates
                MamdaOrderBook.setStrictChecking(true);

                /*Get the Data Dictionary*/
                MamaSource dictionarySource = new MamaSource();
                dictionarySource.symbolNamespace = "WOMBAT";
                dictionarySource.transport = transport;
                dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource);
                MamdaOrderBookFields.setDictionary(dictionary, null);

                if (intervalSecs == 0)
                {
                    intervalSecs = 5;
                }

                foreach (string symbol in options.getSymbolList())
                {
                    BookSelfTest aSelfTest             = new BookSelfTest ();
                    MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker(
                        transport,
                        defaultQueue,
                        aSelfTest,
                        options.getSource(),
                        symbol,
                        intervalSecs);
                    obookCheckers.Add(aBookChecker);

                }

                Mama.start(myBridge);
                GC.KeepAlive(dictionary);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Environment.Exit(1);
            }
        }
Example #25
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);
            }

            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);
                }
        }