Update app.py
Browse files
app.py
CHANGED
|
@@ -35,21 +35,30 @@ def plot_interactive_logarithmic_stock_chart(ticker, start_date, end_date):
|
|
| 35 |
|
| 36 |
fig = go.Figure()
|
| 37 |
|
| 38 |
-
fig.add_trace(go.Scatter(x=data.index, y=data['Close'], mode='lines', name='Close Price', line=dict(color='
|
| 39 |
-
fig.add_trace(go.Scatter(x=extended_dates, y=log_trend, mode='lines', name='Log Trend', line=dict(color='
|
| 40 |
-
fig.add_trace(go.Scatter(x=extended_dates, y=inner_upper_band, mode='lines', name='Inner Upper Band', line=dict(color='
|
| 41 |
-
fig.add_trace(go.Scatter(x=extended_dates, y=inner_lower_band, mode='lines', name='Inner Lower Band', line=dict(color='
|
| 42 |
-
fig.add_trace(go.Scatter(x=extended_dates, y=outer_upper_band, mode='lines', name='Outer Upper Band', line=dict(color='
|
| 43 |
-
fig.add_trace(go.Scatter(x=extended_dates, y=outer_lower_band, mode='lines', name='Outer Lower Band', line=dict(color='
|
| 44 |
|
| 45 |
fig.update_layout(
|
| 46 |
-
title=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
xaxis_title='Date',
|
| 48 |
yaxis_title='Price (Log Scale)',
|
| 49 |
yaxis_type="log",
|
| 50 |
height=800,
|
| 51 |
legend=dict(x=0.01, y=0.99, bgcolor='rgba(255, 255, 255, 0.8)'),
|
| 52 |
-
hovermode='x unified'
|
|
|
|
|
|
|
|
|
|
| 53 |
)
|
| 54 |
|
| 55 |
fig.update_xaxes(
|
|
@@ -72,16 +81,22 @@ def plot_interactive_logarithmic_stock_chart(ticker, start_date, end_date):
|
|
| 72 |
# Get the current date
|
| 73 |
current_date = datetime.now().strftime("%Y-%m-%d")
|
| 74 |
|
| 75 |
-
# Custom CSS to make charts full-width and larger
|
| 76 |
custom_css = """
|
| 77 |
.container {max-width: 100% !important; padding: 0 !important;}
|
| 78 |
.plot-container {height: 800px !important; width: 100% !important;}
|
| 79 |
.react-plotly-container {height: 100% !important; width: 100% !important;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
"""
|
| 81 |
|
| 82 |
# Create Gradio interface
|
| 83 |
-
with gr.Blocks(css=custom_css, title="
|
| 84 |
-
gr.Markdown("#
|
| 85 |
gr.Markdown("Enter a stock ticker and date range to generate a logarithmic chart.")
|
| 86 |
|
| 87 |
with gr.Row():
|
|
|
|
| 35 |
|
| 36 |
fig = go.Figure()
|
| 37 |
|
| 38 |
+
fig.add_trace(go.Scatter(x=data.index, y=data['Close'], mode='lines', name='Close Price', line=dict(color='#3366CC')))
|
| 39 |
+
fig.add_trace(go.Scatter(x=extended_dates, y=log_trend, mode='lines', name='Log Trend', line=dict(color='#DC3912')))
|
| 40 |
+
fig.add_trace(go.Scatter(x=extended_dates, y=inner_upper_band, mode='lines', name='Inner Upper Band', line=dict(color='#FF9900')))
|
| 41 |
+
fig.add_trace(go.Scatter(x=extended_dates, y=inner_lower_band, mode='lines', name='Inner Lower Band', line=dict(color='#FF9900')))
|
| 42 |
+
fig.add_trace(go.Scatter(x=extended_dates, y=outer_upper_band, mode='lines', name='Outer Upper Band', line=dict(color='#109618')))
|
| 43 |
+
fig.add_trace(go.Scatter(x=extended_dates, y=outer_lower_band, mode='lines', name='Outer Lower Band', line=dict(color='#109618')))
|
| 44 |
|
| 45 |
fig.update_layout(
|
| 46 |
+
title={
|
| 47 |
+
'text': 'Stock Log Charts',
|
| 48 |
+
'y': 0.95,
|
| 49 |
+
'x': 0.5,
|
| 50 |
+
'xanchor': 'center',
|
| 51 |
+
'yanchor': 'top'
|
| 52 |
+
},
|
| 53 |
xaxis_title='Date',
|
| 54 |
yaxis_title='Price (Log Scale)',
|
| 55 |
yaxis_type="log",
|
| 56 |
height=800,
|
| 57 |
legend=dict(x=0.01, y=0.99, bgcolor='rgba(255, 255, 255, 0.8)'),
|
| 58 |
+
hovermode='x unified',
|
| 59 |
+
plot_bgcolor='#F5F5F5',
|
| 60 |
+
paper_bgcolor='#F5F5F5',
|
| 61 |
+
font=dict(family="Arial", size=12, color="#333333")
|
| 62 |
)
|
| 63 |
|
| 64 |
fig.update_xaxes(
|
|
|
|
| 81 |
# Get the current date
|
| 82 |
current_date = datetime.now().strftime("%Y-%m-%d")
|
| 83 |
|
| 84 |
+
# Custom CSS to make charts full-width and larger, and apply a theme
|
| 85 |
custom_css = """
|
| 86 |
.container {max-width: 100% !important; padding: 0 !important;}
|
| 87 |
.plot-container {height: 800px !important; width: 100% !important;}
|
| 88 |
.react-plotly-container {height: 100% !important; width: 100% !important;}
|
| 89 |
+
body {background-color: #F5F5F5; color: #333333; font-family: Arial, sans-serif;}
|
| 90 |
+
.gradio-container {background-color: #FFFFFF; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);}
|
| 91 |
+
.gr-button {background-color: #3366CC; color: white;}
|
| 92 |
+
.gr-button:hover {background-color: #254EDB;}
|
| 93 |
+
.gr-input {border: 1px solid #CCCCCC; border-radius: 4px;}
|
| 94 |
+
.gr-input:focus {border-color: #3366CC; box-shadow: 0 0 0 2px rgba(51, 102, 204, 0.2);}
|
| 95 |
"""
|
| 96 |
|
| 97 |
# Create Gradio interface
|
| 98 |
+
with gr.Blocks(css=custom_css, title="Stock Log Charts") as iface:
|
| 99 |
+
gr.Markdown("# Stock Log Charts", elem_id="main-title")
|
| 100 |
gr.Markdown("Enter a stock ticker and date range to generate a logarithmic chart.")
|
| 101 |
|
| 102 |
with gr.Row():
|