Release v2.17.1: Implement Strategies A, B & C (git/stash telemetry excavator, IPv4 parallel FRED macro backfill with YoY metrics, and 3-month Yahoo/Stooq lookback with >= 2026-11-01 scope)
This commit is contained in:
1 parent
52153e76f0
commit
91cf671000
13 files changed
+2506
-411
No files matched your search
@@ -454,22 +454,48 @@ def build_daily_portfolio_brief(
|
||||
js_body = "// Auto-generated by hyperstitionstud_io.quant.daily_brief — DO NOT EDIT MANUALLY\nwindow.HYPERSTITION_DAILY_BRIEF = " + json.dumps(brief_payload, ensure_ascii=False) + ";\n"
|
||||
out_js_path.write_text(js_body, encoding="utf-8")
|
||||
|
||||
# Update append-only Bayesian state ledger outside read-only files
|
||||
history_list = list(prior_state.get("run_history") or [])
|
||||
history_list.append({
|
||||
"run_number": run_number,
|
||||
"generated_at_utc": brief_payload["generated_at_utc"],
|
||||
"posterior_probabilities": bayesian_block["posterior_probabilities"],
|
||||
"question_id": current_question["question_id"],
|
||||
"cidv1": brief_payload["ipld_dag_json_cidv1"]["/"],
|
||||
})
|
||||
# Update append-only Bayesian state ledger outside read-only files (deduplicating same-day identical posteriors)
|
||||
raw_history = list(prior_state.get("run_history") or [])
|
||||
dedup_history: list[dict[str, Any]] = []
|
||||
for entry in raw_history:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
e_dt = str(entry.get("generated_at_utc") or "")[:10]
|
||||
e_post = entry.get("posterior_probabilities")
|
||||
if dedup_history and str(dedup_history[-1].get("generated_at_utc") or "")[:10] == e_dt and dedup_history[-1].get("posterior_probabilities") == e_post:
|
||||
dedup_history[-1] = entry
|
||||
else:
|
||||
dedup_history.append(entry)
|
||||
cur_dt_10 = str(brief_payload["generated_at_utc"])[:10]
|
||||
cur_post = bayesian_block["posterior_probabilities"]
|
||||
if dedup_history and str(dedup_history[-1].get("generated_at_utc") or "")[:10] == cur_dt_10 and dedup_history[-1].get("posterior_probabilities") == cur_post:
|
||||
dedup_history[-1] = {
|
||||
"run_number": int(dedup_history[-1].get("run_number") or len(dedup_history)),
|
||||
"generated_at_utc": brief_payload["generated_at_utc"],
|
||||
"posterior_probabilities": cur_post,
|
||||
"question_id": str(dedup_history[-1].get("question_id") or current_question["question_id"]),
|
||||
"cidv1": brief_payload["ipld_dag_json_cidv1"]["/"],
|
||||
}
|
||||
else:
|
||||
next_run_num = (int(dedup_history[-1].get("run_number") or len(dedup_history)) + 1) if dedup_history else 1
|
||||
dedup_history.append({
|
||||
"run_number": next_run_num,
|
||||
"generated_at_utc": brief_payload["generated_at_utc"],
|
||||
"posterior_probabilities": cur_post,
|
||||
"question_id": f"Q-RUN-{next_run_num:04d}",
|
||||
"cidv1": brief_payload["ipld_dag_json_cidv1"]["/"],
|
||||
})
|
||||
for idx, h_item in enumerate(dedup_history, start=1):
|
||||
h_item["run_number"] = idx
|
||||
h_item["question_id"] = f"Q-RUN-{idx:04d}"
|
||||
effective_run_number = dedup_history[-1]["run_number"]
|
||||
new_state = {
|
||||
"version": CURRENT_VERSION,
|
||||
"run_number": run_number,
|
||||
"run_number": effective_run_number,
|
||||
"updated_at_utc": brief_payload["generated_at_utc"],
|
||||
"latest_posteriors": bayesian_block["posterior_probabilities"],
|
||||
"active_daily_question": current_question,
|
||||
"run_history": history_list[-30:],
|
||||
"run_history": dedup_history[-30:],
|
||||
}
|
||||
state_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
state_path.write_text(json.dumps(new_state, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
|
||||
Reference in new issue
Block a user