INNER CODE UNIT · Python
fetch_news
zoharbabin/quantum-trader · src/analysis/qualitative_analysis.py:13
def fetch_news(self, symbol):
"""
Fetch news articles for a given stock symbol.
:param symbol: Stock symbol to fetch news for
:return: Dictionary containing news articles
"""
try:
url = f"https://newsapi.org/v2/everything"
params = {
'q': symbol,
'apiKey': self.news_api_key,
'language': 'en',
'sortBy': 'publishedAt'
}
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()