mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 09:37:23 -04:00
fix: reduce log flooding during data fetch
Replace verbose JSON logging with concise status messages:
- Success: '✓ Fetched SYMBOL'
- Error: '⚠️ SYMBOL: API rate limit or error - [message]'
Prevents logs from being flooded with full JSON responses
for 100+ stock symbols during startup.
This commit is contained in:
@@ -26,10 +26,10 @@ def get_daily_price(SYMBOL: str):
|
||||
url = f'https://www.alphavantage.co/query?function={FUNCTION}&symbol={SYMBOL}&outputsize={OUTPUTSIZE}&apikey={APIKEY}'
|
||||
r = requests.get(url)
|
||||
data = r.json()
|
||||
print(data)
|
||||
if data.get('Note') is not None or data.get('Information') is not None:
|
||||
print(f"Error")
|
||||
print(f"⚠️ {SYMBOL}: API rate limit or error - {data.get('Note') or data.get('Information')}")
|
||||
return
|
||||
print(f"✓ Fetched {SYMBOL}")
|
||||
with open(f'./daily_prices_{SYMBOL}.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
if SYMBOL == "QQQ":
|
||||
|
||||
Reference in New Issue
Block a user