Beispiel #1
0
void TableListener::onChanged(const char *rowID, IO2GRow *row)
{
    O2GTable type = row->getTableType();
    if (type == Accounts)
    {
        IO2GAccountTableRow *account = (IO2GAccountTableRow *)row;
        std::cout << "The balance has been changed AccountID=" << account->getAccountID() <<
                      " Balance=" << std::fixed << account->getBalance() <<
                      " Equity=" << std::fixed << account->getEquity() << std::endl;
    }
}
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;
	    }
	}
    }
}