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

-X/--value doesn't work for 'roi' command #1417

Closed
aragaer opened this issue Dec 15, 2020 · 9 comments
Closed

-X/--value doesn't work for 'roi' command #1417

aragaer opened this issue Dec 15, 2020 · 9 comments
Assignees
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. docs Documentation-related. roi

Comments

@aragaer
Copy link
Contributor

aragaer commented Dec 15, 2020

My default currency is quite volatile and I prefer reports in some other, somewhat more stable currency. Let's say I want to track some investment in commodity A while getting report in currency B (here 1/B is the volatile default currency).

P 2020-12-01 A 50
P 2020-12-01 B 100

2020-12-01 * buy A
 assets  10 A @ 50
 cash

P 2020-12-10 A 55
P 2020-12-10 B 125

2020-12-10 * reevaluate
 assets  -10 A @ 50
 assets  10 A @ 55
 equity:unrealized gains

I want to see that my investment actually went down -- It was 5B and now it's 4.4B. But I can't do that since hledger roi ignores the -X or --value flag (but it is in the documentation):

$ hledger -f /tmp/hl.journal roi --inv "assets cur:A" --pnl "unrealized gains" -X B
+---++------------+------------++---------------+----------+-------------+-----++----------+----------+
|   ||      Begin |        End || Value (begin) | Cashflow | Value (end) | PnL ||      IRR |      TWR |
+===++============+============++===============+==========+=============+=====++==========+==========+
| 1 || 2020-12-01 | 2020-12-10 ||             0 |      500 |         550 |  50 || 3142.15% | 3142.15% |
+---++------------+------------++---------------+----------+-------------+-----++----------+----------+
@aragaer aragaer added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Dec 15, 2020
@simonmichael
Copy link
Owner

I agree that we should enhance roi to support this, or adjust the command line help so it doesn't advertise the valuation flags.

@simonmichael simonmichael added cli Command line parsing, options, arguments and suchlike. docs Documentation-related. labels Dec 18, 2020
aragaer added a commit to aragaer/hledger that referenced this issue Dec 31, 2020
@aragaer
Copy link
Contributor Author

aragaer commented Dec 31, 2020

I tried to implement this. It works but I don't feel certain enough to create a pull request yet.

@simonmichael
Copy link
Owner

This should be fixed in master by #1454, perhaps you can confirm and close this when you get a chance @aragaer.

@aragaer
Copy link
Contributor Author

aragaer commented Jan 12, 2021

Well... yeah. It's definitely worth seeing numbers so precise. Something's off with amount formatting - I'm seeing about 250 digits after the decimal point. Otherwise it looks good.

@simonmichael
Copy link
Owner

Ouch. :-) A small repro would be great.

@aragaer
Copy link
Contributor Author

aragaer commented Jan 12, 2021

P 2020-12-01 $ 76.20
P 2021-01-01 $ 73.88

2020-12-02 invest
 assets:investment  10000
 assets

2021-01-02 get profit
 assets:investment  =11000
 income:investment
$ stack exec -- hledger -f /tmp/roi.journal roi --inv assets:investment --pnl income:investment
+---++------------+------------++---------------+----------+-------------+------++---------+---------+
|   ||      Begin |        End || Value (begin) | Cashflow | Value (end) |  PnL ||     IRR |     TWR |
+===++============+============++===============+==========+=============+======++=========+=========+
| 1 || 2020-12-02 | 2021-01-02 ||             0 |    10000 |       11000 | 1000 || 196.58% | 196.58% |
+---++------------+------------++---------------+----------+-------------+------++---------+---------+
$ stack exec -- hledger -f /tmp/roi.journal roi --inv assets:investment --pnl income:investment -X '$'
+---++------------+------------++---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------++---------+---------+
|   ||      Begin |        End || Value (begin) |                                                                                                                                                                                                                                                        Cashflow |                                                                                                                                                                                                                                                      Value (end) |                                                                                                                                                                                                                                                             PnL ||     IRR |     TWR |
+===++============+============++===============+=================================================================================================================================================================================================================================================================+==================================================================================================================================================================================================================================================================+=================================================================================================================================================================================================================================================================++=========+=========+
| 1 || 2020-12-02 | 2021-01-02 ||             0 | 135.35462912831618841364374661613427179209528965890633459664320519761775852734163508391987005955603681645912290200324851109907958852192744991878722252301028695181375203031943692474282620465619924201407688142934488359501894964807796426637791012452625879805 | 148.890092041147807255008121277747698971304818624796968056307525717379534380075798592311857065511640498105035192203573362208987547374120194910665944775311315646995127233351380617217108825121819166215484569572279371954520844612885760693015701136978884677855 | 13.535462912831618841364374661613427179209528965890633459664320519761775852734163508391987005955603681645912290200324851109907958852192744991878722252301028695181375203031943692474282620465619924201407688142934488359501894964807796426637791012452625879805 || 196.58% | 196.58% |
+---++------------+------------++---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------++---------+---------+

@adept adept self-assigned this Jan 12, 2021
@adept
Copy link
Collaborator

adept commented Jan 12, 2021

I did the same mistake just now :)

@simonmichael
Copy link
Owner

Should be fixed now by adept's #1460, @aragaer.

@aragaer
Copy link
Contributor Author

aragaer commented Jan 13, 2021

Checked it, looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. cli Command line parsing, options, arguments and suchlike. docs Documentation-related. roi
Projects
None yet
Development

No branches or pull requests

3 participants