mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-10 14:16:41 +03:00
228 lines
7.4 KiB
Plaintext
228 lines
7.4 KiB
Plaintext
# 1. investment that does not grow has no return
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-06-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++=======+=======+
|
|
| 1 || 2017-01-01 | 2017-12-31 || 0 | 200 | 200 | 0 || 0.00% | 0.00% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
|
|
|
>>>=0
|
|
|
|
# 2. Growth by 12% from single investment transaction should show 12% IRR and 12% TWR
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $112
|
|
pnl
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++========+========+
|
|
| 1 || 2017-01-01 | 2017-12-31 || 0 | 100 | 112 | 12 || 12.00% | 12.00% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
|
|
>>>=0
|
|
|
|
# 3. Same as (2), but grow by 1% per month
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-01-31 investment valuation
|
|
investment = $101
|
|
pnl
|
|
|
|
2017-02-28 investment valuation
|
|
investment = $102
|
|
pnl
|
|
|
|
2017-03-31 investment valuation
|
|
investment = $103
|
|
pnl
|
|
|
|
2017-04-30 investment valuation
|
|
investment = $104
|
|
pnl
|
|
|
|
2017-05-31 investment valuation
|
|
investment = $105
|
|
pnl
|
|
|
|
2017-06-30 investment valuation
|
|
investment = $106
|
|
pnl
|
|
|
|
2017-07-31 investment valuation
|
|
investment = $107
|
|
pnl
|
|
|
|
2017-08-31 investment valuation
|
|
investment = $108
|
|
pnl
|
|
|
|
2017-09-30 investment valuation
|
|
investment = $109
|
|
pnl
|
|
|
|
2017-10-31 investment valuation
|
|
investment = $110
|
|
pnl
|
|
|
|
2017-11-30 investment valuation
|
|
investment = $111
|
|
pnl
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $112
|
|
pnl
|
|
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++========+========+
|
|
| 1 || 2017-01-01 | 2017-12-31 || 0 | 100 | 112 | 12 || 12.00% | 12.00% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
|
|
>>>=0
|
|
|
|
# 4. When $100 invested over 12 month + $100 invested over 6 month yield $220, that's 10% TWR, but 12.73% IRR
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-06-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $220
|
|
pnl
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++========+========+
|
|
| 1 || 2017-01-01 | 2017-12-31 || 0 | 200 | 220 | 20 || 12.72% | 10.00% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
|
|
|
|
>>>=0
|
|
|
|
# 5. When $100 invested over 12 month + $100 invested over 6 month yield $20, that's -90% TWR, but -95.73% IRR
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-06-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $20
|
|
pnl
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+------++---------+---------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+======++=========+=========+
|
|
| 1 || 2017-01-01 | 2017-12-31 || 0 | 200 | 20 | -180 || -95.73% | -90.00% |
|
|
+---++------------+------------++---------------+----------+-------------+------++---------+---------+
|
|
|
|
>>>=0
|
|
|
|
# 6. Check that deposits/withdrawals and profit/loss are reflected in the right periods
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Q
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-06-30 investment valuation
|
|
investment = $110
|
|
pnl
|
|
|
|
2017-07-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-10-01 withdrawal
|
|
assets:cash $50
|
|
investment
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $155
|
|
pnl
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++=========+=========+
|
|
| 1 || 2017-01-01 | 2017-03-31 || 0 | 100 | 100 | 0 || 0.00% | 0.00% |
|
|
| 2 || 2017-04-01 | 2017-06-30 || 100 | 0 | 110 | 10 || 46.56% | 46.56% |
|
|
| 3 || 2017-07-01 | 2017-09-30 || 110 | 100 | 210 | 0 || 0.00% | 0.00% |
|
|
| 4 || 2017-10-01 | 2017-12-31 || 210 | -50 | 155 | -5 || -11.83% | -11.82% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
|
|
|
|
>>>=0
|
|
|
|
# 7. Check that reporting for the part of the total history of investment works
|
|
hledger -f- roi --inv investment --pnl pnl -b 2017-06 -e 2018
|
|
<<<
|
|
2017-01-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-06-30 investment valuation
|
|
investment = $110
|
|
pnl
|
|
|
|
2017-07-01 investment
|
|
assets:cash -$100
|
|
investment
|
|
|
|
2017-10-01 withdrawal
|
|
assets:cash $50
|
|
investment
|
|
|
|
2017-12-31 investment valuation
|
|
investment = $155
|
|
pnl
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+--------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++=======+========+
|
|
| 1 || 2017-06-01 | 2017-12-31 || 100 | 50 | 155 | 5 || 5.24% | 11.45% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+--------+
|
|
|
|
>>>=0
|
|
|
|
# 8. Dont fail where there is no rate-of-return
|
|
hledger -f- roi -p 2019-11
|
|
<<<
|
|
2019/11/01 Example
|
|
Assets:Checking 1
|
|
Income:Salary -1
|
|
>>>
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
|
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
|
|
+===++============+============++===============+==========+=============+=====++=======+=======+
|
|
| 1 || 2019-11-01 | 2019-11-30 || 0 | 0 | 0 | 0 || 0.00% | 0.00% |
|
|
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
|
|
|
>>>=0
|