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.