mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 11:52:43 +03:00
doc: cookbook: prices example
This commit is contained in:
parent
a30583f6a1
commit
046b443da5
1
Shake.hs
1
Shake.hs
@ -146,6 +146,7 @@ main = do
|
||||
,"site/csv-import.md"
|
||||
,"site/account-aliases.md"
|
||||
,"site/account-separator.md"
|
||||
,"site/investments.md"
|
||||
]
|
||||
|
||||
-- cookbook pages combined, ready for web output by hakyll
|
||||
|
@ -97,6 +97,7 @@ Practical user recipes, including:
|
||||
[Convert CSV files](csv-import.html)\
|
||||
[Rewrite account names](account-aliases.html)\
|
||||
[Use another account separator character](account-separator.html)\
|
||||
[Track investments](investments.html)\
|
||||
|
||||
</div>
|
||||
|
||||
|
64
site/investments.md
Normal file
64
site/investments.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Track investments
|
||||
|
||||
A simple example using [prices](/journal.html#prices):
|
||||
|
||||
```journal
|
||||
2017/1/1 opening balances
|
||||
(assets:depot) $3000
|
||||
|
||||
2017/1/2 buy shares at $200
|
||||
; let's assume no fees
|
||||
assets:shares 10 TSLA @ $200 ; transaction/purchase price
|
||||
assets:depot
|
||||
|
||||
; market price, has jumped since yesterday's purchase!
|
||||
P 2017/1/3 TSLA $250
|
||||
```
|
||||
|
||||
Some reports.
|
||||
We start with $3000.
|
||||
After the 1/2 purchase, we have $1000 remaining and 10 TSLA shares:
|
||||
```shell
|
||||
$ hledger -f t.j bal assets --flat -HD
|
||||
Ending balances (historical) in 2017/01/01-2017/01/02:
|
||||
|
||||
|| 2017/01/01 2017/01/02
|
||||
===============++============================
|
||||
assets:depot || $3000 $1000
|
||||
assets:shares || 0 10 TSLA
|
||||
---------------++----------------------------
|
||||
|| $3000 $1000, 10 TSLA
|
||||
```
|
||||
|
||||
Show the shares's value at cost, with [`-B/--cost`](/hledger.html#reporting-options):
|
||||
```shell
|
||||
$ hledger -f t.j bal assets --flat -HD -B
|
||||
Ending balances (historical) in 2017/01/01-2017/01/02:
|
||||
|
||||
|| 2017/01/01 2017/01/02
|
||||
===============++=========================
|
||||
assets:depot || $3000 $1000
|
||||
assets:shares || 0 $2000
|
||||
---------------++-------------------------
|
||||
|| $3000 $3000
|
||||
```
|
||||
|
||||
Show the shares's value using the latest applicable market price,
|
||||
with [`-V/--value`](/hledger.html#market-value).
|
||||
A $500 capital gain is apparent in the totals:
|
||||
```shell
|
||||
$ hledger -f t.j bal assets --flat -HD -V
|
||||
Ending balances (historical) in 2017/01/01-2017/01/02:
|
||||
|
||||
|| 2017/01/01 2017/01/02
|
||||
===============++=========================
|
||||
assets:depot || $3000 $1000
|
||||
assets:shares || 0 $2500
|
||||
---------------++-------------------------
|
||||
|| $3000 $3500
|
||||
```
|
||||
|
||||
This is about the limit of hledger's
|
||||
[value-reporting](https://github.com/simonmichael/hledger/issues/131)
|
||||
[abilities](https://github.com/simonmichael/hledger/issues/329),
|
||||
currently.
|
Loading…
Reference in New Issue
Block a user