OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
Getting Started Sample

This sample shows the simplest way to receive and process CME MDP 3.0 market data.

Source code

using namespace OnixS::CME::MDH;
class DirectBookListener : public SecurityListener
{
void onBookUpdate(Handler&, const Security&, const DirectBook& book) ONIXS_CMEMDH_OVERRIDE
{
std::cout << "DirectBook updated:" << std::endl << toStr(book) << std::endl;
}
};
int main(int argc, char** argv)
{
std::cout
<< "CME MDP Premium GettingStarted Sample, v" << toStr(Version::current())
<< "." << std::endl << std::endl;
if (argc < 2)
{
std::cerr << "usage: [ChannelId]" << std::endl;
return 1;
}
const ChannelId channelId = atoi(argv[1]);
try
{
Handler handler;
handler.settings().channel(channelId);
handler.settings().licenseSettings().licenseStore(LICENSE_STORE_FOLDER);
handler.settings().connectivityConfigurationFile(CONNECTIVITY_CONFIGURATION_FILE);
#if !defined(_WIN32)
checkNetworkSettings(NETWORK_INTERFACE_FOR_FEEDS_A, NETWORK_INTERFACE_FOR_FEEDS_B);
handler.settings().feeds()
.feedANetworkInterfaces(NETWORK_INTERFACE_FOR_FEEDS_A)
.feedBNetworkInterfaces(NETWORK_INTERFACE_FOR_FEEDS_B);
#endif
handler.settings().bookManagement().directBooks().maintain(true);
handler.settings().logging().debug().traceMessages(MessageTracing::SbeFormat);
handler.settings().logging().debug().traceBooks(true);
DirectBookListener listener;
handler.settings().listeners().security(&listener);
std::cout << "Starting processing market data.." << std::endl << "Press Ctrl+C to stop and exit." << std::endl;
handler.start();
while (!InterruptDetector::instance().detected())
CurrentThread::sleep(1);
std::cout << "Stopping processing market data.." << std::endl;
handler.stop();
}
catch (const std::exception& ex)
{
std::cerr << std::endl << "ERROR: " << ex.what() << std::endl;
return 1;
}
return 0;
}