Fix Polygon API date range to avoid missing data
- End date now uses yesterday to ensure data availability - Polygon may not have current day data immediately - Successfully tested with AAPL and TSLA charts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,8 +33,8 @@ class PolygonAPI:
|
|||||||
Dictionary with OHLCV data or None if unavailable
|
Dictionary with OHLCV data or None if unavailable
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Calculate date range
|
# Calculate date range (end yesterday to avoid missing today's data)
|
||||||
end_date = datetime.now()
|
end_date = datetime.now() - timedelta(days=1)
|
||||||
start_date = end_date - timedelta(days=days)
|
start_date = end_date - timedelta(days=days)
|
||||||
|
|
||||||
# Format dates as YYYY-MM-DD
|
# Format dates as YYYY-MM-DD
|
||||||
@@ -57,9 +57,12 @@ class PolygonAPI:
|
|||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
|
# Log response for debugging
|
||||||
|
logger.info(f"Polygon API response status: {data.get('status')}, results count: {len(data.get('results', []))}")
|
||||||
|
|
||||||
# Check if we got results
|
# Check if we got results
|
||||||
if data.get('status') != 'OK' or not data.get('results'):
|
if data.get('status') != 'OK' or not data.get('results'):
|
||||||
logger.warning(f"No candle data available for ticker: {ticker}")
|
logger.warning(f"No candle data available for ticker: {ticker}. Response: {data}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
results = data['results']
|
results = data['results']
|
||||||
|
|||||||
Reference in New Issue
Block a user