Bug 250403 - Dashboard "Shares & Indexes" shows wrong percentaged variation
Summary: Dashboard "Shares & Indexes" shows wrong percentaged variation
Status: RESOLVED FIXED
Alias: None
Product: skrooge
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources macOS
: NOR minor
Target Milestone: ---
Assignee: Stephane MANKOWSKI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-07 00:33 UTC by Christoph Vogtländer
Modified: 2010-09-09 11:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Vogtländer 2010-09-07 00:33:16 UTC
Version:           unspecified (using KDE 4.4.5) 
OS:                OS X

Wrong percentaged variation is shown in Dashboard "Shares & Indexes", e.g.:
Todays (Monday) DAX value: 6155,04
Fridays DAX value: 6134,62
Shown variation in Dashboard: 0,11 %
Should be: 0,33%

Values downloaded with Yahoo. Skrooge shows 1/3 less than expected. This also applies on all other Shares/Indexes I'm monitoring. It seems that skrooge interpolates values for saturday and sunday and calculates the variation for monday based on the (interpolated) value of sunday resulting in wrong values.

Reproducible: Didn't try
Comment 1 Stephane MANKOWSKI 2010-09-07 10:11:51 UTC
Hi,
The percentage is computed by this:
100*(EXP(LN(v2/v1)/(d1.daysTo(d2)))-1)

Where, v1 and v2 are values and d1 and d3 are dates.

In you case, the result is:
100*(EXP(LN(6155,04/6134,62 )/3)-1)=0.11%

The problem is that, between Fridays and Monday, we have 3 days.

The expected result is :
100*(EXP(LN(6155,04/6134,62 )/1)-1)=0.33%
because we should use only "working" days

I will check how to do that.
Comment 2 Christoph Vogtländer 2010-09-07 22:37:37 UTC
Are you sure it is correct to divide by the number of days at all? If, for example, the values cannot be downloaded and values are entered manually every now and then imho it would be wrong to calculate the percentage based on the above formula. I think it would be better to assume the value stays as it was. This would also work around weekends, holidays and days where stock market (or a particular index) is closed for other reasons.
What do you think?
Comment 3 Stephane MANKOWSKI 2010-09-08 09:59:00 UTC
You are right, it's better to keep it like this.
Comment 4 Christoph Vogtländer 2010-09-08 23:54:30 UTC
This is not what i meant. I propose to change the formula to:
100*(EXP(LN(v2/v1))-1)

Sorry, I don't want to argue, and I think this it is not a very important issue. No offense. Please change back to WONTFIX if do not want to change this.
Comment 5 Stephane MANKOWSKI 2010-09-09 10:54:51 UTC
Hi Christophe,

Sorry for the misunderstanding.

The right formula to compute the "daily" rate is:
100*(EXP(LN(v2/v1)/(d1.daysTo(d2)))-1)

The problem is that in you case d1.daysTo(d2) returns 3 even if there is only 1 "working" day.

I can not use systematically the following formula because some people are downloading only one value per month.  

So, I need a way to compute "working" days between 2 dates.
Comment 6 Stephane MANKOWSKI 2010-09-09 11:59:37 UTC
SVN commit 1173419 by smankowski:

BUG: 250403: Dashboard "Shares & Indexes" shows wrong percentaged variation 

 M  +1 -0      CHANGELOG  
 M  +1 -1      skgbankmodeler/skgunitobject.cpp  
 M  +14 -0     skgbasemodeler/skgservices.cpp  
 M  +8 -0      skgbasemodeler/skgservices.h  
 M  +6 -0      skgbasemodelertest/skgtestbase.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1173419