Skip to content

Commit 37e49ad

Browse files
committed
cli: rename --infer-value to --infer-market-price
For clarity; infer-value was too vague. The old spelling remains supported for compatibility, but is now deprecated. When typing, --infer-market or even --infer (for now) is sufficient.
1 parent 681965e commit 37e49ad

File tree

9 files changed

+58
-56
lines changed

9 files changed

+58
-56
lines changed

doc/common.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ m4_define({{_reportingoptions_}}, {{
158158
`--value`
159159
: convert amounts to cost or market value, more flexibly than -B/-V/-X
160160

161-
`--infer-value`
162-
: with -V/-X/--value, also infer market prices from transactions
161+
`--infer-market-prices`
162+
: use transaction prices (recorded with @ or @@) as additional market prices, as if they were P directives
163163

164164
`--auto`
165165
: apply [automated posting rules](hledger.html#auto-postings) to modify transactions.

hledger-lib/Hledger/Data/Valuation.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ prefix l = if null l then (""++) else ((l++": ")++)
365365
--
366366
-- 1. A *declared market price* or *inferred market price*:
367367
-- A's latest market price in B on or before the valuation date
368-
-- as declared by a P directive, or (with the `--infer-value` flag)
368+
-- as declared by a P directive, or (with the `--infer-market-price` flag)
369369
-- inferred from transaction prices.
370370
--
371371
-- 2. A *reverse market price*:
@@ -390,7 +390,7 @@ prefix l = if null l then (""++) else ((l++": ")++)
390390
-- prices before the valuation date.)
391391
--
392392
-- 3. If there are no P directives at all (any commodity or date), and
393-
-- the `--infer-value` flag is used, then the price commodity from
393+
-- the `--infer-market-price` flag is used, then the price commodity from
394394
-- the latest transaction price for A on or before valuation date."
395395
--
396396
makePriceGraph :: [MarketPrice] -> [MarketPrice] -> Day -> PriceGraph
@@ -429,7 +429,7 @@ makePriceGraph alldeclaredprices allinferredprices d =
429429
where
430430
ps | not $ null visibledeclaredprices = visibledeclaredprices
431431
| not $ null alldeclaredprices = alldeclaredprices
432-
| otherwise = visibleinferredprices -- will be null without --infer-value
432+
| otherwise = visibleinferredprices -- will be null without --infer-market-price
433433

434434
-- | Given a list of P-declared market prices in parse order and a
435435
-- list of transaction-inferred market prices in parse order, select

hledger-lib/Hledger/Reports/ReportOptions.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ rawOptsToReportOpts rawopts = do
185185
,statuses_ = statusesFromRawOpts rawopts
186186
,cost_ = costing
187187
,value_ = valuation
188-
,infer_value_ = boolopt "infer-value" rawopts
188+
,infer_value_ = boolopt "infer-market-price" rawopts
189189
,depth_ = maybeposintopt "depth" rawopts
190190
,date2_ = boolopt "date2" rawopts
191191
,empty_ = boolopt "empty" rawopts

hledger/Hledger/Cli/CliOptions.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ reportflags = [
176176
,"'now': convert to current market value, in default valuation commodity or COMM"
177177
,"YYYY-MM-DD: convert to market value on the given date, in default valuation commodity or COMM"
178178
])
179-
,flagNone ["infer-value"] (setboolopt "infer-value") "with -V/-X/--value, also infer market prices from transactions"
179+
-- XXX infer-value renamed to infer-market-price and deprecated 2021-02
180+
,flagNone ["infer-market-price","infer-value"] (setboolopt "infer-market-price")
181+
"use transaction prices (recorded with @ or @@) as additional market prices, as if they were P directives"
180182

181183
-- generated postings/transactions
182184
,flagNone ["auto"] (setboolopt "auto") "apply automated posting rules to modify transactions"

hledger/Hledger/Cli/Commands/Roi.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ unMix a =
273273
Just a -> aquantity a
274274
Nothing -> error' $ "Amounts could not be converted to a single cost basis: " ++ show (map showAmount $ amounts a) ++
275275
"\nConsider using --value to force all costs to be in a single commodity." ++
276-
"\nFor example, \"--cost --value=end,<commodity> --infer-value\", where commodity is the one that was used to pay for the investment."
276+
"\nFor example, \"--cost --value=end,<commodity> --infer-market-price\", where commodity is the one that was used to pay for the investment."
277277

278278
-- Show Decimal rounded to two decimal places, unless it has less places already. This ensures that "2" won't be shown as "2.00"
279279
showDecimal :: Decimal -> String

hledger/hledger.m4.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ in this order of preference
769769
1. A *declared market price* or *inferred market price*:
770770
A's latest market price in B on or before the valuation date
771771
as declared by a [P directive](hledger.html#declaring-market-prices),
772-
or (with the `--infer-value` flag)
772+
or (with the `--infer-market-price` flag)
773773
inferred from [transaction prices](hledger.html#transaction-prices).
774774
<!-- (Latest by date, then parse order.) -->
775775
<!-- (A declared price overrides an inferred price on the same date.) -->
@@ -792,7 +792,7 @@ visible in `--debug=2` output). That limit is currently 1000.
792792

793793
Amounts for which no suitable market price can be found, are not converted.
794794

795-
## --infer-value: market prices from transactions
795+
## --infer-market-price: market prices from transactions
796796

797797
Normally, market value in hledger is fully controlled by, and requires,
798798
[P directives](hledger.html#declaring-market-prices) in your journal.
@@ -802,16 +802,16 @@ why not use the recorded [transaction prices](hledger.html#transaction-prices)
802802
as additional market prices (as Ledger does) ?
803803
We could produce value reports without needing P directives at all.
804804

805-
Adding the `--infer-value` flag to `-V`, `-X` or `--value` enables
806-
this. So for example, `hledger bs -V --infer-value` will get market
805+
Adding the `--infer-market-price` flag to `-V`, `-X` or `--value` enables
806+
this. So for example, `hledger bs -V --infer-market-price` will get market
807807
prices both from P directives and from transactions.
808808

809809
There is a downside: value reports can sometimes be affected in
810810
confusing/undesired ways by your journal entries. If this happens to
811811
you, read all of this [Valuation](#valuation) section carefully,
812812
and try adding `--debug` or `--debug=2` to troubleshoot.
813813

814-
`--infer-value` can infer market prices from:
814+
`--infer-market-price` can infer market prices from:
815815

816816
- multicommodity transactions with explicit prices (`@`/`@@`)
817817

@@ -840,15 +840,15 @@ follows, in this order of preference:
840840
prices before the valuation date.)
841841

842842
3. If there are no P directives at all (any commodity or date) and the
843-
`--infer-value` flag is used: the price commodity from the latest
843+
`--infer-market-price` flag is used: the price commodity from the latest
844844
transaction-inferred price for A on or before valuation date.
845845

846846
This means:
847847

848848
- If you have [P directives](hledger.html#declaring-market-prices),
849849
they determine which commodities `-V` will convert, and to what.
850850

851-
- If you have no P directives, and use the `--infer-value` flag,
851+
- If you have no P directives, and use the `--infer-market-price` flag,
852852
[transaction prices](hledger.html#transaction-prices) determine it.
853853

854854
Amounts for which no valuation commodity can be found are not converted.

hledger/test/journal/valuation2.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ $ hledger -f- bal -N -V -e 2002-01-01
232232
$ hledger -f- bal -N -V
233233
1 A a
234234

235-
# 23. Market price is inferred from transactions with --infer-value,
235+
# 23. Market price is inferred from transactions with --infer-market-price,
236236
# and -V can work with no P directives.
237-
$ hledger -f- bal -N -V --infer-value
237+
$ hledger -f- bal -N -V --infer-market-price
238238
B2 a
239239

240240
# 24. A P-declared market price on the same date as a transaction price has precedence.
@@ -244,7 +244,7 @@ P 2020-01-01 A 1 B
244244
2020-01-01
245245
(a) 1 A @ 2 B
246246

247-
$ hledger -f- bal -N -V --infer-value
247+
$ hledger -f- bal -N -V --infer-market-price
248248
1 B a
249249

250250
# 25. A transaction-inferred price newer than a P-declared price has precedence.
@@ -254,7 +254,7 @@ P 2020-01-01 A 1 B
254254
2020-01-02
255255
(a) 1 A @ 2 B
256256

257-
$ hledger -f- bal -N -V --infer-value
257+
$ hledger -f- bal -N -V --infer-market-price
258258
2 B a
259259

260260
# 26. A later-dated P directive sets the valuation commodity even if parsed out of order.
@@ -275,7 +275,7 @@ $ hledger -f- bal -N -V
275275
(a) 1 A @ 1 D ; date: 2020-01-02
276276
(a) 1 A @ 1 B
277277

278-
$ hledger -f- bal -N -V --infer-value
278+
$ hledger -f- bal -N -V --infer-market-price
279279
D3 a
280280

281281
# 28. #1402 It should pick the direct (forward) A 3.00 price for B here,

hledger/test/roi.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
240240
>>>2
241241
hledger: Amounts could not be converted to a single cost basis: ["10 B","-10 B @@ 100 A"]
242242
Consider using --value to force all costs to be in a single commodity.
243-
For example, "--cost --value=end,<commodity> --infer-value", where commodity is the one that was used to pay for the investment.
243+
For example, "--cost --value=end,<commodity> --infer-market-price", where commodity is the one that was used to pay for the investment.
244244
>>>=1
245245

246246
# 10. Forcing valuation via --value
247-
hledger -f- roi -p 2019-11 --inv Investment --pnl PnL --cost --value=then,A --infer-value
247+
hledger -f- roi -p 2019-11 --inv Investment --pnl PnL --cost --value=then,A --infer-market-price
248248
<<<
249249
2019/11/01 Example
250250
Assets:Checking -100 A

0 commit comments

Comments
 (0)