Update aggregator.py
Browse files- aggregator.py +42 -42
aggregator.py
CHANGED
@@ -16,41 +16,41 @@ def get_articles_sentiment(ticker, model):
|
|
16 |
bezinga_results = pipe(bezinga_list)
|
17 |
except Exception as e:
|
18 |
print(e)
|
19 |
-
bezinga_results =
|
20 |
|
21 |
try:
|
22 |
newsapi_list = get_newsapi(ticker)
|
23 |
newsapi_results = pipe(newsapi_list)
|
24 |
except Exception as e:
|
25 |
print(e)
|
26 |
-
newsapi_results =
|
27 |
try:
|
28 |
newsdata_list = get_newsdata(ticker)
|
29 |
newsdata_results = pipe(newsdata_list)
|
30 |
except Exception as e:
|
31 |
print(e)
|
32 |
-
newsdata_results =
|
33 |
|
34 |
try:
|
35 |
finhub_list = get_finhub(ticker)
|
36 |
finhub_results = pipe(finhub_list)
|
37 |
except Exception as e:
|
38 |
print(e)
|
39 |
-
finhub_results =
|
40 |
|
41 |
try:
|
42 |
vantage_list = get_vantage(ticker)
|
43 |
vantage_results = pipe(vantage_list)
|
44 |
except Exception as e:
|
45 |
print(e)
|
46 |
-
vantage_results =
|
47 |
|
48 |
try:
|
49 |
marketaux_list = get_marketaux(ticker)
|
50 |
marketaux_results = pipe(marketaux_list)
|
51 |
except Exception as e:
|
52 |
print(e)
|
53 |
-
marketaux_results =
|
54 |
|
55 |
|
56 |
|
@@ -212,52 +212,52 @@ def get_articles_sentiment(ticker, model):
|
|
212 |
|
213 |
results_dict = {
|
214 |
"bezinga": {
|
215 |
-
"bezinga_articles": len(bezinga_results) if bezinga_results else 0,
|
216 |
-
"bezinga_positives": len(bezinga_positives) if bezinga_results else 0,
|
217 |
-
"bezinga_negatives": len(bezinga_negatives) if bezinga_results else 0,
|
218 |
-
"bezinga_sentiment_mean": bezinga_label_mean if bezinga_results else 0,
|
219 |
-
"bezinga_positive_score_mean": bezinga_positive_score_mean if bezinga_results else 0,
|
220 |
-
"bezinga_negative_score_mean": bezinga_negative_score_mean if bezinga_results else 0
|
221 |
},
|
222 |
"finhub": {
|
223 |
-
"finhub_articles": len(finhub_results) if finhub_results else 0,
|
224 |
-
"finhub_positives": len(finhub_positives) if finhub_results else 0,
|
225 |
-
"finhub_negatives": len(finhub_negatives) if finhub_results else 0,
|
226 |
-
"finhub_sentiment_mean": finhub_label_mean if finhub_results else 0,
|
227 |
-
"finhub_positive_score_mean": finhub_positive_score_mean if finhub_results else 0,
|
228 |
-
"finhub_negative_score_mean": finhub_negative_score_mean if finhub_results else 0
|
229 |
},
|
230 |
"marketaux": {
|
231 |
-
"marketaux_articles": len(marketaux_results) if marketaux_results else 0,
|
232 |
-
"marketaux_positives": len(marketaux_positives) if marketaux_results else 0,
|
233 |
-
"marketaux_negatives": len(marketaux_negatives) if marketaux_results else 0,
|
234 |
-
"marketaux_sentiment_mean": marketaux_label_mean if marketaux_results else 0,
|
235 |
-
"marketaux_positive_score_mean": marketaux_positive_score_mean if marketaux_results else 0,
|
236 |
-
"marketaux_negative_score_mean": marketaux_negative_score_mean if marketaux_results else 0
|
237 |
},
|
238 |
"newsapi": {
|
239 |
-
"newsapi_articles": len(newsapi_results) if newsapi_results else 0,
|
240 |
-
"newsapi_positives": len(newsapi_positives) if newsapi_results else 0,
|
241 |
-
"newsapi_negatives": len(newsapi_negatives) if newsapi_results else 0,
|
242 |
-
"newsapi_sentiment_mean": newsapi_label_mean if newsapi_results else 0,
|
243 |
-
"newsapi_positive_score_mean": newsapi_positive_score_mean if newsapi_results else 0,
|
244 |
-
"newsapi_negative_score_mean": newsapi_negative_score_mean if newsapi_results else 0
|
245 |
},
|
246 |
"newsdata": {
|
247 |
-
"newsdata_articles": len(newsdata_results) if newsdata_results else 0,
|
248 |
-
"newsdata_positives": len(newsdata_positives) if newsdata_results else 0,
|
249 |
-
"newsdata_negatives": len(newsdata_negatives) if newsdata_results else 0,
|
250 |
-
"newsdata_sentiment_mean": newsdata_label_mean if newsdata_results else 0,
|
251 |
-
"newsdata_positive_score_mean": newsdata_positive_score_mean if newsdata_results else 0,
|
252 |
-
"newsdata_negative_score_mean": newsdata_negative_score_mean if newsdata_results else 0
|
253 |
},
|
254 |
"vantage": {
|
255 |
-
"vantage_articles": len(vantage_results) if vantage_results else 0,
|
256 |
-
"vantage_positives": len(vantage_positives) if vantage_results else 0,
|
257 |
-
"vantage_negatives": len(vantage_negatives) if vantage_results else 0,
|
258 |
-
"vantage_sentiment_mean": vantage_label_mean if vantage_results else 0,
|
259 |
-
"vantage_positive_score_mean": vantage_positive_score_mean if vantage_results else 0,
|
260 |
-
"vantage_negative_score_mean": vantage_negative_score_mean if vantage_results else 0
|
261 |
},
|
262 |
"total_articles": total_articles,
|
263 |
"total_positives": total_positives,
|
|
|
16 |
bezinga_results = pipe(bezinga_list)
|
17 |
except Exception as e:
|
18 |
print(e)
|
19 |
+
bezinga_results = 0
|
20 |
|
21 |
try:
|
22 |
newsapi_list = get_newsapi(ticker)
|
23 |
newsapi_results = pipe(newsapi_list)
|
24 |
except Exception as e:
|
25 |
print(e)
|
26 |
+
newsapi_results = 0
|
27 |
try:
|
28 |
newsdata_list = get_newsdata(ticker)
|
29 |
newsdata_results = pipe(newsdata_list)
|
30 |
except Exception as e:
|
31 |
print(e)
|
32 |
+
newsdata_results = 0
|
33 |
|
34 |
try:
|
35 |
finhub_list = get_finhub(ticker)
|
36 |
finhub_results = pipe(finhub_list)
|
37 |
except Exception as e:
|
38 |
print(e)
|
39 |
+
finhub_results = 0
|
40 |
|
41 |
try:
|
42 |
vantage_list = get_vantage(ticker)
|
43 |
vantage_results = pipe(vantage_list)
|
44 |
except Exception as e:
|
45 |
print(e)
|
46 |
+
vantage_results = 0
|
47 |
|
48 |
try:
|
49 |
marketaux_list = get_marketaux(ticker)
|
50 |
marketaux_results = pipe(marketaux_list)
|
51 |
except Exception as e:
|
52 |
print(e)
|
53 |
+
marketaux_results = 0
|
54 |
|
55 |
|
56 |
|
|
|
212 |
|
213 |
results_dict = {
|
214 |
"bezinga": {
|
215 |
+
"bezinga_articles": len(bezinga_results) if bezinga_results > 0 else 0,
|
216 |
+
"bezinga_positives": len(bezinga_positives) if bezinga_results > 0 else 0,
|
217 |
+
"bezinga_negatives": len(bezinga_negatives) if bezinga_results > 0 else 0,
|
218 |
+
"bezinga_sentiment_mean": bezinga_label_mean if bezinga_results > 0 else 0,
|
219 |
+
"bezinga_positive_score_mean": bezinga_positive_score_mean if bezinga_results > 0 else 0,
|
220 |
+
"bezinga_negative_score_mean": bezinga_negative_score_mean if bezinga_results > 0 else 0
|
221 |
},
|
222 |
"finhub": {
|
223 |
+
"finhub_articles": len(finhub_results) if finhub_results > 0 else 0,
|
224 |
+
"finhub_positives": len(finhub_positives) if finhub_results > 0 else 0,
|
225 |
+
"finhub_negatives": len(finhub_negatives) if finhub_results > 0 else 0,
|
226 |
+
"finhub_sentiment_mean": finhub_label_mean if finhub_results > 0 else 0,
|
227 |
+
"finhub_positive_score_mean": finhub_positive_score_mean if finhub_results > 0 else 0,
|
228 |
+
"finhub_negative_score_mean": finhub_negative_score_mean if finhub_results > 0 else 0
|
229 |
},
|
230 |
"marketaux": {
|
231 |
+
"marketaux_articles": len(marketaux_results) if marketaux_results > 0 else 0,
|
232 |
+
"marketaux_positives": len(marketaux_positives) if marketaux_results > 0 else 0,
|
233 |
+
"marketaux_negatives": len(marketaux_negatives) if marketaux_results > 0 else 0,
|
234 |
+
"marketaux_sentiment_mean": marketaux_label_mean if marketaux_results > 0 else 0,
|
235 |
+
"marketaux_positive_score_mean": marketaux_positive_score_mean if marketaux_results > 0 else 0,
|
236 |
+
"marketaux_negative_score_mean": marketaux_negative_score_mean if marketaux_results > 0 else 0
|
237 |
},
|
238 |
"newsapi": {
|
239 |
+
"newsapi_articles": len(newsapi_results) if newsapi_results > 0 else 0,
|
240 |
+
"newsapi_positives": len(newsapi_positives) if newsapi_results > 0 else 0,
|
241 |
+
"newsapi_negatives": len(newsapi_negatives) if newsapi_results > 0 else 0,
|
242 |
+
"newsapi_sentiment_mean": newsapi_label_mean if newsapi_results > 0 else 0,
|
243 |
+
"newsapi_positive_score_mean": newsapi_positive_score_mean if newsapi_results > 0 else 0,
|
244 |
+
"newsapi_negative_score_mean": newsapi_negative_score_mean if newsapi_results > 0 else 0
|
245 |
},
|
246 |
"newsdata": {
|
247 |
+
"newsdata_articles": len(newsdata_results) if newsdata_results > 0 else 0,
|
248 |
+
"newsdata_positives": len(newsdata_positives) if newsdata_results > 0 else 0,
|
249 |
+
"newsdata_negatives": len(newsdata_negatives) if newsdata_results > 0 else 0,
|
250 |
+
"newsdata_sentiment_mean": newsdata_label_mean if newsdata_results > 0 else 0,
|
251 |
+
"newsdata_positive_score_mean": newsdata_positive_score_mean if newsdata_results > 0 else 0,
|
252 |
+
"newsdata_negative_score_mean": newsdata_negative_score_mean if newsdata_results > 0 else 0
|
253 |
},
|
254 |
"vantage": {
|
255 |
+
"vantage_articles": len(vantage_results) if vantage_results > 0 else 0,
|
256 |
+
"vantage_positives": len(vantage_positives) if vantage_results > 0 else 0,
|
257 |
+
"vantage_negatives": len(vantage_negatives) if vantage_results > 0 else 0,
|
258 |
+
"vantage_sentiment_mean": vantage_label_mean if vantage_results > 0 else 0,
|
259 |
+
"vantage_positive_score_mean": vantage_positive_score_mean if vantage_results > 0 else 0,
|
260 |
+
"vantage_negative_score_mean": vantage_negative_score_mean if vantage_results > 0 else 0
|
261 |
},
|
262 |
"total_articles": total_articles,
|
263 |
"total_positives": total_positives,
|