diff --git a/yfinance_plus.py b/yfinance_plus.py index 4986876..f9d9590 100644 --- a/yfinance_plus.py +++ b/yfinance_plus.py @@ -67,14 +67,18 @@ class HistoricalDataCache: def _normalize_period_to_days(self, period: str) -> int: """Convert period string to approximate days""" + if period is None: + return 30 period_map = { '1d': 1, '2d': 2, '5d': 5, '1mo': 30, '3mo': 90, '6mo': 180, '1y': 365, '2y': 730, '5y': 1825, '10y': 3650, 'ytd': 365, 'max': 36500 } - return period_map.get(period.lower(), 30) + return period_map.get(str(period).lower(), 30) def get(self, symbol: str, period: str, interval: str, start: str = None, end: str = None) -> Optional[pd.DataFrame]: """Get cached historical data if available and valid""" + if period is None: + return None with self._lock: try: # First check exact match @@ -121,6 +125,8 @@ class HistoricalDataCache: def store(self, symbol: str, period: str, interval: str, data: pd.DataFrame, start: str = None, end: str = None): """Store historical data in cache""" + if period is None: + return with self._lock: try: # Check if we already have a longer period cache that contains this data