class IO2GAccountsTableResponseReader
Parents | |
IO2GGenericTableResponseReader |
Brief
The class reads a stream of account rows coming from the trading server.
Details
All data from the trading server come in the form of responses. The type of the response depends on the type of the request.
An IO2GResponse
object of the GetAccounts
type
comes from the trading server as a response to a request for the initial account information.
The response consists of the Accounts table rows. Every row is represented by an
IO2GAccountRow
object.
In order to read this response, you must use the O2GAccountsTableResponseReader
.
Getting the response
If your application uses the IO2GTableManager
, the Accounts table
is always loaded during the login process.
This information is kept in an IO2GAccountsTable
object.
If your application does not use the IO2GTableManager
, the initial account information needs
to be requested.
Depending on the trading server settings, the Accounts table may or may not be loaded by the server automatically during the login process.
To determine whether the table is loaded or not and what follow-up action is required to obtain the
GetAccounts
response,
use the returned value of the IO2GLoginRules
.isTableLoadedByDefault
method:
Returned Value |
Follow-up action |
|
Call the
|
|
Create a request to get initial account information by using the
In this case, an instance of the |
Instantiating the class
An instance of the O2GAccountsTableResponseReader
class can be obtained by calling the
IO2GResponseReaderFactory
.createAccountsTableReader
method.
For example:
O2G2Ptr<IO2GResponseReaderFactory> responseFactory = session->getResponseReaderFactory();
if (responseFactory)
{
O2G2Ptr<IO2GAccountsTableResponseReader> accountsReader = responseFactory->createAccountsTableReader(accountsResponse);
...
}
Example
Get rows from the Accounts table [hide]
O2G2Ptr<IO2GResponse> accountsResponse = loginRules->getTableRefreshResponse(Accounts); O2G2Ptr<IO2GResponseReaderFactory> responseFactory = session->getResponseReaderFactory(); if (responseFactory) { O2G2Ptr<IO2GAccountsTableResponseReader> accountsReader = responseFactory->createAccountsTableReader(accountsResponse); for (int i = 0; i < accountsReader->size(); ++i) { O2G2Ptr<IO2GAccountRow> account = accountsReader->getRow(i); std::cout << "AccountID: " << account->getAccountID() << " Balance = " << account->getBalance() << " UsedMargin = " << account->getUsedMargin() << std::endl; } }
Public Methods | |
Gets an instance of the class that provides access to the list of table columns. |
|
Gets the value of a cell. |
|
Gets a generic row by its index. |
|
Gets a row from the Accounts table. |
|
Gets the type of a trading table. |
|
Checks whether the cell value can be used or not. |
|
Gets the number of rows in the reader. |