hledger-2.0: Hledger/Cli/Commands/Prices.txt
prices
Print the market prices declared with P directives. With
--infer-market-prices, also show any additional prices inferred from
costs. With --show-reverse, also show additional prices inferred by
reversing known prices. With --show-aliases, also show the exchange
rates provided by commodity aliases.
Flags:
--show-reverse also show the prices inferred by reversing known
prices
--show-aliases also show the exchange rates provided by
commodity aliases
--summary summarise declared prices per commodity instead
of listing them
--locations also show where prices where declared
With --locations, each price line gets a trailing ; location: FILE:LINE
comment showing where it came from. Declared prices point at their P
directive; prices inferred from costs point at the parent transaction's
first line. Reversed prices keep the source position of the directive
they were derived from.
With --show-aliases, each commodity alias which provides an exchange
rate (between a commodity and its alias, when there are no market prices
between them) is shown as a price dated 0000-01-01 with a
; commodity alias comment. Its location is the commodity directive which
declared the alias. These are used only when market prices can't provide
a conversion, see Finding market price.
Price amounts are always displayed with their full precision, except for
reverse prices which are limited to 8 decimal digits.
Prices can be filtered by a date:, cur:, amt: or find: query.
Generally if you run this command with --infer-market-prices
--show-reverse --show-aliases, it will show the same prices used
internally to calculate value reports. But if in doubt, you can inspect
those directly by running the value report with --debug=2.
Examples:
$ hledger prices
P 2024-01-01 AAPL $150
P 2024-02-01 AAPL $160
P 2024-02-01 EUR $1.08
$ hledger prices --infer-market-prices
P 2024-01-01 AAPL $150
P 2024-01-05 AAPL $150
P 2024-02-01 AAPL $160
P 2024-02-01 EUR $1.08
prices summary
With --summary, instead of listing individual prices, prices prints one
row per commodity used in the journal (other than the base currency),
with the following columns:
- Commodity — the commodity, as an ISO 4217 code if possible.
- Prices — the number of market price declarations for that commodity.
- Earliest / Latest — the date range of those prices.
- Period — the duration between earliest and latest.
- Coverage — the percentage of weekdays in that period that have a price
declared (or blank when fewer than two prices).
Summary mode is a quick way to spot gaps in your price data, and pairs
naturally with getprices. Only prices declared with P directives are
counted; prices inferred with --show-reverse or --infer-market-prices
are ignored.
Queries (cur:, date:, amt:, find:) can be used to narrow the prices that
are summarised.