Skip to content

The computing of appreciation/depreciation of assets isn't exact #7122

@pk960

Description

@pk960

MMEX version:

  • 1.7.0
  • 1.8.0
  • 1.8.1
  • 1.8.2
  • 1.9.0
  • Other (please specify)

Note: bug reporters are expected to have verified the bug still exists
either in the last stable version of MMEX or on updated development code
(master branch).
=> Verified in the master branch.

Operating System:

  • Windows
  • Mac OSX
  • Linux

Description of the bug

The computing of the appreciation or depreciation in Model_Asset.cpp isn't exact.
The tooltip says that it is a annual rate.
The current formula for the appreciation is
amount *= pow(1.0 + (r->VALUECHANGERATE / 36500.0), diff_time_in_days);
For an annual rate, the correct formula is :
amount *= pow(1.0 + (r->VALUECHANGERATE / 100.0), diff_time_in_days/365.25);

Reproduction

Is the bug reproducible?

  • Always
  • Randomly
  • Happened only once

Reproduction steps:

Create an asset with an initial value of 100, an appreciation rate of 10% by year and a purchase date exactly 4 years ago.

Expected result:

The asset value should be 146.41 (100*1.10*1.10*1.10*1.10) exactly 4 years after the purchase.

Actual result:

The asset value is 149.22 exactly 4 years after the purchase.

Additional information

The current formula is applicable to a daily rate for years of 365 days.
But the conversion of the annual rate to the daily rate cannot be done by a division by 365.
The correct conversion is dailyRate = (pow(1+annualRate/100,1/365)-1)*100.
But it is simpler to use the annual rate.
And because years have a mean duration of 365.25 days between 1900 and 2100, 365.25 is better than 365 if you don't want to compute differently leap years and normal years.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions