You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the roi-command for the yearly ROI results in:
$> hledger -f test.journal roi --inv assets:stocks --pnl "expenses:|revenues:" -V -Y
hledger: Ratio has zero denominator
The monthly one works, though:
$> hledger -f test.journal roi --inv assets:stocks --pnl "expenses:|revenues:" -V -M --cashflow
IRR cash flow for 2022-02-01 - 2022-02-28
+------------++-----------+
||| Amount |
+============++===========+
| 2022-02-01 || € -101,00 || 2022-03-01 || € 101,00 |
+------------++-----------+
TWR cash flow for 2022-02-01 - 2022-02-28
+------------++-----------------+--------------++---------+----------+------------+-------++------------------+
||| Portfolio value | Unit balance || Pnl | Cashflow | Unit price | Units || New Unit Balance |
+============++=================+==============++=========+==========+============+=======++==================+
| 2022-02-01 || 0 | 0 || 0 | € 101,00 | 100 | 1.01 || 1.01 || 2022-02-01 || 0 | 1.01 || € -1,00 | 0 | -0.99 | 0 || 1.01 || 2022-02-28 || 101 | 1.01 || 0 | 0 | -0.99 | 0 || 1.01 |
+------------++-----------------+--------------++---------+----------+------------+-------++------------------+
Final unit price: € 101,00/1.01 units = 100
Total TWR: 0.00%.
Period: 0.08 years.
Annualized TWR: 0.00%
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
||| Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=======+=======+
| 1 || 2022-02-01 | 2022-02-28 || 0 | € 101,00 | € 101,00 | 0 || 0.00% | 0.00% |
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
I identified the issue to be caused by the assets:stocks account being empty and having expenses right in the first transaction.
Splitting the purchase as follows, makes the yearly ROI work:
hledger on macOS, installed via homebrew; latest version from brew
$> hledger --version hledger 1.24.1, mac-x86_64
I want to track stock purchases together with potential trading fees.
Minimum example:
Using the
roi
-command for the yearly ROI results in:The monthly one works, though:
I identified the issue to be caused by the
assets:stocks
account being empty and having expenses right in the first transaction.Splitting the purchase as follows, makes the yearly ROI work:
Note, that the expense has to happen on the next day. Putting it on the same day or before the purchase still results in the error.
Furthermore, the command works, if the account isn't initially empty. The following works:
The init-amount doesn't even have to be positive. Negative amounts work, too. Only the zero causes an issue here.
When looking at the cashflow with
--cashflow
, it seems, that the expense is always considered first and the actual cashflow last:As stated in the title, it also happens when there's a revenue instead of or in addition to an expense.
The text was updated successfully, but these errors were encountered: