This feature turns out to be quite involved, as valuation interacts with the many report variations. Various bugs/specs have been fixed/clarified relating to register's running total, balance totals etc. Eg register's total should now be the sum of the posting amount values, not the values of the original sums. Current level of support has been documented. When valuing at transaction date, we once again do early valuation of all posting amounts, to get more correct results. variants. This means --value-at=t can be slower than other valuation modes when there are many transactions and many prices. This could be revisited for optimisation when things are more settled.
360 lines
9.3 KiB
Plaintext
360 lines
9.3 KiB
Plaintext
# http://hledger.org/journal.html#market-prices
|
|
# http://hledger.org/hledger.html#market-value
|
|
|
|
# 1. Market prices are ignored by -B.
|
|
<
|
|
P 2011/01/01 € $1.35
|
|
|
|
2011/01/01
|
|
expenses:foreign €100
|
|
assets
|
|
|
|
$ hledger -f- bal -NB
|
|
€-100 assets
|
|
€100 expenses:foreign
|
|
|
|
|
|
# 2. Market prices are used by bal -V.
|
|
# Market prices for other commodities are not used.
|
|
# Nor are transaction prices.
|
|
<
|
|
P 2011/01/01 € $1.35
|
|
P 2011/01/01 GBP $1.35
|
|
|
|
2011/01/01
|
|
(expenses:foreign) €100 @ $1.20
|
|
|
|
$ hledger -f- bal -N -V
|
|
$135.00 expenses:foreign
|
|
|
|
|
|
# 3. The location of price directives does not matter.
|
|
# If multiple directives have the same date, the last parsed is used.
|
|
<
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
P 2000/1/1 $ €1.35
|
|
|
|
3000/03/03
|
|
(b) $100
|
|
|
|
P 2000/1/1 $ €1.30
|
|
|
|
$ hledger -f- bal -N -V a
|
|
€130.00 a
|
|
|
|
|
|
# 4. Market prices in the future (later than today's date) are ignored by default. #453, #683
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
P 3000/1/1 $ €1.30
|
|
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
$ hledger -f- bal -N -V
|
|
€120.00 a
|
|
|
|
|
|
# 5. Market prices in the future are still ignored by default even
|
|
# with an explicit future report end date, unlike hledger 1.14-.
|
|
<
|
|
P 3000/1/1 $ €1.10
|
|
|
|
3000/01/01
|
|
(a) $100
|
|
|
|
$ hledger -f- bal -N -V -e 3000/2
|
|
$100 a
|
|
|
|
|
|
# 6. Market prices interact with D directives and with amount style canonicalisation. #131
|
|
<
|
|
|
|
D 1000.00 H ; declare a default commodity named H
|
|
|
|
P 2015/08/14 EEEE 41.66 ; default commodity H is used for these market prices
|
|
P 2015/08/14 FFFF 74.62
|
|
P 2015/08/14 GGGG 32.39
|
|
|
|
2015/08/15
|
|
a 2.4120 EEEE @@ 100 ; default commodity H is used for these transaction prices
|
|
a 0.3350 FFFF @@ 25
|
|
a 0.7718 GGGG @@ 25
|
|
b ; implicit balancing amount is in the cost commodity, H
|
|
|
|
$ hledger -f- balance -V
|
|
150.48 H a
|
|
-150.00 H b
|
|
--------------------
|
|
0.48 H
|
|
|
|
|
|
# 7. register -V affects posting amounts and total.
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
2000/1/1
|
|
(a) $100
|
|
|
|
$ hledger -f- reg -V
|
|
2000/01/01 (a) €120.00 €120.00
|
|
|
|
|
|
# 8. print -V affects posting amounts but not balance assertions.
|
|
<
|
|
P 2000/1/1 $ €1.20
|
|
2000/1/1
|
|
(a) $100 = $100
|
|
|
|
$ hledger -f- print -V
|
|
2000/01/01
|
|
(a) €120.00 = $100
|
|
|
|
>=0
|
|
|
|
# --value-at tests
|
|
|
|
<
|
|
P 2000/01/01 A 1 B
|
|
P 2000-01-15 A 5 B
|
|
P 2000/02/01 A 2 B
|
|
P 2000/03/01 A 3 B
|
|
P 2000/04/01 A 4 B
|
|
|
|
2000/01/01
|
|
(a) 1 A
|
|
|
|
2000/02/01
|
|
(a) 1 A
|
|
|
|
2000/03/01
|
|
(a) 1 A
|
|
|
|
# print
|
|
|
|
# 9. print value using prices on transaction (posting) dates
|
|
$ hledger -f- print --value-at=transaction
|
|
2000/01/01
|
|
(a) 1 B
|
|
|
|
2000/02/01
|
|
(a) 2 B
|
|
|
|
2000/03/01
|
|
(a) 3 B
|
|
|
|
>=0
|
|
|
|
# 10. print value using prices on last day of report period (2000-02-29)
|
|
$ hledger -f- print --value-at=period date:2000/01-2000/03
|
|
2000/01/01
|
|
(a) 2 B
|
|
|
|
2000/02/01
|
|
(a) 2 B
|
|
|
|
>=0
|
|
|
|
# 11. print value using prices on last day of report period (no period specified)
|
|
# specified - uses last day of journal (2000-03-01)
|
|
$ hledger -f- print --value-at=period
|
|
2000/01/01
|
|
(a) 3 B
|
|
|
|
2000/02/01
|
|
(a) 3 B
|
|
|
|
2000/03/01
|
|
(a) 3 B
|
|
|
|
>=0
|
|
|
|
# 12. print value using prices on a specified date
|
|
$ hledger -f- print --value-at=2000-01-15
|
|
2000/01/01
|
|
(a) 5 B
|
|
|
|
2000/02/01
|
|
(a) 5 B
|
|
|
|
2000/03/01
|
|
(a) 5 B
|
|
|
|
>=0
|
|
|
|
# 13. print value using prices today
|
|
# (assuming today's date is >= 2000-04-01)
|
|
$ hledger -f- print --value-at=now
|
|
2000/01/01
|
|
(a) 4 B
|
|
|
|
2000/02/01
|
|
(a) 4 B
|
|
|
|
2000/03/01
|
|
(a) 4 B
|
|
|
|
>=0
|
|
|
|
# register
|
|
|
|
# 14. register report valued at transaction.
|
|
# Shows the running total of the posting amount values (not the values
|
|
# of the running total).
|
|
$ hledger -f- reg --value-at=transaction
|
|
2000/01/01 (a) 1 B 1 B
|
|
2000/02/01 (a) 2 B 3 B
|
|
2000/03/01 (a) 3 B 6 B
|
|
|
|
# 15. register report valued at period end
|
|
$ hledger -f- reg --value-at=period
|
|
2000/01/01 (a) 3 B 3 B
|
|
2000/02/01 (a) 3 B 6 B
|
|
2000/03/01 (a) 3 B 9 B
|
|
|
|
# 16. register report valued at specified date
|
|
$ hledger -f- reg --value-at=2000-01-15
|
|
2000/01/01 (a) 5 B 5 B
|
|
2000/02/01 (a) 5 B 10 B
|
|
2000/03/01 (a) 5 B 15 B
|
|
|
|
# 17. register report valued today
|
|
$ hledger -f- reg --value-at=now
|
|
2000/01/01 (a) 4 B 4 B
|
|
2000/02/01 (a) 4 B 8 B
|
|
2000/03/01 (a) 4 B 12 B
|
|
|
|
# 18. register report valued at default date (same as above)
|
|
$ hledger -f- reg -V
|
|
2000/01/01 (a) 4 B 4 B
|
|
2000/02/01 (a) 4 B 8 B
|
|
2000/03/01 (a) 4 B 12 B
|
|
|
|
# register, periodic
|
|
|
|
# 19. periodic register report valued at transaction
|
|
$ hledger -f- reg --value-at=transaction -M
|
|
2000/01 a 1 B 1 B
|
|
2000/02 a 2 B 3 B
|
|
2000/03 a 3 B 6 B
|
|
|
|
# 20. periodic register report valued at period end
|
|
$ hledger -f- reg --value-at=period -M
|
|
>2 /not yet supported/
|
|
>=1
|
|
# XXX
|
|
# 2000/01 a 5 B 5 B
|
|
# 2000/02 a 2 B 7 B
|
|
# 2000/03 a 3 B 10 B
|
|
|
|
# 21. periodic register report valued at specified date
|
|
$ hledger -f- reg --value-at=2000-01-15 -M
|
|
2000/01 a 5 B 5 B
|
|
2000/02 a 5 B 10 B
|
|
2000/03 a 5 B 15 B
|
|
|
|
# 22. periodic register report valued today
|
|
$ hledger -f- reg --value-at=now -M
|
|
2000/01 a 4 B 4 B
|
|
2000/02 a 4 B 8 B
|
|
2000/03 a 4 B 12 B
|
|
|
|
# 23. periodic register report valued at default date (same as above)
|
|
$ hledger -f- reg -V -M
|
|
2000/01 a 4 B 4 B
|
|
2000/02 a 4 B 8 B
|
|
2000/03 a 4 B 12 B
|
|
|
|
# balance
|
|
|
|
# 24. single column balance report valued at transaction
|
|
$ hledger -f- bal --value-at=transaction
|
|
6 B a
|
|
--------------------
|
|
6 B
|
|
|
|
# 25. single column balance report valued at period end
|
|
$ hledger -f- bal --value-at=period
|
|
9 B a
|
|
--------------------
|
|
9 B
|
|
|
|
# 26. single column balance report valued at specified date
|
|
$ hledger -f- bal --value-at=2000-01-15
|
|
15 B a
|
|
--------------------
|
|
15 B
|
|
|
|
# 27. single column balance report valued today
|
|
$ hledger -f- bal --value-at=now
|
|
12 B a
|
|
--------------------
|
|
12 B
|
|
|
|
# 28. single column balance report valued at default date (same as above)
|
|
$ hledger -f- bal -V
|
|
12 B a
|
|
--------------------
|
|
12 B
|
|
|
|
# balance, periodic
|
|
|
|
# 29. multicolumn balance report valued at transaction
|
|
$ hledger -f- bal -MTA --value-at=transaction
|
|
>2 /not yet supported/
|
|
>=1
|
|
# Balance changes in 2000q1:
|
|
#
|
|
# || Jan Feb Mar Total Average
|
|
# ===++=================================
|
|
# a || 1 B 2 B 3 B 6 B 2 B
|
|
# ---++---------------------------------
|
|
# || 1 B 2 B 3 B 6 B 2 B
|
|
|
|
# 30. multicolumn balance report valued at period end
|
|
$ hledger -f- bal -M --value-at=period
|
|
Balance changes in 2000q1:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 5 B 2 B 3 B
|
|
---++---------------
|
|
|| 5 B 2 B 3 B
|
|
|
|
# 31. multicolumn balance report valued at period end with -T or -A
|
|
$ hledger -f- bal -M --value-at=period -TA
|
|
>2 /not yet supported/
|
|
>=1
|
|
|
|
# 32. multicolumn balance report valued at other date
|
|
$ hledger -f- bal -M --value-at=2000-01-15
|
|
Balance changes in 2000q1:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 5 B 5 B 5 B
|
|
---++---------------
|
|
|| 5 B 5 B 5 B
|
|
|
|
# 33. multicolumn balance report valued today (with today >= 2000-04-01)
|
|
$ hledger -f- bal -M --value-at=now
|
|
Balance changes in 2000q1:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 4 B 4 B 4 B
|
|
---++---------------
|
|
|| 4 B 4 B 4 B
|
|
|
|
# 34. multicolumn balance report valued at default date (same as above)
|
|
$ hledger -f- bal -M -V
|
|
Balance changes in 2000q1:
|
|
|
|
|| Jan Feb Mar
|
|
===++===============
|
|
a || 4 B 4 B 4 B
|
|
---++---------------
|
|
|| 4 B 4 B 4 B
|
|
|