Spaces:
Sleeping
Sleeping
Add Jared read-only token OHLCV ingestion and manual contract lookup
Browse files
app.py
CHANGED
|
@@ -126,7 +126,7 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 126 |
|
| 127 |
future_plot = plot_future_forecast(df, result, indicators)
|
| 128 |
future_table = pd.DataFrame({
|
| 129 |
-
"Date": [df.index[-1] + timedelta(days=i+1) for i in range(
|
| 130 |
"Prediction": result["latest_prediction"]
|
| 131 |
})
|
| 132 |
signals_table = signals_df.reset_index()[["Date", "Price", "Signal", "Position_Size", "Stop_Loss", "Take_Profit", "Equity"]]
|
|
@@ -149,7 +149,17 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 149 |
"Forecast": result["forecast"]
|
| 150 |
}).to_csv(predictions_csv)
|
| 151 |
chart_png = f"chart_{safe_name}.png"
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
with open(log_path, 'r') as log_file:
|
| 155 |
log_output = log_file.read()
|
|
@@ -159,7 +169,7 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 159 |
chart_plot, sentiment_text, signals_table, backtest_plot, future_plot, future_table,
|
| 160 |
r2_plot, error_plot, precision_recall_plot, risk_plot, loss_plot, architecture_plot,
|
| 161 |
f"Dashboard generated successfully | source={df.attrs.get('source', data_src)} | token={df.attrs.get('token_address', display_ticker)}.{sizing_note}",
|
| 162 |
-
|
| 163 |
]
|
| 164 |
except Exception as e:
|
| 165 |
logging.error(f"Dashboard error: {str(e)}")
|
|
|
|
| 126 |
|
| 127 |
future_plot = plot_future_forecast(df, result, indicators)
|
| 128 |
future_table = pd.DataFrame({
|
| 129 |
+
"Date": [df.index[-1] + timedelta(days=i+1) for i in range(effective_horizon)],
|
| 130 |
"Prediction": result["latest_prediction"]
|
| 131 |
})
|
| 132 |
signals_table = signals_df.reset_index()[["Date", "Price", "Signal", "Position_Size", "Stop_Loss", "Take_Profit", "Equity"]]
|
|
|
|
| 149 |
"Forecast": result["forecast"]
|
| 150 |
}).to_csv(predictions_csv)
|
| 151 |
chart_png = f"chart_{safe_name}.png"
|
| 152 |
+
try:
|
| 153 |
+
# Kaleido v1 requires a separately provisioned Chrome binary. Keep
|
| 154 |
+
# PNG export when available, but never fail the whole analysis if
|
| 155 |
+
# the optional renderer is unavailable.
|
| 156 |
+
pio.write_image(chart_plot, chart_png, format='png')
|
| 157 |
+
chart_export = chart_png
|
| 158 |
+
except Exception as export_error:
|
| 159 |
+
logging.warning(f"PNG export unavailable: {export_error}")
|
| 160 |
+
chart_html = f"chart_{safe_name}.html"
|
| 161 |
+
chart_plot.write_html(chart_html, include_plotlyjs="cdn")
|
| 162 |
+
chart_export = chart_html
|
| 163 |
|
| 164 |
with open(log_path, 'r') as log_file:
|
| 165 |
log_output = log_file.read()
|
|
|
|
| 169 |
chart_plot, sentiment_text, signals_table, backtest_plot, future_plot, future_table,
|
| 170 |
r2_plot, error_plot, precision_recall_plot, risk_plot, loss_plot, architecture_plot,
|
| 171 |
f"Dashboard generated successfully | source={df.attrs.get('source', data_src)} | token={df.attrs.get('token_address', display_ticker)}.{sizing_note}",
|
| 172 |
+
chart_export, signals_csv, predictions_csv, signals_plot, log_output
|
| 173 |
]
|
| 174 |
except Exception as e:
|
| 175 |
logging.error(f"Dashboard error: {str(e)}")
|