Spaces:
Sleeping
Sleeping
Manus commited on
Commit ·
cccefbc
1
Parent(s): 041bbd8
Final fix for multiple syntax errors in app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
|
@@ -92,7 +93,7 @@ def run_dashboard(data_src, ticker, file_upload, timeframe, start_date, end_date
|
|
| 92 |
importance_threshold=feat_threshold
|
| 93 |
)
|
| 94 |
if isinstance(result, dict) and result.get("error"):
|
| 95 |
-
logging.error(f"Model training failed: {result['error']}")
|
| 96 |
return [None] * 12 + [f"Model training failed: {result['error']}", None, None, None, None, f"Model training failed: {result['error']}"]
|
| 97 |
|
| 98 |
signals_df, trades_df, equity_df = generate_signals(df, result)
|
|
@@ -107,10 +108,10 @@ def run_dashboard(data_src, ticker, file_upload, timeframe, start_date, end_date
|
|
| 107 |
|
| 108 |
future_plot = plot_future_forecast(df, result, indicators)
|
| 109 |
future_table = pd.DataFrame({
|
| 110 |
-
|
| 111 |
-
|
| 112 |
})
|
| 113 |
-
signals_table = signals_df.reset_index()[[
|
| 114 |
r2_plot = plot_metrics_r2(result)
|
| 115 |
error_plot = plot_metrics_errors(result)
|
| 116 |
precision_recall_plot = plot_metrics_precision_recall(result)
|
|
@@ -125,13 +126,13 @@ def run_dashboard(data_src, ticker, file_upload, timeframe, start_date, end_date
|
|
| 125 |
|
| 126 |
predictions_csv = f"predictions_{ticker}.csv"
|
| 127 |
pd.DataFrame({
|
| 128 |
-
|
| 129 |
-
|
| 130 |
}).to_csv(predictions_csv)
|
| 131 |
chart_png = f"chart_{ticker}.png"
|
| 132 |
-
pio.
|
| 133 |
|
| 134 |
-
with open(log_path,
|
| 135 |
log_output = log_file.read()
|
| 136 |
|
| 137 |
logging.info("Dashboard run completed successfully")
|
|
@@ -235,3 +236,4 @@ def main_interface():
|
|
| 235 |
if __name__ == "__main__":
|
| 236 |
main_interface().launch(server_name="0.0.0.0", server_port=7860, share=False)
|
| 237 |
|
|
|
|
|
|
| 1 |
+
'''
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
|
|
|
| 93 |
importance_threshold=feat_threshold
|
| 94 |
)
|
| 95 |
if isinstance(result, dict) and result.get("error"):
|
| 96 |
+
logging.error(f"Model training failed: {result['error']})")
|
| 97 |
return [None] * 12 + [f"Model training failed: {result['error']}", None, None, None, None, f"Model training failed: {result['error']}"]
|
| 98 |
|
| 99 |
signals_df, trades_df, equity_df = generate_signals(df, result)
|
|
|
|
| 108 |
|
| 109 |
future_plot = plot_future_forecast(df, result, indicators)
|
| 110 |
future_table = pd.DataFrame({
|
| 111 |
+
"Date": [df.index[-1] + timedelta(days=i+1) for i in range(horizon)],
|
| 112 |
+
"Prediction": result["latest_prediction"]
|
| 113 |
})
|
| 114 |
+
signals_table = signals_df.reset_index()[["Date", "Price", "Signal", "Position_Size", "Stop_Loss", "Take_Profit", "Equity"]]
|
| 115 |
r2_plot = plot_metrics_r2(result)
|
| 116 |
error_plot = plot_metrics_errors(result)
|
| 117 |
precision_recall_plot = plot_metrics_precision_recall(result)
|
|
|
|
| 126 |
|
| 127 |
predictions_csv = f"predictions_{ticker}.csv"
|
| 128 |
pd.DataFrame({
|
| 129 |
+
"Actual": result["actual"],
|
| 130 |
+
"Forecast": result["forecast"]
|
| 131 |
}).to_csv(predictions_csv)
|
| 132 |
chart_png = f"chart_{ticker}.png"
|
| 133 |
+
pio.write_image(chart_plot, chart_png, format='png')
|
| 134 |
|
| 135 |
+
with open(log_path, 'r') as log_file:
|
| 136 |
log_output = log_file.read()
|
| 137 |
|
| 138 |
logging.info("Dashboard run completed successfully")
|
|
|
|
| 236 |
if __name__ == "__main__":
|
| 237 |
main_interface().launch(server_name="0.0.0.0", server_port=7860, share=False)
|
| 238 |
|
| 239 |
+
'''
|