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:
Bu5hm4nn
2026-03-23 22:25:09 +01:00
parent 92c6f62bb8
commit 21878bf7ff
2 changed files with 114 additions and 0 deletions

View File

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