AccountInfo ForexConnectClient::getAccountInfo()
{
    TableHandler<Accounts, IO2GAccountsTable, IO2GAccountTableRow> handler(mpSession);
    while (true)
    {
	IO2GAccountTableRow *account = handler.getNextRow();
	if (account == NULL)
	{
	    throw std::runtime_error("Could not get account table row.");
	}
        if (mAccountID.size() == 0 || strcmp(account->getAccountID(), mAccountID.c_str()) == 0)
	{
            if (strcmp(account->getMarginCallFlag(), "N") == 0 &&
                (strcmp(account->getAccountKind(), "32") == 0 ||
		 strcmp(account->getAccountKind(), "36") == 0))
	    {
		AccountInfo info;
		info.mBalance = account->getBalance();
		info.mUsedMargin = account->getUsedMargin();
		info.mUsableMargin = account->getUsableMargin();
		info.mBaseUnitSize = account->getBaseUnitSize();
		info.mEquity = account->getEquity();
		info.mGrossPL = account->getGrossPL();
                return info;
	    }
	}
    }
}