How to use Price History API in Your C++ Application?

From FxCodeBaseWiki
Jump to: navigation, search

The article provides general steps on how to use the Price History API.

Details

In order to use the Price History API, you need to perform the following steps:

  • Create the ForexConnect trading session.
  • Before logging in, create an instance of IPriceHistoryCommunicator using PriceHistoryCommunicatorFactory::createCommunicator().

Keep the instance of the price history communicator for as long as the instance of the trading session is in use.

  • Attach the instance of the class that implements the IPriceHistoryCommunicatorListener interface to the communicator using the IPriceHistoryCommunicator::addListener() method.

In that class, implement the following methods. Follow these links for details on the implementation of each method.

  • onRequestCompleted()
  • onRequestFailed()
  • onRequestCancelled()
  • Log in to ForexConnect and wait until the communicator signals that it is ready (IPriceHistoryCommunicator::isReady()). You can also implement the IPriceHistoryCommunicatorStatusListener interface, subscribe it for the status events using the IPriceHistoryCommunicator::addStatusListener() method and then watch for the status changes using this interface.
  • Create an instance of the price history request using IPriceHistoryCommunicator::createRequest().
  • Send the request using IPriceHistoryCommunicator::sendRequest().
  • When the request is completed, the onRequestCompleted() method will be called. In the implementation of this method:
  • Create an instance of the IO2GMarketDataSnapshotResponseReader using IPriceHistoryCommunicator::createResponseReader.
  • Use IO2GMarketDataSnapshotResponseReader to extract price data from the response object passed to the onRequestCompleted() method.
  • Do not release the instance of the price history communicator until:
  • The trading session is logged off.
  • All listeners are unsubscribed.

This Article in Other Languages

Language: English  • español