Automatic Market Prices Download#
Hledger-lots can download daily market prices from Yahoo Finance and output as market price directive, so you get updated xirr calculation and run regular hledger reports using market prices.
Setup#
Add a yahoo_ticker tag to the comment of a commodity directive with the value of the ticker in Yahoo Finance.
IMPORTANT: You may need to add double quotes between the commodity name because hledger accepts only word characters without it
Examples:#
commodity AAPL ; yahoo_ticker:AAPL
commodity "PETR4" ; yahoo_ticker:PETR4.SA
commodity BTC ; yahoo_ticker:BTC-USD
commodity EURUSD ; yahoo_ticker:EURUSD=X
For output example, see here
Downloading#
Run hledger-lots -f [journal file] prices
. For those commodities that have a yahoo_ticker tag according to the example above, hledger-lots will download daily historical prices in a date range according to the rule below, so the user doesn't need to care about start and end dates.
Condition | Start Date | End Date |
---|---|---|
no market price | First Purchase | Yesterday |
have market price | Next day of the last price | Yesterday |
market price later or equal yesterday | No download | No download |
no transactions | No download | No download |