Upload runtime.py
Browse files- runtime.py +24 -3
runtime.py
CHANGED
|
@@ -1132,6 +1132,7 @@ def build_prediction_track_record(
|
|
| 1132 |
daily: pd.DataFrame,
|
| 1133 |
t5_test: pd.DataFrame,
|
| 1134 |
tomorrow_test: pd.DataFrame,
|
|
|
|
| 1135 |
tplus1_test: pd.DataFrame,
|
| 1136 |
t5_latest: dict[str, Any],
|
| 1137 |
tomorrow_latest: dict[str, Any],
|
|
@@ -1173,6 +1174,23 @@ def build_prediction_track_record(
|
|
| 1173 |
pred = "UP" if int(row.get("pred")) == 1 else "DOWN"
|
| 1174 |
add_prediction(row.get("target_date") or row.get("date"), pred, "Tomorrow", 20, {"prob_up": row.get("prob_up")})
|
| 1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1176 |
add_prediction(tomorrow_latest.get("target_date"), tomorrow_latest.get("prediction"), "Tomorrow", 40, {"prob_up": tomorrow_latest.get("prob_up")})
|
| 1177 |
|
| 1178 |
records: list[dict[str, Any]] = []
|
|
@@ -1207,9 +1225,10 @@ def _dashboard_payload_cached(key: tuple[tuple[str, int | None, int | None], ...
|
|
| 1207 |
tplus1_summary = load_tplus1_summary()
|
| 1208 |
tplus1_latest = latest_tplus1_prediction()
|
| 1209 |
refresh_state = load_refresh_state()
|
| 1210 |
-
t5_test = load_test_predictions()
|
| 1211 |
-
tomorrow_test = load_tomorrow_test_predictions()
|
| 1212 |
-
|
|
|
|
| 1213 |
daily = pd.read_parquet(NIFTY_1D_PATH)
|
| 1214 |
daily["date"] = pd.to_datetime(daily["date"], errors="coerce")
|
| 1215 |
daily = daily.sort_values("date").tail(180)
|
|
@@ -1292,6 +1311,7 @@ def _dashboard_payload_cached(key: tuple[tuple[str, int | None, int | None], ...
|
|
| 1292 |
daily,
|
| 1293 |
t5_test,
|
| 1294 |
tomorrow_test,
|
|
|
|
| 1295 |
tplus1_test,
|
| 1296 |
t5_latest,
|
| 1297 |
tomorrow_latest,
|
|
@@ -1315,6 +1335,7 @@ def _dashboard_payload_cached(key: tuple[tuple[str, int | None, int | None], ...
|
|
| 1315 |
"recent_predictions": _json_ready_frame(recent_predictions),
|
| 1316 |
"t5_recent_predictions": _json_ready_frame(recent_predictions),
|
| 1317 |
"tomorrow_recent_predictions": _json_ready_frame(tomorrow_recent),
|
|
|
|
| 1318 |
"tplus1_recent_predictions": _json_ready_frame(tplus1_test.tail(40)),
|
| 1319 |
"track_record": track_record,
|
| 1320 |
},
|
|
|
|
| 1132 |
daily: pd.DataFrame,
|
| 1133 |
t5_test: pd.DataFrame,
|
| 1134 |
tomorrow_test: pd.DataFrame,
|
| 1135 |
+
tomorrow_history: pd.DataFrame,
|
| 1136 |
tplus1_test: pd.DataFrame,
|
| 1137 |
t5_latest: dict[str, Any],
|
| 1138 |
tomorrow_latest: dict[str, Any],
|
|
|
|
| 1174 |
pred = "UP" if int(row.get("pred")) == 1 else "DOWN"
|
| 1175 |
add_prediction(row.get("target_date") or row.get("date"), pred, "Tomorrow", 20, {"prob_up": row.get("prob_up")})
|
| 1176 |
|
| 1177 |
+
if not tomorrow_history.empty:
|
| 1178 |
+
for _, row in tomorrow_history.iterrows():
|
| 1179 |
+
pred = row.get("prediction")
|
| 1180 |
+
if pd.isna(pred) and "pred" in row:
|
| 1181 |
+
pred = "UP" if int(row.get("pred")) == 1 else "DOWN"
|
| 1182 |
+
target_date = row.get("target_date") or row.get("date") or row.get("input_date")
|
| 1183 |
+
add_prediction(
|
| 1184 |
+
target_date,
|
| 1185 |
+
pred,
|
| 1186 |
+
"Tomorrow",
|
| 1187 |
+
30,
|
| 1188 |
+
{
|
| 1189 |
+
"prob_up": row.get("prob_up"),
|
| 1190 |
+
"source": row.get("source"),
|
| 1191 |
+
},
|
| 1192 |
+
)
|
| 1193 |
+
|
| 1194 |
add_prediction(tomorrow_latest.get("target_date"), tomorrow_latest.get("prediction"), "Tomorrow", 40, {"prob_up": tomorrow_latest.get("prob_up")})
|
| 1195 |
|
| 1196 |
records: list[dict[str, Any]] = []
|
|
|
|
| 1225 |
tplus1_summary = load_tplus1_summary()
|
| 1226 |
tplus1_latest = latest_tplus1_prediction()
|
| 1227 |
refresh_state = load_refresh_state()
|
| 1228 |
+
t5_test = load_test_predictions()
|
| 1229 |
+
tomorrow_test = load_tomorrow_test_predictions()
|
| 1230 |
+
tomorrow_history = _load_prediction_history(TOMORROW_PREDICTION_HISTORY_PATH)
|
| 1231 |
+
tplus1_test = load_tplus1_test_predictions()
|
| 1232 |
daily = pd.read_parquet(NIFTY_1D_PATH)
|
| 1233 |
daily["date"] = pd.to_datetime(daily["date"], errors="coerce")
|
| 1234 |
daily = daily.sort_values("date").tail(180)
|
|
|
|
| 1311 |
daily,
|
| 1312 |
t5_test,
|
| 1313 |
tomorrow_test,
|
| 1314 |
+
tomorrow_history,
|
| 1315 |
tplus1_test,
|
| 1316 |
t5_latest,
|
| 1317 |
tomorrow_latest,
|
|
|
|
| 1335 |
"recent_predictions": _json_ready_frame(recent_predictions),
|
| 1336 |
"t5_recent_predictions": _json_ready_frame(recent_predictions),
|
| 1337 |
"tomorrow_recent_predictions": _json_ready_frame(tomorrow_recent),
|
| 1338 |
+
"tomorrow_history_predictions": _json_ready_frame(tomorrow_history.tail(80)),
|
| 1339 |
"tplus1_recent_predictions": _json_ready_frame(tplus1_test.tail(40)),
|
| 1340 |
"track_record": track_record,
|
| 1341 |
},
|