fix(cache): period=None 시 AttributeError 수정

start/end 날짜 범위로 history()를 호출할 때 period=None을 전달하면
_normalize_period_to_days()에서 None.lower()가 호출되어
AttributeError: 'NoneType' object has no attribute 'lower' 발생.

- _normalize_period_to_days(): None 가드 추가, str() 래핑으로 안전 처리
- get(): period=None이면 즉시 None 반환
- store(): period=None이면 즉시 반환 (date-range 요청은 피클 캐시 생략)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
I Luk Kim 5 months ago
parent d18976d4aa
commit 9fae52e7dc

@ -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

Loading…
Cancel
Save