Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

IAccount.getEquity() returns 0 in beginning of demo-run
 Post subject: IAccount.getEquity() returns 0 in beginning of demo-run Post rating: 0   New post Posted: Mon 02 Mar, 2009, 12:54 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
I have the problem, that in demo mode in the beginning of a run getEquity() returns 0.
I would like to calculate the volume for the first trade as a function of the equity.

How can I get the correct equity at the beginning of a run?

Thanks,
R.


 
 Post subject: Re: IAccount.getEquity() returns 0 in beginning of demo-run Post rating: 0   New post Posted: Wed 04 Mar, 2009, 13:33 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
To avoid first ticks without account update try to use this:

//........
private double equity = 0;
public void onAccount(IAccount account) throws JFException {
      this.equity = account.getEquity();
}
public void onTick(Instrument instrument, ITick tick) throws JFException {

      if (instrument != currentInstrument) {
         return;
      }
      if (equity == 0) {
         log("Waiting for account update.");
         return;
      }
//................
}


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com