Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,8 +88,7 @@ def plot_results(data, best_short_window, best_long_window, horizon_name, best_a
|
|
| 88 |
dtick="M1", # Set tick interval to every month
|
| 89 |
tickangle=45, # Rotate the tick labels for better readability
|
| 90 |
),
|
| 91 |
-
|
| 92 |
-
height=600
|
| 93 |
)
|
| 94 |
return fig
|
| 95 |
|
|
@@ -108,8 +107,7 @@ def plot_strategy_over_time(data, best_short_window, best_long_window):
|
|
| 108 |
title='Strategy Accuracy Over Time',
|
| 109 |
xaxis_title='Date',
|
| 110 |
yaxis_title='Rolling Accuracy',
|
| 111 |
-
|
| 112 |
-
height=400
|
| 113 |
)
|
| 114 |
return fig
|
| 115 |
|
|
@@ -189,14 +187,16 @@ if run_button:
|
|
| 189 |
st.write(f"**{st.session_state.horizon_page} Horizon - Best Short HMA**: {best_short_window}, **Best Long HMA**: {best_long_window}, **Best Accuracy**: {best_accuracy:.2f}")
|
| 190 |
st.write(f"**Buy Win Rate**: {buy_accuracy:.2f}, **Sell Win Rate**: {sell_accuracy:.2f}")
|
| 191 |
|
| 192 |
-
# Plot results
|
| 193 |
-
|
| 194 |
-
|
|
|
|
| 195 |
|
| 196 |
-
# Plot strategy performance over time
|
| 197 |
st.write("Strategy Performance Over Time")
|
| 198 |
-
|
| 199 |
-
|
|
|
|
| 200 |
|
| 201 |
# Display heatmap of accuracy with annotations
|
| 202 |
st.write(f"{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations")
|
|
@@ -218,11 +218,11 @@ if run_button:
|
|
| 218 |
title=f'{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations',
|
| 219 |
xaxis_title='Long HMA',
|
| 220 |
yaxis_title='Short HMA',
|
| 221 |
-
|
| 222 |
-
height=600
|
| 223 |
)
|
| 224 |
|
| 225 |
-
st.
|
|
|
|
| 226 |
|
| 227 |
# Re-display the results if they exist and user switches pages without re-running
|
| 228 |
else:
|
|
@@ -235,14 +235,16 @@ else:
|
|
| 235 |
st.write(f"**{st.session_state.horizon_page} Horizon - Best Short HMA**: {best_short_window}, **Best Long HMA**: {best_long_window}, **Best Accuracy**: {best_accuracy:.2f}")
|
| 236 |
st.write(f"**Buy Win Rate**: {buy_accuracy:.2f}, **Sell Win Rate**: {sell_accuracy:.2f}")
|
| 237 |
|
| 238 |
-
# Plot results
|
| 239 |
-
|
| 240 |
-
|
|
|
|
| 241 |
|
| 242 |
-
# Plot strategy performance over time
|
| 243 |
st.write("Strategy Performance Over Time")
|
| 244 |
-
|
| 245 |
-
|
|
|
|
| 246 |
|
| 247 |
# Display heatmap of accuracy with annotations
|
| 248 |
st.write(f"{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations")
|
|
@@ -264,11 +266,11 @@ else:
|
|
| 264 |
title=f'{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations',
|
| 265 |
xaxis_title='Long HMA',
|
| 266 |
yaxis_title='Short HMA',
|
| 267 |
-
|
| 268 |
-
height=600
|
| 269 |
)
|
| 270 |
|
| 271 |
-
st.
|
|
|
|
| 272 |
|
| 273 |
|
| 274 |
hide_streamlit_style = """
|
|
|
|
| 88 |
dtick="M1", # Set tick interval to every month
|
| 89 |
tickangle=45, # Rotate the tick labels for better readability
|
| 90 |
),
|
| 91 |
+
autosize=True # Enable autosizing
|
|
|
|
| 92 |
)
|
| 93 |
return fig
|
| 94 |
|
|
|
|
| 107 |
title='Strategy Accuracy Over Time',
|
| 108 |
xaxis_title='Date',
|
| 109 |
yaxis_title='Rolling Accuracy',
|
| 110 |
+
autosize=True # Enable autosizing
|
|
|
|
| 111 |
)
|
| 112 |
return fig
|
| 113 |
|
|
|
|
| 187 |
st.write(f"**{st.session_state.horizon_page} Horizon - Best Short HMA**: {best_short_window}, **Best Long HMA**: {best_long_window}, **Best Accuracy**: {best_accuracy:.2f}")
|
| 188 |
st.write(f"**Buy Win Rate**: {buy_accuracy:.2f}, **Sell Win Rate**: {sell_accuracy:.2f}")
|
| 189 |
|
| 190 |
+
# Plot results within a container to limit the height
|
| 191 |
+
with st.container():
|
| 192 |
+
fig = plot_results(data, best_short_window, best_long_window, st.session_state.horizon_page, best_accuracy, buy_accuracy, sell_accuracy)
|
| 193 |
+
st.plotly_chart(fig, use_container_width=True, height=600) # Specify height here
|
| 194 |
|
| 195 |
+
# Plot strategy performance over time within a container to limit the height
|
| 196 |
st.write("Strategy Performance Over Time")
|
| 197 |
+
with st.container():
|
| 198 |
+
strategy_fig = plot_strategy_over_time(data, best_short_window, best_long_window)
|
| 199 |
+
st.plotly_chart(strategy_fig, use_container_width=True, height=400) # Specify height here
|
| 200 |
|
| 201 |
# Display heatmap of accuracy with annotations
|
| 202 |
st.write(f"{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations")
|
|
|
|
| 218 |
title=f'{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations',
|
| 219 |
xaxis_title='Long HMA',
|
| 220 |
yaxis_title='Short HMA',
|
| 221 |
+
autosize=True # Enable autosizing
|
|
|
|
| 222 |
)
|
| 223 |
|
| 224 |
+
with st.container():
|
| 225 |
+
st.plotly_chart(heatmap_fig, use_container_width=True, height=600) # Specify height here
|
| 226 |
|
| 227 |
# Re-display the results if they exist and user switches pages without re-running
|
| 228 |
else:
|
|
|
|
| 235 |
st.write(f"**{st.session_state.horizon_page} Horizon - Best Short HMA**: {best_short_window}, **Best Long HMA**: {best_long_window}, **Best Accuracy**: {best_accuracy:.2f}")
|
| 236 |
st.write(f"**Buy Win Rate**: {buy_accuracy:.2f}, **Sell Win Rate**: {sell_accuracy:.2f}")
|
| 237 |
|
| 238 |
+
# Plot results within a container to limit the height
|
| 239 |
+
with st.container():
|
| 240 |
+
fig = plot_results(st.session_state['data'], best_short_window, best_long_window, st.session_state.horizon_page, best_accuracy, buy_accuracy, sell_accuracy)
|
| 241 |
+
st.plotly_chart(fig, use_container_width=True, height=600) # Specify height here
|
| 242 |
|
| 243 |
+
# Plot strategy performance over time within a container to limit the height
|
| 244 |
st.write("Strategy Performance Over Time")
|
| 245 |
+
with st.container():
|
| 246 |
+
strategy_fig = plot_strategy_over_time(st.session_state['data'], best_short_window, best_long_window)
|
| 247 |
+
st.plotly_chart(strategy_fig, use_container_width=True, height=400) # Specify height here
|
| 248 |
|
| 249 |
# Display heatmap of accuracy with annotations
|
| 250 |
st.write(f"{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations")
|
|
|
|
| 266 |
title=f'{st.session_state.horizon_page} Horizon: Accuracy Heatmap of HMA Combinations',
|
| 267 |
xaxis_title='Long HMA',
|
| 268 |
yaxis_title='Short HMA',
|
| 269 |
+
autosize=True # Enable autosizing
|
|
|
|
| 270 |
)
|
| 271 |
|
| 272 |
+
with st.container():
|
| 273 |
+
st.plotly_chart(heatmap_fig, use_container_width=True, height=600) # Specify height here
|
| 274 |
|
| 275 |
|
| 276 |
hide_streamlit_style = """
|