Dukascopy
 
 
Wiki JStore Search Login

JForex Platform v2.18.14 possible equity bug
 Post subject: JForex Platform v2.18.14 possible equity bug Post rating: 0   New post Posted: Wed 19 Sep, 2012, 17:21 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
It looks like behavior of IHistory.getEquity() in LIVE mode is incorrect and may have experienced a regression bug.

Prior platform version 2.18.13 appears to have been correct.

As you know, onAccount updates are fairly infrequent. So in order to get a better estimate of equity, I read in the forum that IHistory's method getEquity() could be used. I've been using this method for a while now...

In the onTick event, if I have not received an onAccount update for a while...
then I use IHistory's getEquity() to update the equity. But it is retrieving a value which does not match the true equity, it is a lower value. (see attached image)

This value does not agree with the correct Equity value as shown on lower left of JForex platform. The account position is FLAT at this time.

I have attached an image of the mismatch in values. The incorrect value originates from IHistory getEquity() from within a Strategy module onTick callback context. The code was functioning correctly for v2.18.13 of the JForex platform. I think I'm using this correctly, it has worked for at least a week until the regression appeared.

            IHistory history = context.getHistory();
                  double accountEquity = history.getEquity(); // appears incorrect


Attachments:
File comment: IHistory getEquity() incorrect value
HistoryGetEquityBug.PNG [49.58 KiB]
Downloaded 352 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: FIXED: Seems to be my error in using incorrect getEquity() Post rating: 0   New post Posted: Wed 19 Sep, 2012, 17:40 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
In thinking about this, I believe it is my error, using the incorrect getEquity() call.

Just to note the error is in LIVE mode, but I never use anything other than LIVE and it was working fine yesterday, I believe.

Perhaps I should get the Account object from context, and use IAccount.getEquity() instead of IHistory.getEquity()... I will try this now, and report what happens .......... <coding furiously>

I think I was stupid to use IHistory for LIVE getEquity(), should use IAccount.getEquity().

OK, that may be the problem, and it was MY mistake. Somehow the IHistory.getEquity() seemed to be working properly to track equity, but the CORRECT method I suppose should be IAccount.getEquity() for the LIVE context.

Very sorry, but this now looks OK. I was misled by a post into using IHistory.getEquity() probably because the post might have had to do with some backtesting, and not LIVE mode.

HyperScalper


 
 Post subject: Confusion resolved NO BUG Post rating: 0   New post Posted: Wed 19 Sep, 2012, 19:10 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
In conclusion, this appears absolutely correct. Perhaps IHistory.getEquity() for a LIVE account should return IAccount.getEquity(). It certainly confused me, but now all is well !! :)

// from within an onTick Strategy callback handler...
// IF some time has elapsed since last equity update, not advisable or necessary on every tick event !!!!
            IAccount account = context.getAccount();
   double accountEquity = account.getEquity(); // for LIVE account this is correct


Thanks for your help!


 

Jump to:  

cron
  © 1998-2025 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