Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -139,12 +139,30 @@ def gradio_interface(years):
|
|
| 139 |
fig = analyze_stocks(stocks_filepath, index_symbol, years)
|
| 140 |
return fig
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
iface = gr.Interface(
|
| 143 |
fn=gradio_interface,
|
| 144 |
-
inputs=
|
| 145 |
-
outputs=
|
| 146 |
title="S&P 500 Stock Analysis",
|
| 147 |
description="Analyze S&P 500 stocks based on Beta and R-Squared values.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
iface.launch()
|
|
|
|
| 139 |
fig = analyze_stocks(stocks_filepath, index_symbol, years)
|
| 140 |
return fig
|
| 141 |
|
| 142 |
+
# Create the interface components
|
| 143 |
+
years_slider = gr.Slider(minimum=1, maximum=10, step=1, value=5, label="Years of Data")
|
| 144 |
+
analyze_button = gr.Button("Analyze")
|
| 145 |
+
output_plot = gr.Plot()
|
| 146 |
+
|
| 147 |
+
# Define the interface layout
|
| 148 |
iface = gr.Interface(
|
| 149 |
fn=gradio_interface,
|
| 150 |
+
inputs=years_slider,
|
| 151 |
+
outputs=output_plot,
|
| 152 |
title="S&P 500 Stock Analysis",
|
| 153 |
description="Analyze S&P 500 stocks based on Beta and R-Squared values.",
|
| 154 |
+
layout="vertical", # This ensures components are stacked vertically
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
# Customize the interface layout
|
| 158 |
+
iface.layout = gr.Layout(
|
| 159 |
+
gr.Row(years_slider),
|
| 160 |
+
gr.Row(analyze_button),
|
| 161 |
+
gr.Row(output_plot)
|
| 162 |
)
|
| 163 |
|
| 164 |
+
# Set up event handler for the analyze button
|
| 165 |
+
analyze_button.click(fn=gradio_interface, inputs=years_slider, outputs=output_plot)
|
| 166 |
+
|
| 167 |
+
# Launch the interface
|
| 168 |
iface.launch()
|