Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -260,7 +260,7 @@ with market_analysis:
|
|
| 260 |
|
| 261 |
with news_analysis:
|
| 262 |
st.header("News Analysis")
|
| 263 |
-
st.write("This module provides news impact for the following day based on the
|
| 264 |
|
| 265 |
# Load data
|
| 266 |
data_file_path = r"Events_SameDay.csv" # Update this with your file path
|
|
@@ -293,37 +293,6 @@ with news_analysis:
|
|
| 293 |
# hoverlabel=dict(font=dict(color=events
|
| 294 |
# ['FeatureSentiment'].apply(lambda x: 'red' if x == 'Negative' else 'blue' if x == 'Neutral' else 'green'))), # Customize the line style, color, and width
|
| 295 |
)
|
| 296 |
-
# Create dummy traces for the legend
|
| 297 |
-
dummy_positive = go.Scatter(x=[None], y=[None], mode='lines', name='Positive Impacts',
|
| 298 |
-
marker=dict(color=cs.pos_impacts_color, size=15), showlegend=True,
|
| 299 |
-
# visible='legendonly'
|
| 300 |
-
)
|
| 301 |
-
dummy_negative = go.Scatter(x=[None], y=[None], mode='lines', name='Negative Impacts',
|
| 302 |
-
marker=dict(color=cs.neg_impacts_color, size=15), showlegend=True,
|
| 303 |
-
# visible='legendonly'
|
| 304 |
-
)
|
| 305 |
-
|
| 306 |
-
fontsize = 12
|
| 307 |
-
annotations = []
|
| 308 |
-
# Create annotations for the Positive points
|
| 309 |
-
for index, row in plot_sub_pos.iterrows():
|
| 310 |
-
annotation1 = dict(x=row['Date'], y=row['Price'], text = row['Positive_Impacts'],
|
| 311 |
-
showarrow=True, arrowhead=0, # arrowcolor='black',
|
| 312 |
-
ax=10, ay=-20, # Dynamic offset
|
| 313 |
-
font=dict(size=fontsize, color=cs.pos_impacts_color),
|
| 314 |
-
)
|
| 315 |
-
annotations.append(annotation1)
|
| 316 |
-
|
| 317 |
-
# Create annotations for the Negative points
|
| 318 |
-
for index, row in plot_sub_neg.iterrows():
|
| 319 |
-
annotation2 = dict(x=row['Date'], y=row['Price'], text = row['Negative_Impacts'],
|
| 320 |
-
showarrow=True, arrowhead=0, arrowcolor=cs.close_line_color,
|
| 321 |
-
ax=10, ay=-20, # Dynamic offset
|
| 322 |
-
font=dict(size=fontsize, color=cs.neg_impacts_color),
|
| 323 |
-
)
|
| 324 |
-
annotations.append(annotation2)
|
| 325 |
-
|
| 326 |
-
# Create the layout
|
| 327 |
title = 'OGDCL Close Price w.r.t. News Impacts'
|
| 328 |
layout = go.Layout(
|
| 329 |
title=title,
|
|
@@ -339,19 +308,17 @@ with news_analysis:
|
|
| 339 |
# gridcolor='lightgray',
|
| 340 |
range=[90, 120],
|
| 341 |
tickvals=list(range(90, 120, 5)),
|
| 342 |
-
)
|
| 343 |
-
# plot_bgcolor='rgba(245, 245, 245, 0.8)',
|
| 344 |
-
# paper_bgcolor='white',
|
| 345 |
-
# hoverlabel=dict(
|
| 346 |
-
# bgcolor='white',
|
| 347 |
-
# font=dict(color='black'),
|
| 348 |
-
# ),
|
| 349 |
-
annotations=annotations,
|
| 350 |
)
|
| 351 |
|
| 352 |
# Add all traces to the figure
|
| 353 |
-
figure = go.Figure(data=[line_stock
|
| 354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
figure.update_layout(
|
| 356 |
title={
|
| 357 |
'text': title,
|
|
@@ -363,6 +330,8 @@ with news_analysis:
|
|
| 363 |
},
|
| 364 |
hovermode='closest',
|
| 365 |
margin=dict(l=40, r=40, t=80, b=40),
|
|
|
|
|
|
|
| 366 |
)
|
| 367 |
figure.update_xaxes(
|
| 368 |
rangeslider_visible=True,
|
|
@@ -376,6 +345,8 @@ with news_analysis:
|
|
| 376 |
])
|
| 377 |
)
|
| 378 |
)
|
|
|
|
|
|
|
| 379 |
st.plotly_chart(figure)
|
| 380 |
|
| 381 |
# news = events[events['Date'].between(start_date, end_date, inclusive='both')]
|
|
|
|
| 260 |
|
| 261 |
with news_analysis:
|
| 262 |
st.header("News Analysis")
|
| 263 |
+
st.write("This module provides news impact for the following day based on the current date.")
|
| 264 |
|
| 265 |
# Load data
|
| 266 |
data_file_path = r"Events_SameDay.csv" # Update this with your file path
|
|
|
|
| 293 |
# hoverlabel=dict(font=dict(color=events
|
| 294 |
# ['FeatureSentiment'].apply(lambda x: 'red' if x == 'Negative' else 'blue' if x == 'Neutral' else 'green'))), # Customize the line style, color, and width
|
| 295 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
title = 'OGDCL Close Price w.r.t. News Impacts'
|
| 297 |
layout = go.Layout(
|
| 298 |
title=title,
|
|
|
|
| 308 |
# gridcolor='lightgray',
|
| 309 |
range=[90, 120],
|
| 310 |
tickvals=list(range(90, 120, 5)),
|
| 311 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
)
|
| 313 |
|
| 314 |
# Add all traces to the figure
|
| 315 |
+
figure = go.Figure(data=[line_stock], layout=layout)
|
| 316 |
+
figure.add_scatter(x=plot_sub_pos['Date'], y=plot_sub_pos['Price'], mode='markers',
|
| 317 |
+
marker=dict(symbol='triangle-up', size=10, color=cs.pos_impacts_color), name='Strong buy',
|
| 318 |
+
customdata=events['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>')
|
| 319 |
+
figure.add_scatter(x=plot_sub_neg['Date'], y=plot_sub_neg['Price'], mode='markers',
|
| 320 |
+
marker=dict(symbol='triangle-down', size=10, color=cs.neg_impacts_color), name='Strong sell',
|
| 321 |
+
customdata=events['Feature'], hovertemplate='%{x}<br>Close: %{y}<br>Feature: %{customdata}<br>',)
|
| 322 |
figure.update_layout(
|
| 323 |
title={
|
| 324 |
'text': title,
|
|
|
|
| 330 |
},
|
| 331 |
hovermode='closest',
|
| 332 |
margin=dict(l=40, r=40, t=80, b=40),
|
| 333 |
+
modebar_add="togglespikelines",
|
| 334 |
+
# scrollZoom=True,
|
| 335 |
)
|
| 336 |
figure.update_xaxes(
|
| 337 |
rangeslider_visible=True,
|
|
|
|
| 345 |
])
|
| 346 |
)
|
| 347 |
)
|
| 348 |
+
# Update y-axis to allow vertical scrolling and dragging
|
| 349 |
+
figure.update_yaxes(fixedrange=False)
|
| 350 |
st.plotly_chart(figure)
|
| 351 |
|
| 352 |
# news = events[events['Date'].between(start_date, end_date, inclusive='both')]
|