class O2GTableManager
Brief
The class creates and maintains trading tables in the ForexConnect memory.
Details
The O2GTableManager
allows to create and maintain in-memory representations of the trading tables.
The tables updates are handled by the ForexConnect API automatically.
For implementation details, refer to the ForexConnect API Class Hierarchy section.
Alternatively, you can:
Request the initial data from the trading server by calling the
O2GRequestFactory
.createRefreshTableRequest
or
O2GLoginRules
.getTableRefreshResponse
methods.
Capture the TABLES_UPDATES responses.
Maintain the received data in user-created structures.
Advantages of the O2GTableManager usage
The following list summarizes the advantages that the O2GTableManager
usage provides:
In-memory representation of the trading tables with up-to-date values by the descendants of the O2GTable class.
Access to the calculated fields (i.e. PipCost in the Offers table is accessible through the getPipCost method, UsableMargin in the Accounts table is accessible through the getUsableMargin method, etc.). All calculated fields are updated automatically.
Access to the Summary table information through the methods of the O2GSummaryTableRow class.
Separate subscriptions to trading table events. The events are described in the IO2GTableListener interface documentation.
Note: The disadvantage of the table manager usage is the performance decrease. The performance decreases because the values of the calculated fields are computed at every price change. If your application does not need the values of the calculated fields, the table manager usage is not recommended.
Prerequisites
You must specify before the login that your session uses the table manager by calling the
O2GSession
.useTableManager
method. For example,
mSession.useTableManager(O2GTableManagerMode.YES, null);
After specifying the usage of the table manager for your session, you must log on to the trading server by calling the
O2GSession
.login
method. For example,
mSession.login(mUserID, mPassword, mURL, mConnection);
Instantiating the class
An instance of the table manager can be obtained only after an O2GSession object gets the CONNECTED status.
You can track the trading tables data for all your accounts or for each of the accounts individually.
To get an instance of the class that tracks the data for all accounts, call the O2GSession
.getTableManager
method. For example,
O2GTableManager tableManager = mSession.getTableManager();
To get an instance of the class that tracks the data for a specific account, call the O2GSession
.getTableManagerByAccount
method. For example,
O2GTableManager tableManager = mSession.getTableManagerByAccount(mAccountID);
In order to use the trading tables data, an instance of the O2GTableManager
class must have the TABLES_LOADED status.
Note: If the connection between the ForexConnect API and the trading server brakes, you may need to re-create an instance of the O2GTableManager
class.
In case the restore of a connection fails, the session status becomes DISCONNECTED and you must login and create a new instance of the O2GTableManager
class.
In case the ForexConnect API restores the connection successfully, you can use the existing instance of the O2GTableManager
class.
For a detailed explanation of the session statuses, refer to the Session Statuses section.
For complete details of the table manager usage, refer to the How to use a table manager in ForexConnect API section.
Example
Get close price and current profit/loss [show]
The namespace is com.fxcore2
.
Public Methods | |
Gets a table manager status. |
|
Gets an instance of a trading table. |
|
Locks tables updates. |
|
Unlock table updates. |