Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,13 +77,37 @@ def score_news(parsed_news_df):
|
|
| 77 |
def plot_hourly_sentiment(parsed_and_scored_news, ticker):
|
| 78 |
numeric_cols = parsed_and_scored_news.select_dtypes(include=['float64', 'int64'])
|
| 79 |
mean_scores = numeric_cols.resample('h').mean()
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
return fig
|
| 82 |
|
| 83 |
def plot_daily_sentiment(parsed_and_scored_news, ticker):
|
| 84 |
numeric_cols = parsed_and_scored_news.select_dtypes(include=['float64', 'int64'])
|
| 85 |
mean_scores = numeric_cols.resample('D').mean()
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
return fig
|
| 88 |
|
| 89 |
def get_recommendation(sentiment_scores):
|
|
|
|
| 77 |
def plot_hourly_sentiment(parsed_and_scored_news, ticker):
|
| 78 |
numeric_cols = parsed_and_scored_news.select_dtypes(include=['float64', 'int64'])
|
| 79 |
mean_scores = numeric_cols.resample('h').mean()
|
| 80 |
+
|
| 81 |
+
fig = px.bar(mean_scores, x=mean_scores.index, y='sentiment_score',
|
| 82 |
+
title=f'{ticker} Hourly Sentiment Scores',
|
| 83 |
+
color='sentiment_score',
|
| 84 |
+
color_continuous_scale=['red', 'yellow', 'green'],
|
| 85 |
+
range_color=[-1, 1])
|
| 86 |
+
|
| 87 |
+
fig.update_layout(coloraxis_colorbar=dict(
|
| 88 |
+
title="Sentiment",
|
| 89 |
+
tickvals=[-1, 0, 1],
|
| 90 |
+
ticktext=["Negative", "Neutral", "Positive"],
|
| 91 |
+
))
|
| 92 |
+
|
| 93 |
return fig
|
| 94 |
|
| 95 |
def plot_daily_sentiment(parsed_and_scored_news, ticker):
|
| 96 |
numeric_cols = parsed_and_scored_news.select_dtypes(include=['float64', 'int64'])
|
| 97 |
mean_scores = numeric_cols.resample('D').mean()
|
| 98 |
+
|
| 99 |
+
fig = px.bar(mean_scores, x=mean_scores.index, y='sentiment_score',
|
| 100 |
+
title=f'{ticker} Daily Sentiment Scores',
|
| 101 |
+
color='sentiment_score',
|
| 102 |
+
color_continuous_scale=['red', 'yellow', 'green'],
|
| 103 |
+
range_color=[-1, 1])
|
| 104 |
+
|
| 105 |
+
fig.update_layout(coloraxis_colorbar=dict(
|
| 106 |
+
title="Sentiment",
|
| 107 |
+
tickvals=[-1, 0, 1],
|
| 108 |
+
ticktext=["Negative", "Neutral", "Positive"],
|
| 109 |
+
))
|
| 110 |
+
|
| 111 |
return fig
|
| 112 |
|
| 113 |
def get_recommendation(sentiment_scores):
|