Alpha Vantage API additions

62 views
Skip to first unread message

aa...@axvig.com

unread,
Apr 7, 2025, 10:54:27 PM4/7/25
to Beancount
So my Yahoo price updates have been toast for a couple months now and
I'm looking for something different. Might as well try Alpha Vantage.
I found that it could only retrieve the most recent price.

So I built out the get_historical_price function for that, and it does
work. Code here:
https://github.com/aaronaxvig/beanprice/blob/master/beanprice/sources/alphavantage.py#L111
At least it did work until I ran into the API limit this evening and I
had a few minor changes made after that...but probably is fine.

I do plan to add tests and do a pull request soon.

In the meantime, the reason for this email is an architecture question.
The free API always returns 100 (most recent) price values. So it
seemed inefficient to be dumping 99 values every single time I was
looking up a historic value. And then of course I ran into the 25 API
calls per day rate limit which added an actual need to solve that
inefficiency.

The idea would be to save all 100 values into the cache even when only
one is requested. This would seamlessly provide a pretty good and
efficient experience. My first idea was to make get_historical_price
able to return either a SourcePrice or a List[SourcePrice].
get_prices_series of course was the inspiration there for the latter.
This seems a little messy though and would require some handling in
price.py around the two existing "source.get_historical_price(symbol,
time)" lines. Then other source.py implementations could choose to
return the List sometimes too...completely optional.

Is this dumb?

I couldn't find anywhere that called get_price_series (implemented in
yahoo.py, for example) to get ideas.

The easy answer that kind of sucks, of course: implement the get price
series function and tell people to use that instead.

Marcus Read

unread,
Apr 8, 2025, 8:00:52 AM4/8/25
to bean...@googlegroups.com
Hi Aaron

I'm a beancount user and also own and maintain the market_prices library which I use for getting price data. There are no rate limits and you can be very specific about what you're after. The data is from Yahoo (from what I've ever been able to tell, the data from Yahoo and Alpha Vantage is one and the same).

I mention it only as a possible useful source for price data - there's no public interface to generate price directives and I've never sought to integrate it with `beanprice`.

Hope you might find it useful.

Cheers
Marcus

--
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 beancount+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/beancount/38bc65bb26b36b3068e2b039742f419f%40axvig.com.

fin

unread,
Apr 8, 2025, 12:00:43 PM4/8/25
to bean...@googlegroups.com
aaron via Beancount wrote:

i have been using the --no-cache option to bean-price
and been able to get prices (using all recent versions
of beancount, beanprice).

...

fin

Reply all
Reply to author
Forward
0 new messages