Spaces:
Sleeping
Sleeping
Add Jared read-only token OHLCV ingestion and manual contract lookup
Browse files
app.py
CHANGED
|
@@ -75,13 +75,27 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 75 |
sentiment_text, sentiment_score = sentiment_analysis(ticker, start_date, end_date, news_api_key)
|
| 76 |
|
| 77 |
features = valid_indicators # Use valid_indicators for feature
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
target = 'value'
|
| 79 |
result = get_model(
|
| 80 |
df=df,
|
| 81 |
features=features,
|
| 82 |
target=target,
|
| 83 |
model_name=model,
|
| 84 |
-
horizon=
|
| 85 |
hidden_units=hidden_units,
|
| 86 |
n_layers=n_layers,
|
| 87 |
epochs=epochs,
|
|
@@ -90,7 +104,7 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 90 |
beta2=beta2,
|
| 91 |
weight_decay=weight_decay,
|
| 92 |
dropout=dropout,
|
| 93 |
-
window_size=
|
| 94 |
test_split=test_split,
|
| 95 |
selector_method=feat_selector,
|
| 96 |
importance_threshold=feat_threshold
|
|
@@ -144,7 +158,7 @@ def run_dashboard(data_src, ticker, manual_token, file_upload, timeframe, start_
|
|
| 144 |
return [
|
| 145 |
chart_plot, sentiment_text, signals_table, backtest_plot, future_plot, future_table,
|
| 146 |
r2_plot, error_plot, precision_recall_plot, risk_plot, loss_plot, architecture_plot,
|
| 147 |
-
f"Dashboard generated successfully | source={df.attrs.get('source', data_src)} | token={df.attrs.get('token_address', display_ticker)}",
|
| 148 |
chart_png, signals_csv, predictions_csv, signals_plot, log_output
|
| 149 |
]
|
| 150 |
except Exception as e:
|
|
|
|
| 75 |
sentiment_text, sentiment_score = sentiment_analysis(ticker, start_date, end_date, news_api_key)
|
| 76 |
|
| 77 |
features = valid_indicators # Use valid_indicators for feature
|
| 78 |
+
# Newly launched Jared-observed tokens may have only a few real candles.
|
| 79 |
+
# Adapt sequence parameters to the available history rather than creating
|
| 80 |
+
# synthetic rows or allowing an impossible preprocessing request.
|
| 81 |
+
requested_window = int(window_size)
|
| 82 |
+
requested_horizon = int(horizon)
|
| 83 |
+
available_rows = len(df.dropna(subset=["value"]))
|
| 84 |
+
effective_window = min(requested_window, max(5, available_rows // 3))
|
| 85 |
+
max_horizon_for_samples = available_rows - effective_window - 9
|
| 86 |
+
effective_horizon = min(requested_horizon, max(1, max_horizon_for_samples))
|
| 87 |
+
if available_rows - effective_window - effective_horizon + 1 < 10:
|
| 88 |
+
effective_window = max(5, available_rows - effective_horizon - 9)
|
| 89 |
+
sizing_note = ""
|
| 90 |
+
if effective_window != requested_window or effective_horizon != requested_horizon:
|
| 91 |
+
sizing_note = f" Sparse history: LSTM window {requested_window}->{effective_window}, horizon {requested_horizon}->{effective_horizon}."
|
| 92 |
target = 'value'
|
| 93 |
result = get_model(
|
| 94 |
df=df,
|
| 95 |
features=features,
|
| 96 |
target=target,
|
| 97 |
model_name=model,
|
| 98 |
+
horizon=effective_horizon,
|
| 99 |
hidden_units=hidden_units,
|
| 100 |
n_layers=n_layers,
|
| 101 |
epochs=epochs,
|
|
|
|
| 104 |
beta2=beta2,
|
| 105 |
weight_decay=weight_decay,
|
| 106 |
dropout=dropout,
|
| 107 |
+
window_size=effective_window,
|
| 108 |
test_split=test_split,
|
| 109 |
selector_method=feat_selector,
|
| 110 |
importance_threshold=feat_threshold
|
|
|
|
| 158 |
return [
|
| 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 |
chart_png, signals_csv, predictions_csv, signals_plot, log_output
|
| 163 |
]
|
| 164 |
except Exception as e:
|