OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
Getting Started Sample

The Getting Started sample is the smallest complete handler application in this repository. It starts the CME MDP Premium Market Data Handler for one channel, enables direct market-by-price books, and prints direct book updates, making it the quickest path for understanding the basic startup and listener flow.

Arguments

Argument Description Default
ChannelId Positional CME market data channel identifier to process. Required

Running Examples

Process channel 310:

./GettingStarted 310

Process another channel:

./GettingStarted 311

Notes

This sample uses the built-in defaults from samples/Common/Defaults.h: license store ../../license, connectivity file ../Settings/config.xml, and no network interface override. On non-Windows builds, changing NETWORK_INTERFACE_FOR_FEEDS_A and NETWORK_INTERFACE_FOR_FEEDS_B before building overrides the feed interfaces. On Windows builds, this sample does not apply those macros.

Source Code

using namespace OnixS::CME::MDH;
class DirectBookListener : public SecurityListener
{
void onBookUpdate(Handler&, const Security&, const DirectBook& book) 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().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;
}