Account Info

Interface IAccount provides various methods for obtaining account information like current equity, use of leverage, available credit, etc. The interface can be retrieved in strategy either by using IContext.getAccount() or in onAccount callback method from its parameters. Note that values returned by getEquity, getUseOfLeverage and getCreditLine methods are to be used for information purposes and can be incorrect right after order changes, as they are updated in about every 5 seconds.

Current account data

Consider a sample code that in onAccount method prints current equity, total profit/loss, account balance and total order amount:

public void onAccount(IAccount account) throws JFException {
    double profitLoss = 0;
    double totalAmount = 0;  
    for (IOrder order : engine.getOrders()) {
        if(order.getState() == IOrder.State.FILLED){
            profitLoss += order.getProfitLossInUSD();
            totalAmount += order.getAmount();
    //account.getEquity() gets updated every 5 seconds 
    //whereas history.getEquity() gets calculated according to the last tick prices
    console.getOut().format("last server equity=%.2f calculated equity=%.2f profit/loss=%.2f credit line=%.2f balance=%.2f total amount=%.3f", 
        account.getEquity(), history.getEquity(), profitLoss, account.getCreditLine(), account.getBalance(), totalAmount).println();

Trading allowance

The IAccount.AccountState enumeration enlists the possible account states with respect to the trading allowance. Consider finding out the current AccountState:

public void onStart(IContext context) throws JFException {
The information on this web site is provided only as general information, which may be incomplete or outdated. Click here for full disclaimer.