ValueRaider/yfinance-cache

[Feature Request] Utilize Cache for Custom Historical Data

Closed this issue · 4 comments

It would be super useful to have an interface for storing custom historical data inside the cache, so that expensive sums of historical data for portfolios would not have to be computed repeatedly or stored using another method, and so they can benefit from the aging/cache validation mechanism.

This could probably be done by allowing the user to register a custom ticker along with a custom fetch function for when the price needs to be updated for a given date.

This is a great package by the way, good job on all of the work so far!

Do you have a specific scenario?

When you need to get the historical value of a portfolio of stocks over time, to get the total value of the portfolio you would need to sum up the individual values for all the stocks, regardless of if they were cached or not. If you need to do this repeatedly (i.e. hosting an api) the calculations add up

You might be overestimating the cost of Numpy summing a few thousand values.

Have you tried using FetchDate to implement your caching layer on top of YFC? if df["FetchDate"].iloc[-1] > lastCalcDate ...

I dont know much about the performance of Numpy, you are probably right about the overestimation. In that case caching would be more effort than it is worth. Thanks for the quick response!