The class provides access to account information.
Method/Use |
Prerequisites |
O2GAccountsTableResponseReader .getRow
This method is used to get the initial account information after a session with the trading server is established.
This method provides access to a single account. If you have multiple accounts, call this method in a loop. |
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 get the account information, use the returned value of the O2GLoginRules .isTableLoadedByDefault method:
If the table is loaded, you can get the account information by using the O2GLoginRules .getTableRefreshResponse method;
Otherwise, you must create a request to load the table by using the O2GRequestFactory .createRefreshTableRequest method.
You must obtain a response to this request by implementing the IO2GResponseListener .onRequestCompleted method.
Both methods use the O2GResponse object of the O2GResponseType .GetAccounts type.
You must parse this object by using the O2GAccountsTableResponseReader object.
For details, see the example below. |
O2GTablesUpdatesReader .getAccountRow
This method is used to get account information updates.
This method provides access to a single account. If you have multiple accounts, call this method in a loop. |
To receive the account information updates, you must implement the IO2GResponseListener .onTablesUpdates method.
The received O2GResponse object is of the O2GResponseType .TablesUpdates type.
You must parse this object by using the O2GTablesUpdatesReader object.
For details, see the example below. |
Get Account ID, Balance and Used margin [hide]
// Get accounts information
public static void getAccounts(O2GSession session, ResponseListener responseListener)
{
try
{
O2GLoginRules loginRules = session.getLoginRules();
// Check if Accounts table is loaded automatically
if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.Accounts))
{
// If table is loaded, use getTableRefreshResponse method
O2GResponse accountsResponse = loginRules.getTableRefreshResponse(O2GTableType.Accounts);
O2GResponseReaderFactory responseFactory = session.getResponseReaderFactory();
if (responseFactory != null)
{
O2GAccountsTableResponseReader accountsReader = responseFactory.createAccountsTableReader(accountsResponse);
for (int i = 0; i < accountsReader.Count; i++) {
O2GAccountRow account = accountsReader.getRow(i);
Console.WriteLine("AccountID = " + account.AccountID +
" Balance = " + account.Balance +
" UsedMargin = " + account.UsedMargin);
}
}
}
else
{
// If table is not loaded, use createRefreshTableRequest method
O2GRequestFactory requestFactory = session.getRequestFactory();
if (requestFactory != null)
{
O2GRequest request = requestFactory.createRefreshTableRequest(O2GTableType.Accounts);
responseListener.setRequest(request.RequestID);
session.sendRequest(request);
Thread.Sleep(1000);
}
}
}
catch (Exception e)
{
Console.WriteLine("Exception in getAccounts().\n\t " + e.Message);
}
}
// Implementation of IO2GResponseListener interface public method onRequestCompleted
public void onRequestCompleted(String requestID, O2GResponse response)
{
if (requestID.Equals(mRequestID))
{
O2GResponseReaderFactory readerFactory = mSession.getResponseReaderFactory();
if (readerFactory != null)
{
O2GAccountsTableResponseReader reader = readerFactory.createAccountsTableReader(response);
for (int i = 0; i < reader.Count; i++)
{
O2GAccountRow account = reader.getRow(i);
Console.WriteLine(" This is a response to your request: \nAccountID = " + account.AccountID +
" Balance = " + account.Balance +
" UsedMargin = " + account.UsedMargin);
}
}
}
}
// Implementation of IO2GResponseListener interface public method onTablesUpdates
public void onTablesUpdates(O2GResponse response)
{
O2GResponseReaderFactory factory = mSession.getResponseReaderFactory();
if (factory != null)
{
O2GTablesUpdatesReader updatesReader = factory.createTablesUpdatesReader(response);
for (int i = 0; i < updatesReader.Count; i++)
{
O2GTableType tableType = updatesReader.getUpdateTable(i);
if (tableType == O2GTableType.Accounts)
{
O2GAccountRow account = updatesReader.getAccountRow(i);
Console.WriteLine(" This is a live update: \nAccountID = " + account.AccountID +
" Balance = " + account.Balance +
" UsedMargin = " + account.UsedMargin);
}
}
}
}
Public Properties |
AccountID
|
Gets the unique identification number of the account.
|
AccountKind
|
Gets the type of the account.
|
AccountName
|
Gets the unique name of the account as it is displayed in the FX Trading Station.
|
AmountLimit
|
Gets the maximum amount of an order that is allowed on the account.
|
Balance
|
Gets the amount of funds on the account.
|
BaseUnitSize
|
Gets the size of one lot.
|
Columns
|
The columns of the table.
|
LastMarginCallDate
|
Gets the date and time of the last occurrence of a Margin Call.
|
LeverageProfileID
|
Gets the unique identification number of an account leverage profile that specifies margin requirements.
|
M2MEquity
|
Gets the equity balance of the account at the beginning of a trading day.
|
MaintenanceFlag
|
Gets a rollover maintenance flag.
|
MaintenanceType
|
Gets the type of a position maintenance.
|
ManagerAccountID
|
Gets the unique identification number of the funds manager account.
|
MarginCallFlag
|
Gets the limitation state of the account.
|
NonTradeEquity
|
Gets the amount of the accounting transactions that is applied to the account during the current trading day.
|
TableType
|
The type of the table.
|
UsedMargin
|
Gets the amount of funds used to maintain all open positions of the account.
|
UsedMargin3
|
Gets the amount of funds used to maintain all open positions of the account with a three-level margin policy.
|
Public Methods |
getCell
|
Gets a cell of the table.
|
isCellChanged
|
Gets a flag indicating whether the value of the cell is changed.
|