-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
116 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
class Cache: | ||
"""In-memory cache for API responses.""" | ||
|
||
def __init__(self): | ||
self._prices_cache: dict[str, list[dict[str, any]]] = {} | ||
self._financial_metrics_cache: dict[str, list[dict[str, any]]] = {} | ||
self._line_items_cache: dict[str, list[dict[str, any]]] = {} | ||
self._insider_trades_cache: dict[str, list[dict[str, any]]] = {} | ||
|
||
def get_prices(self, ticker: str) -> list[dict[str, any]] | None: | ||
"""Get cached price data if available.""" | ||
return self._prices_cache.get(ticker) | ||
|
||
def set_prices(self, ticker: str, data: list[dict[str, any]]): | ||
"""Cache price data.""" | ||
self._prices_cache[ticker] = data | ||
|
||
def get_financial_metrics(self, ticker: str) -> list[dict[str, any]]: | ||
"""Get cached financial metrics if available.""" | ||
return self._financial_metrics_cache.get(ticker) | ||
|
||
def set_financial_metrics(self, ticker: str, data: list[dict[str, any]]): | ||
"""Cache financial metrics data.""" | ||
self._financial_metrics_cache[ticker] = data | ||
|
||
def get_line_items(self, ticker: str) -> list[dict[str, any]] | None: | ||
"""Get cached line items if available.""" | ||
return self._line_items_cache.get(ticker) | ||
|
||
def set_line_items(self, ticker: str, data: list[dict[str, any]]): | ||
"""Cache line items data.""" | ||
self._line_items_cache[ticker] = data | ||
|
||
def get_insider_trades(self, ticker: str) -> list[dict[str, any]] | None: | ||
"""Get cached insider trades if available.""" | ||
return self._insider_trades_cache.get(ticker) | ||
|
||
def set_insider_trades(self, ticker: str, data: list[dict[str, any]]): | ||
"""Cache insider trades data.""" | ||
self._insider_trades_cache[ticker] = data | ||
|
||
|
||
# Global cache instance | ||
_cache = Cache() | ||
|
||
|
||
def get_cache() -> Cache: | ||
"""Get the global cache instance.""" | ||
return _cache | ||
return _cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.