API Reference
This section describes the creation of a simple Bovespa application step by step.
Follow these instructions to get it to work:
Engine initialization
Execute the following instruction to initialize FIX engine.
The engine.properties file is required to read the engine configuration parameters. It must, by default, be present in the current directory. If the file is located elsewhere or has a different name specify the properties file name and path explicitly.
Engine::init ("bovespa.properties");
If an error occurs during initialization (the properties file is not found, a required property is missing etc.) the exception will be thrown.
try {
Engine::init("engine.properties");
}
catch( const std::exception& ex ) {
cout << "ERROR: " << ex.what() << endl;
}
BovespaApplication creation
You can create an BovespaApplication in three steps:
Configure BovespaApplication parameters, create BovespaApplication object.
BovespaApplicationParams params;
params.templatesFn_ = "templates.xml";
params.configXml_ = "config.xml";
params.tcpReplayParams_.senderCompId_ = "Sender";
params.tcpReplayParams_.targetCompId_ = "Target";
params.tcpReplayParams_.username_ = "username";
params.tcpReplayParams_.password_ = "12345";
params.tcpReplayParams_.ip_ = "1.2.3.4;";
params.tcpReplayParams_.port_ = 3001;
app_ = Engine::FixEngine::singleton()->createBovespaApplication(params);
Subscription
You will start receiving market data from after you subscribe to a symbol and provide per-instrument listener.
Use the BovespaApplication::subscribeToInstrument method for that.
Market data will be delivered to the listener's callbacks.
BovespaSubscriptionItem item;
item.symbol_ = symbol;
app_->subscribeToInstrument(item, new PerInstrumentListener());
Releasing resources
Use the BovespaApplication::release() method to release the resources. Calling unsubscribe is optional.
Full example
#include <iostream>
#include <string>
#include <b2bits/Engine.h>
#include <B2BITS_BovespaApplication.h>
#include <B2BITS_BovespaApplicationListeners.h>
using namespace Bovespa;
using namespace B2bits::MD;
{
{
}
{
this->release();
}
{
}
}
size_t count,
bool isNewSequence) override
{
}
}
}
recovered_ = false;
}
recovered_ = true;
}
std::cerr << error << std::endl;
}
}
bool recovered_ = true;
};
class BovespaClient
{
public:
BovespaClient()
{
app_ = Engine::FixEngine::singleton()->createBovespaApplication(params);
}
void subscribe(std::string const& symbol)
{
item.
recovery_ = RO_USE_MARKET_TCP_AS_POSIBLE_RECOVERY;
app_->subscribeToInstrument(item, new PerInstrumentListener());
}
void release() {
app_->release();
app_ = NULL;
}
private:
};
int main(int argc, char* argv[])
{
try
{
Engine::init();
BovespaClient application;
application.subscribe("EZTC3");
char c;
std::cin >> c;
application.release();
Engine::FixEngine::destroy();
}
catch (const std::exception& ex)
{
std::cout << " ERROR: " << ex.what() << std::endl;
return -1;
}
return 0;
}