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

[ROI] provide not annualized TWR #2068

Closed
chrpinedo opened this issue Jul 31, 2023 · 2 comments · Fixed by #2069
Closed

[ROI] provide not annualized TWR #2068

chrpinedo opened this issue Jul 31, 2023 · 2 comments · Fixed by #2069
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. roi

Comments

@chrpinedo
Copy link

Nowadays the hledger roi command provides the annualized TWR and the annualized IRR. I think that IRR must be always annualized but TWR value firstly is calculated over one period and then this value can be annualized (and in fact the hledger roi command provides it always annualized).

Annualized value of TWR and the IRR is good to calculate the performance of one investment over long periods of time however:

  • it provides very huge values with short periods of time of, for example, a couple of months
  • it is useless to track the evolution of the investment (I explain later).

To track the evolution of the investment over one period (-b begin-date and -e end-date) I often use the hledger roi command with subperiods -Y (yearly), -M (monthly) and even in rare occasions -W (weekly). However, hledger roi command provides the annualized value of TWR and IRR for the subperiods. It would be very useful to provide also the "simple TWR" or "TWR of the subperiod" and the "accumulative TWR" of the period with the previous periods.

@chrpinedo chrpinedo added the A-WISH Some kind of improvement request, hare-brained proposal, or plea. label Jul 31, 2023
@adept
Copy link
Collaborator

adept commented Jul 31, 2023

twr <- timeWeightedReturn showCashFlow prettyTables investmentsQuery trans mixedAmountValue thisSpan
is where the twr for the period is computed. It could return final amount of units and final unit price which could enable the "accumulated TWR" computation, if it is passed on to the subsequent call on the next loop iteration and used as initialUnits and initialUnitPrice here:

let initialUnitPrice = 100 :: Decimal

annualizedTWR = 100*((1+(realToFrac totalTWR/100))**(1/years)-1) :: Double
is where the TWR is annualized, so returning totalTWR along with annualizedTWR there should be, I think, the unadjusted TWR for the period.

It wold be nice to have some examples with TWR computed by not-hledger (say, by excel) to verify this, though.

@chrpinedo do you happen to have some numbers that could be useful as tests?

@chrpinedo
Copy link
Author

@adept just now I don't have a third party software to calculate TWR/IRR. I was just evaluating if hledger roi command was enough for me to track the performance of the investments or if I should export cashflows from hledger to create one spreadsheet (I don't know if it is easy to export cashflows in CSV format with hledger roi command or perhaps with hledger commands).
If you find useful I could try to provide one use case with one stock of my portfolio with hledger roi and with one google sheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. roi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants