INNER CODE UNIT · Python
aggregate_sentiment
zoharbabin/quantum-trader · src/analysis/qualitative_analysis.py:72
def aggregate_sentiment(self, news_data, twitter_data):
"""
Aggregate sentiment from news and Twitter data.
:param news_data: Dictionary containing news articles
:param twitter_data: Dictionary containing tweets
:return: Aggregated sentiment score (-1 to 1)
"""
try:
sentiments = []
# Analyze news sentiment
for article in news_data.get('articles', []):
title_sentiment = self.analyze_sentiment(article.get('title', ''))
desc_sentiment = self.analyze_sentiment(article.get('description', ''))
sentiments.extend([title_sentiment, desc_sentiment])
# Analyze Twitter sentiment