OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Track Top Of The Book Only Sample

Enables the trackTopOfTheBookOnly setting so the Handler reports order book updates only when the best bid or ask changes. This reduces processing overhead when only the top of the book is of interest.

Source code

#include "../Common/Defaults.h"
#include "../Common/MarketDataEventTracer.h"
#include "../Common/ServiceEventTracer.h"
#include "../Common/Utils.h"
#include <cstdlib>
#ifndef _WIN32
# include <pthread.h>
# include <csignal>
# include <cstdio>
# include <vector>
#endif
int main(int /*argc*/, char** /*argv*/)
{
try
{
introduceMyself("Track Top Of The Book Only");
FeedEngineSettings feedEngineSettings;
FeedEngine feedEngine(feedEngineSettings);
HandlerSettings handlerSettings;
// For most of Linux operating systems it would be
// better to define following parameter to be able to
// successfully receive market data from multicast feeds.
handlerSettings.networkInterface = NETWORK_INTERFACE;
// Let's activate logging to get data for support.
handlerSettings.logLevel = LogLevels::Debug;
handlerSettings.logDirectory = LOG_DIRECTORY;
handlerSettings.logFileNamePrefix = LOG_FILE_NAME_PREFIX;
// By default, license is stored in lib folder of the distribute
// package. Instead of copying, let's use original file.
handlerSettings.licenseDirectory = LICENSE_DIRECTORY;
// Allow only order book updates if the top of the book changes.
handlerSettings.trackTopOfTheBookOnly = true;
// Primary settings - connectivity configuration.
handlerSettings.connectivityConfiguration = AP1_C10Y_FILE;
// Constructs handler with custom license root and enabled logging.
// It will be used to download the product definitions for all market
// subscriptions.
Handler handler(handlerSettings);
// Binds the handler to the feed engine.
handler.bindFeedEngine(feedEngine);
// Traces all service events coming from handlers.
ServiceEventTracer serviceEventTracer;
serviceEventTracer.attachTo(handler);
// Traces all market data events coming from handlers.
MarketDataEventTracer marketDataEventTracer;
marketDataEventTracer.attachTo(handler);
// Making subscription.
MarketSubscriptions subscriptions;
MarketSubscription brentFutures(
);
subscriptions.insert(brentFutures);
// Start the Handler to download product definitions
// for all market subscriptions.
handler.start(subscriptions);
readUserResponse();
std::cout << "Shutdown the Handler..." << std::endl;
// Stop multicast data processing.
handler.stop();
std::cout << "Done." << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "Unknown exception." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}