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 command includes unwanted amounts when given a period and dates on postings. #2197

Closed
hbwales opened this issue May 2, 2024 · 6 comments
Labels

Comments

@hbwales
Copy link

hbwales commented May 2, 2024

The roi command includes unwanted amounts when given a period and dates on postings.

For example with test.journal as:

2020-12-01 Test1
  A        +200.00  ; date:2020-12-01
  B        +100.00  ; date:2021-01-01
  C        -300.00

2020-12-01 Test2
  D        +200.00
  E        +100.00
  F        -300.00

I get:

> hledger.exe roi --inv A --pnl dummy -p 2020 -f test.journal
+---++------------+------------++---------------+----------+-------------+---------++---------++------------+----------+
|   ||      Begin |        End || Value (begin) | Cashflow | Value (end) |     PnL ||     IRR || TWR/period | TWR/year |
+===++============+============++===============+==========+=============+=========++=========++============+==========+
| 1 || 2020-01-01 | 2020-12-31 ||             0 |   300.00 |      200.00 | -100.00 || -99.16% ||    -33.33% |  -33.33% |
+---++------------+------------++---------------+----------+-------------+---------++---------++------------+----------+

Note the Cashflow of 300, & PnL -100, I would expect 200 and 0 respectively?
Taking the dates off the postings gives the expected result:

>hledger.exe roi --inv D --pnl dummy -p 2020 -f test.journal
+---++------------+------------++---------------+----------+-------------+-----++-------++------------+----------+
|   ||      Begin |        End || Value (begin) | Cashflow | Value (end) | PnL ||   IRR || TWR/period | TWR/year |
+===++============+============++===============+==========+=============+=====++=======++============+==========+
| 1 || 2020-01-01 | 2020-12-31 ||             0 |   200.00 |      200.00 |   0 || 0.00% ||      0.00% |    0.00% |
+---++------------+------------++---------------+----------+-------------+-----++-------++------------+----------+

(Version used is hledger 1.32.1-g39fc78a64-20231207, windows-x86_64)

@simonmichael
Copy link
Owner

Thanks for the report. There was one fix for roi in hledger 1.33:

roi now correctly interacts with --value. #2190 (Dmitry Astapov)

Could you confirm your issue still happens with 1.33 ?

@hbwales
Copy link
Author

hbwales commented May 3, 2024

Thanks - I get the same results with hledger 1.33.1-gba1b40e50-20240502, windows-x86_64

@simonmichael
Copy link
Owner

@adept, any thoughts ?

@adept
Copy link
Collaborator

adept commented May 3, 2024

@hbwales , in this transaction:

2020-12-01 Test1
  A        +200.00  ; date:2020-12-01
  B        +100.00  ; date:2021-01-01
  C        -300.00

your assumption seems to be that these cash movements have taken place:

  1. 200 from C to A
  2. 100 from C to B

However, roi takes an "A-centric" view, and treats all transactions that mention A as related to the investment. So the interpretation is this:

  1. 300 from C to A (money moving in, as C is not a PnL account)
  2. 100 from A to B (money moving out, as B is not a PnL account)

This is documented in https://hledger.org/1.33/hledger.html#semantics-of---inv-and---pnl

If this interpretation does not suit you, you need to split this transaction into two so that the transaction that is not related to your investment will not have any mention of A.

This is not a recent development, I would've expected roi to behave like this from the very beginning

@simonmichael
Copy link
Owner

@hbwales, shall we close this ?

@simonmichael
Copy link
Owner

simonmichael commented May 23, 2024

Closing, presumed resolved.

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

No branches or pull requests

3 participants