Hi, I've tried extending bean-price to have a --update option which can be 
found at https://bitbucket.org/seltzered/beancount/branch/bean-price-update 
. Essentially it will look at commodity lifetimes and the last fetched 
price to fetch up to (but not including) the present date.

The motivations for this were:
  - Previously it seemed like most would write their own bespoke script for 
price updates.
  - It seemed like others had interest in a --update feature- see Johannes 
Harms comments in 
https://bitbucket.org/blais/beancount/issues/329/bean-price-support-fetch-over-range-of
 
I initially had a branch for specifying a "--date-range" option but having 
something that looked into commodity lifetimes and prices to find the dates 
to update seemed more useful.
  - There was some hinting of a making a 'historical price fetcher' routine 
in lifetimes.py already. There's also been experiments like 
fetch-lifetime-prices.py.

Features:
  - By default it fetches for 'weekday' prices, but one can set the 
--update-rate to 'weekly' or 'daily' instead.
  - You can use the existing --date option to fetch up to a specific final 
date. Could be helpful if you really want to fetch inclusive of today.
  - You can use the --update-compress or --inactive options to fetch prices 
during times where you're not holding a given commodity.

Edge cases & current drawbacks (much of the logic is in the 
'get_price_jobs_up_to_date' method in find_prices.py):
  - For a given commodity, the update looks for the latest price date to 
start updating from, it doesn't try to do any advance 'filling' across 
multiple gaps of missing prices, though that doesn't seem like a typical 
usecase.
  - If you use --inactive with a commodity that has never been held, it 
will currently try to fetch prices from the commodity directive's date. 
Open to feedback as to whether this should be done or not.
  - I'm not sure how to handle commodities that don't have a price source 
listed - right now those will just throw up error messages. Perhaps an 
--ignore-undeclared-source option?


So far the testing has just been through unit tests & my personal ledger 
file, so would love to hear if anyone else tries this out. I don't seem 
have pullrequest access so perhaps Martin can merge it in if it seems 
suitable.

-Vivek

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/6e59463d-940f-412d-add3-972350286f16%40googlegroups.com.

Reply via email to