You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cache will return any data thats less than the end_date even if its period parameter asked for something else.
>>> from tools import api
>>> [(m.report_period, m.period) for m in api.get_financial_metrics('TSLA', end_date='2025-04-03', period='annual')]
[('2024-12-31', 'annual'), ('2023-12-31', 'annual'), ('2022-12-31', 'annual'), ('2021-12-31', 'annual'), ('2020-12-31', 'annual'), ('2019-12-31', 'annual'), ('2018-12-31', 'annual'), ('2017-12-31', 'annual'), ('2016-12-31', 'annual'), ('2015-12-31', 'annual')]
>>> [(m.report_period, m.period) for m in api.get_financial_metrics('TSLA', end_date='2025-04-03', period='quarterly')]
[('2024-12-31', 'annual'), ('2023-12-31', 'annual'), ('2022-12-31', 'annual'), ('2021-12-31', 'annual'), ('2020-12-31', 'annual'), ('2019-12-31', 'annual'), ('2018-12-31', 'annual'), ('2017-12-31', 'annual'), ('2016-12-31', 'annual'), ('2015-12-31', 'annual')]
Since the first call asked for the period to be annual, thats the data stored in the cache. If I execute the call again asking for quarterly results, it will just get the annual results from the cache and return those instead.
cache only merges on report_period, ignoring differences between ttm and quarterly results
If the first issue was fixed by knowing that different keys (report_period) will be returned by using period annual and quarterly/ttm, it will expose this second issue. For some api calls such as tools.api.get_financial_metrics, the call supports annual, ttm, and quarterly values for the period param. If you choose ttm or quarterly, the report_period will be the same, but the values will be different, so they need to be cached separately.
>>> [(m.report_period, m.revenue_growth) for m in api.get_financial_metrics('TSLA', end_date='2025-04-03', period='quarterly')]
[('2024-12-31', 0.020848224922563736), ('2024-09-30', -0.012470588235294117), ('2024-06-30', 0.1971268954509178), ('2024-03-31', -0.15361385941908054), ('2023-12-31', 0.07781584582441113), ('2023-09-30', -0.06326473302041963), ('2023-06-30', 0.06849843542372155), ('2023-03-31', -0.0406694629492557), ('2022-12-31', 0.13349491936235666), ('2022-09-30', 0.2669186252509744)]
>>> [(m.report_period, m.revenue_growth) for m in api.get_financial_metrics('TSLA', end_date='2025-04-03', period='ttm')]
[('2024-12-31', 0.0055584148224395264), ('2024-09-30', 0.019219874525273295), ('2024-06-30', 0.006047812549474906), ('2024-03-31', -0.020956258460521012), ('2023-12-31', 0.008850756849172262), ('2023-09-30', 0.020164206406602287), ('2023-06-30', 0.09290405067705004), ('2023-03-31', 0.05613660356976259), ('2022-12-31', 0.0881476831011314), ('2022-09-30', 0.11459667093469911)]
I think the solution is to take the period param into account when caching results.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
I think I found 2 problems with the cache
Since the first call asked for the period to be
annual
, thats the data stored in the cache. If I execute the call again asking forquarterly
results, it will just get the annual results from the cache and return those instead.If the first issue was fixed by knowing that different keys (report_period) will be returned by using period
annual
andquarterly
/ttm
, it will expose this second issue. For some api calls such astools.api.get_financial_metrics
, the call supportsannual
,ttm
, andquarterly
values for the period param. If you choosettm
orquarterly
, thereport_period
will be the same, but the values will be different, so they need to be cached separately.I think the solution is to take the period param into account when caching results.
The text was updated successfully, but these errors were encountered: