class O2GAccountsTable

Parents
O2GTable

Brief

The class keeps up-to-date information about accounts in memory.

Details

The class is an in-memory representation of the Accounts table.
In order to keep this representation in sync with the trading server, you must instantiate the class and listen to the updates coming from the trading server. The class provides methods to find individual accounts, represented by O2GAccountTableRow.

Prerequisites

The class is available only through the use of the O2GTableManager. An O2GTableManager object must have the O2GTableManagerStatus.TABLES_LOADED status.
For complete instructions on the table manager usage, see the How to use table manager in ForexConnect API section.

Instantiating the class

In order to get accounts information for the first time, you must obtain an instance of the class by calling the O2GTableManager.getTable method with the O2GTableType.ACCOUNTS argument. For example,

O2GAccountsTable accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.ACCOUNTS);

Receiving notifications about the Accounts table updates

In order to keep the O2GAccountsTable data current, your application must listen to the Accounts table updates coming from the trading server. These updates represent inserts into the table and changes of the account information. An instance of the class implementing the IO2GTableListener interface must be subscribed to the table updates. Subscription to each update type is done individually. Before the logout, you must unsubscribe the listener from every update type separately. The table below shows the subscription/unsubsription syntax for the O2GAccountsTable:

Update type

Subscribe syntax

Unsubscribe syntax

INSERT

accountsTable.subscribeUpdate(O2GTableUpdateType.INSERT, tableListener);

accountsTable.unsubscribeUpdate(O2GTableUpdateType.INSERT, tableListener);

UPDATE

accountsTable.subscribeUpdate(O2GTableUpdateType.UPDATE, tableListener);

accountsTable.unsubscribeUpdate(O2GTableUpdateType.UPDATE, tableListener);

Note: Accounts can he deleted only when the market is closed. Therefore, you do not receive an update of the DELETE type during the trading session and there is no need to subscribe to it.

Example

Get Account ID, Equity and Usable margin [show]

The namespace is com.fxcore2.

Public Methods

findRow

Finds a row in the O2GAccountsTable by an AccountID.

forEachRow

Iterates through the rows of a table.

getNextGenericRow

Gets the next row from a table.

getNextGenericRowByColumnValue

Gets the next row from O2GTable based on the column value.

getNextGenericRowByColumnValues

Gets the next row from O2GTable based on any of the column values.

getNextGenericRowByMultiColumnValues

Gets the next row from O2GTable based on multiple columns values.

getNextRow

Gets the next row from the O2GAccountsTable.

getNextRowByColumnValue

Gets the next row from O2GAccountsTable based on the column value.

getNextRowByColumnValues

Gets the next row from O2GAccountsTable based on any of the column values.

getNextRowByMultiColumnValues

Gets the next row from O2GAccountsTable based on the multiple columns values.

getRow

Gets a row from the O2GAccountsTable by its index.

getStatus

Gets the status of a table.

isCellChanged

Checks whether the value of a cell has changed on not.

subscribeStatus

Subscribes a table listener to table status changes.

subscribeUpdate

Subscribes a table listener to table updates.

unsubscribeStatus

Unsubscribes a table listener from table status changes.

unsubscribeUpdate

Unsubscribes a table listener from table updates.

back