Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CAGR columns to Investment Lots report #1956

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

mcbridebt
Copy link
Contributor

@mcbridebt mcbridebt commented Jun 11, 2024

Adds Compound Annual Growth Rate (CAGR) columns (realized and unrealized) to the Investment Lots report.

Currently, the report shows investment gain/loss percentages via the Return on Investment (ROI) columns (both realized and unrealized). This can be useful in some situations, but ROI has its limitations. It does not recognize the time value of money. But CAGR does. It is useful for the report to support both ROI and CAGR.

For example, suppose there are two investment lots, [A] and [B]. Both were purchased for $100 and sold for $110. At first glance, it might seem that they performed equally. The ROI for each is 10% (gain divided by basis). But suppose [A] was held for only one year before being sold while [B] was held for 10 years. Clearly [A] grew at a much faster rate than [B], which ROI does not reflect. The CAGR is 10% for [A] but only 0.96% for [B], which is much more illustrative of how much [A] has outperformed [B].

See https://www.investopedia.com/terms/c/cagr.asp for CAGR description and formula.
Bug: https://bugs.gnucash.org/show_bug.cgi?id=799335

New options:
image

New table columns:
image

TODO: Update report documentation for the new columns

Fix and standardize 'columns' labels
@christopherlam
Copy link
Contributor

Hi I'm the resident scheme maintainer.

I don't have any opinion regarding the calculations... I'll assume that they are correct; to learn enough scheme to create a custom report sets a non-trivial bar of entry ;-)

However: can the report handle the full gamut of stock-type activity? ie. buy/sell, dividend payment, stock split, reverse stock split, return of capital, notional distribution? and the short-position counterparts? If not, it may need to be explicit about safely bailing out when encountering these scenarios. Example: see advanced-portfolio.scm which cannot handle short positions, and will simply bail out if the stock balance is negative.

I'll have an opinion regarding programming style: you'll notice most existing reports will minimise the use of set! in the report. set! can redefine any variable, whether local or global; and makes the report arguably more difficult to follow. Ideally they would be rewritten; the scheme idiom is to use named let loops to achieve similar results.

Moreover there should be tests. See example at test/test-ifrs-cost-basis.scm to create stock transactions and tests the ifrs report output. Note the ifrs cost basis report doesn't use lots. See test-new-owner-report.scm which has some lot-creation routines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants