int main (int argc, const char **argv) { try { CommonCommandLineParser cmdLine (argc, argv); setvbuf (stdout, (char *) NULL, _IONBF, 0); // Initialise the MAMA API mamaBridge bridge = cmdLine.getBridge(); Mama::open (); const vector<const char*>& symbolList = cmdLine.getSymbolList (); double throttleRate = cmdLine.getThrottleRate (); int snapshotInterval = cmdLine.getOptInt ("snapshot"); int precision = cmdLine.getPrecision (); bool processEntries = cmdLine.getOptBool ('e'); bool strictChecking = !cmdLine.getOptBool ('C'); bool processMarketOrders = cmdLine.getOptBool ('k'); bool showDeltas = cmdLine.showDeltas (); const char* dictFile = cmdLine.getOptString("use_dict_file"); MamaSource* source = cmdLine.getSource (); MamaQueueGroup queues (cmdLine.getNumThreads(), bridge); DictRequester dictRequester (bridge); // We might as well enforce strict checking of order book updates // (at the expense of some performance). if (strictChecking) { cout << "MamdaOrderBook strict checking is on" << endl; MamdaOrderBook::setStrictChecking (true); } else { cout << "MamdaOrderBook strict checking is off" << endl; MamdaOrderBook::setStrictChecking (false); } // Get and initialize the dictionary if(dictFile) { MamaDictionary* dict =new MamaDictionary; dict->populateFromFile(dictFile); MamdaCommonFields::setDictionary (*dict); MamdaOrderBookFields::setDictionary (*dict); } else { dictRequester.requestDictionary (cmdLine.getDictSource()); MamdaCommonFields::setDictionary (*dictRequester.getDictionary()); MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary ()); } const char* symbolMapFile = cmdLine.getSymbolMapFile (); if (symbolMapFile) { MamaSymbolMapFile* aMap = new MamaSymbolMapFile; if (MAMA_STATUS_OK == aMap->load (symbolMapFile)) { source->getTransport()->setSymbolMap (aMap); } } for (vector<const char*>::const_iterator i = symbolList.begin (); i != symbolList.end (); ++i) { const char* symbol = *i; MamdaSubscription* aSubscription = new MamdaSubscription; MamdaOrderBookListener* aBookListener = new MamdaOrderBookListener; aSubscription->addMsgListener (aBookListener); aBookListener->setProcessMarketOrders (processMarketOrders); aBookListener->setProcessEntries (processEntries); BookTicker* aTicker = new BookTicker; aBookListener->addHandler (aTicker); aSubscription->addQualityListener (aTicker); aSubscription->addErrorListener (aTicker); aTicker->setShowEntries (processEntries); aTicker->setShowMarketOrders (processMarketOrders); aTicker->setShowDeltas (showDeltas); aTicker->setPrecision (precision); aSubscription->setType (MAMA_SUBSC_TYPE_BOOK); aSubscription->setMdDataType (MAMA_MD_DATA_TYPE_ORDER_BOOK); aSubscription->create (queues.getNextQueue(), source, symbol); } Mama::start (bridge); } catch (MamaStatus &e) { // This exception can be thrown from Mama.open () // Mama::createTransport (transportName) and from // MamdaSubscription constructor when entitlements is enabled. cerr << "MamaStatus exception in main (): " << e.toString () << endl; exit (1); } catch (std::exception &ex) { cerr << "Exception in main (): " << ex.what () << endl; exit (1); } catch (...) { cerr << "Unknown Exception in main ()." << endl; exit (1); } exit (1); }
int main (int argc, const char **argv) { setbuf (stdout, NULL); try { BookPublisher* mBookPublisher = new BookPublisher; CommonCommandLineParser cmdLine (argc, argv); // Initialise the MAMA API mamaBridge bridge = cmdLine.getBridge(); Mama::open (); const char* symbol = cmdLine.getOptString("s"); const char* partId = cmdLine.getOptString("p"); const char* pubSource = cmdLine.getOptString("SP"); const char* dictFile = cmdLine.getOptString("use_dict_file"); MamaSource* source = cmdLine.getSource(); mBookPublisher->mPublishRecaps = cmdLine.getPublishRecaps(); MamaQueueGroup queues (cmdLine.getNumThreads(), bridge); mBookPublisher->setQueueGroup (&queues);; mBookPublisher->setProcessEntries (cmdLine.getOptBool ('e')); mBookPublisher->createPublisherTransport (bridge); mBookPublisher->createPublisherManager (pubSource, bridge); // Get and initialize the dictionary if (dictFile) { MamaDictionary* dict =new MamaDictionary; dict->populateFromFile(dictFile); MamdaCommonFields::setDictionary (*dict); MamdaOrderBookFields::setDictionary (*dict); } else { DictRequester dictRequester (bridge); dictRequester.requestDictionary (cmdLine.getDictSource()); MamdaCommonFields::setDictionary (*dictRequester.getDictionary()); MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary()); } //create publisher and also set up MamaTimer to process order and publish changes mBookPublisher->createTimer (symbol, bridge); mBookPublisher->createMessage (); //set up new Book and enable order book publishing mBookPublisher->createBook (symbol, partId); Mama::start (bridge); } catch (MamaStatus &e) { // This exception can be thrown from Mama.open () // Mama::createTransport (transportName) and from // MamdaSubscription constructor when entitlements is enabled. cerr << "MamaStatus exception in main (): " << e.toString () << endl; exit (1); } catch (std::exception &ex) { cerr << "Exception in main (): " << ex.what () << endl; exit (1); } catch (...) { cerr << "Unknown Exception in main ()." << endl; exit (1); } exit (1); }