feat(DATA-001): Add live GLD price feed service with Redis caching
- Create PriceFeed service using yfinance - Cache prices in Redis with 60s TTL - Add PriceData dataclass for type safety - Support concurrent price fetching for multiple symbols
This commit is contained in:
@@ -70,3 +70,17 @@ class CacheService:
|
||||
if isinstance(value, datetime):
|
||||
return value.isoformat()
|
||||
raise TypeError(f"Object of type {type(value).__name__} is not JSON serializable")
|
||||
|
||||
|
||||
# Global cache instance
|
||||
_cache_instance: CacheService | None = None
|
||||
|
||||
|
||||
def get_cache() -> CacheService:
|
||||
"""Get or create global cache instance."""
|
||||
global _cache_instance
|
||||
if _cache_instance is None:
|
||||
import os
|
||||
redis_url = os.environ.get("REDIS_URL")
|
||||
_cache_instance = CacheService(redis_url)
|
||||
return _cache_instance
|
||||
|
||||
Reference in New Issue
Block a user