955 lines
46 KiB
Python
955 lines
46 KiB
Python
"""
|
|
hyperstitionstud_io.quant.timeseries — Lens-Neutral Periodic Quantitative Financial & Memetic Gematria Time-Series Engine.
|
|
|
|
Enforces the Strict Periodicity Qualification Gate:
|
|
- Ingests ONLY timestamp-indexed periodic sources (`21:30 UTC` `us-closing-bell` market bars,
|
|
`00:00 UTC` `*-dossier-news-YYYY-MM-DD.md` wire harvests, daily `M1-M7+` regime vectors, and
|
|
dated `quantitative-economic-anchors.json` step revisions).
|
|
- Strictly excludes non-periodic/static corpora (`01-lexicon`, `10-19-ledgers`, undated dossiers
|
|
`20-24`, `26-45`, `65-69`, 22-volume Encyclopedia, proposals, lectures, podcasts, `db.json`).
|
|
- Persists 100% lens-neutral mathematical keys (`struct_*` & `ts_*`) and projects interpretive
|
|
registers (`fund_manager`, `neutral_math`, `corporate_board`, `tierzoo_ecology`,
|
|
`fantasy_sabermetrics`, `pokedex_scanner`) at runtime via `hyperstitionstud_io.lenses`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import datetime
|
|
import hashlib
|
|
import json
|
|
import math
|
|
import re
|
|
import urllib.parse
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from hyperstitionstud_io import __version__ as CURRENT_VERSION
|
|
from hyperstitionstud_io.ciphers import (
|
|
compute_aq,
|
|
expand_quant_spoken,
|
|
int_to_spoken_words,
|
|
is_repdigit_37,
|
|
prime_rank,
|
|
)
|
|
from hyperstitionstud_io.config import load_workspace_config
|
|
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard
|
|
from hyperstitionstud_io.ipld import compute_dag_json_cidv1, write_pretty_and_dag_json
|
|
from hyperstitionstud_io.lenses import DEFAULT_LENS, ENABLED_LENSES, LENS_REGISTRY, apply_all_lenses
|
|
from hyperstitionstud_io.phonetics import translate_batch
|
|
from hyperstitionstud_io.quant.collector import (
|
|
CANONICAL_WATCHLIST_24,
|
|
NO_DATA_AVAILABLE,
|
|
S1_S6_SIGNATURE_RINGS,
|
|
)
|
|
|
|
# Canonical TradingView Superchart Symbol & URL Resolver (Opened in new window; 0 external script embeds)
|
|
TRADINGVIEW_SYMBOL_MAP: dict[str, tuple[str, str]] = {
|
|
"NVDA": ("NASDAQ:NVDA", "https://www.tradingview.com/chart/?symbol=NASDAQ%3ANVDA"),
|
|
"ASML": ("NASDAQ:ASML", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AASML"),
|
|
"TSM": ("NYSE:TSM", "https://www.tradingview.com/chart/?symbol=NYSE%3ATSM"),
|
|
"ANTHR-PVT": ("NASDAQ:GOOGL", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AGOOGL"),
|
|
"MSFT": ("NASDAQ:MSFT", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AMSFT"),
|
|
"GOOGL": ("NASDAQ:GOOGL", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AGOOGL"),
|
|
"META": ("NASDAQ:META", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AMETA"),
|
|
"ORCL": ("NYSE:ORCL", "https://www.tradingview.com/chart/?symbol=NYSE%3AORCL"),
|
|
"AVGO": ("NASDAQ:AVGO", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AAVGO"),
|
|
"ARM": ("NASDAQ:ARM", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AARM"),
|
|
"AMD": ("NASDAQ:AMD", "https://www.tradingview.com/chart/?symbol=NASDAQ%3AAMD"),
|
|
"PLTR": ("NASDAQ:PLTR", "https://www.tradingview.com/chart/?symbol=NASDAQ%3APLTR"),
|
|
"LMT": ("NYSE:LMT", "https://www.tradingview.com/chart/?symbol=NYSE%3ALMT"),
|
|
"RTX": ("NYSE:RTX", "https://www.tradingview.com/chart/?symbol=NYSE%3ARTX"),
|
|
"HG=F": ("COMEX:HG1!", "https://www.tradingview.com/chart/?symbol=COMEX%3AHG1%21"),
|
|
"^VIX": ("TVC:VIX", "https://www.tradingview.com/chart/?symbol=TVC%3AVIX"),
|
|
"BTC-USD": ("COINBASE:BTCUSD", "https://www.tradingview.com/chart/?symbol=COINBASE%3ABTCUSD"),
|
|
"ETH-USD": ("COINBASE:ETHUSD", "https://www.tradingview.com/chart/?symbol=COINBASE%3AETHUSD"),
|
|
"SOL-USD": ("COINBASE:SOLUSD", "https://www.tradingview.com/chart/?symbol=COINBASE%3ASOLUSD"),
|
|
"COIN": ("NASDAQ:COIN", "https://www.tradingview.com/chart/?symbol=NASDAQ%3ACOIN"),
|
|
"CEG": ("NASDAQ:CEG", "https://www.tradingview.com/chart/?symbol=NASDAQ%3ACEG"),
|
|
"LLY": ("NYSE:LLY", "https://www.tradingview.com/chart/?symbol=NYSE%3ALLY"),
|
|
"^TNX": ("TVC:US10Y", "https://www.tradingview.com/chart/?symbol=TVC%3AUS10Y"),
|
|
"BLK": ("NYSE:BLK", "https://www.tradingview.com/chart/?symbol=NYSE%3ABLK"),
|
|
}
|
|
|
|
EXCLUDED_NON_PERIODIC_SOURCES: list[str] = [
|
|
"01-ingglish-aq-lexicon.md",
|
|
"10-19-ledger-*.md",
|
|
"20-24-dossier-*.md",
|
|
"26-45-dossier-*.md",
|
|
"65-69-dossier-technocapital-singularity-*.md",
|
|
"technocapital-singularity-zoology/encyclopedia/*",
|
|
"proposal-*.md",
|
|
"lecture-*.md",
|
|
"podcast-ep*.md",
|
|
"haiperdohp-jemaytreeah/db.json",
|
|
]
|
|
|
|
_SPARK_BLOCKS = "▁▂▃▄▅▆▇█"
|
|
_DATED_NEWS_RE = re.compile(r"^(\d+)-dossier-news-(\d{4}-\d{2}-\d{2})\.md$")
|
|
_EQ_LINE_RE = re.compile(r"^-\s+`([^`]+)`\s+\(\"([^\"]+)\"\)\s+—\s+`([^`]+)=\s*(333|666|777)`")
|
|
|
|
|
|
GUILD_ENCYCLOPEDIA_VOLUME_MAP: dict[str, tuple[str, int, int, str]] = {
|
|
"S1": ("03-machinic-phylum-guilds-s1-to-s5/class-s1-autoregressive-ai-and-abstract-machine-a-to-z.pdf", 1, 65, "292"),
|
|
"S2": ("03-machinic-phylum-guilds-s1-to-s5/class-s2-flash-crash-and-templex-liquidity-a-to-z.pdf", 1, 66, "193"),
|
|
"S3": ("03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf", 5, 67, "137"),
|
|
"S4": ("03-machinic-phylum-guilds-s1-to-s5/class-s4-and-s5-nomad-carrier-wave-and-cutaneous-bwo-a-to-z.pdf", 1, 67, "211"),
|
|
"S5": ("03-machinic-phylum-guilds-s1-to-s5/class-s4-and-s5-nomad-carrier-wave-and-cutaneous-bwo-a-to-z.pdf", 3, 69, "777"),
|
|
"S6": ("04-capital-organizational-capture-s6/a-to-f-acquisition-to-fund.pdf", 1, 68, "125"),
|
|
}
|
|
|
|
|
|
def build_instrument_doc_references(
|
|
sym: str,
|
|
ent_eng: str,
|
|
ent_ing: str,
|
|
ent_ing_aq: int,
|
|
guilds: list[str],
|
|
) -> dict[str, Any]:
|
|
primary_g = guilds[0] if guilds else "S1"
|
|
vol_rel, pg_num, dos_num, fallback_q = GUILD_ENCYCLOPEDIA_VOLUME_MAP.get(
|
|
primary_g,
|
|
("03-machinic-phylum-guilds-s1-to-s5/class-s1-autoregressive-ai-and-abstract-machine-a-to-z.pdf", 1, 65, "292"),
|
|
)
|
|
dos_file_map = {
|
|
65: "65-dossier-technocapital-singularity-autoregressive-ai.md",
|
|
66: "66-dossier-technocapital-singularity-flash-crash-liquidity.md",
|
|
67: "67-dossier-technocapital-singularity-silicon-war-machine.md",
|
|
68: "68-dossier-technocapital-singularity-apparatus-of-capture.md",
|
|
69: "69-dossier-technocapital-singularity-vampiric-memetics.md",
|
|
}
|
|
dos_fname = dos_file_map.get(dos_num, "71-dossier-news-2026-11-29.md")
|
|
dos_prefix = "/zoology/dossiers" if dos_num in dos_file_map else "/archive"
|
|
q_enc = urllib.parse.quote(ent_ing)
|
|
return {
|
|
"encyclopedia_volume_rel": vol_rel,
|
|
"encyclopedia_deep_link": f"/encyclopedia/{vol_rel}#page={pg_num}&search={q_enc}",
|
|
"knowledge_graph_deep_link": f"/graph/index.html?select=aq:{ent_ing_aq}",
|
|
"exemplar_dossier_deep_link": f"{dos_prefix}/{dos_fname}#:~:text={urllib.parse.quote(fallback_q)}",
|
|
"rest_api_deep_link": f"/api/v1/dossiers/{dos_num}?highlight={urllib.parse.quote(fallback_q)}",
|
|
"verbatim_citation_passage": (
|
|
f"{sym} ({ent_eng} -> `{ent_ing}` = {ent_ing_aq}) indexed in Guilds [{', '.join(guilds)}] "
|
|
f"and Volume `{vol_rel.split('/')[-1]}` (p.{pg_num}, Dossier {dos_num})."
|
|
),
|
|
}
|
|
|
|
|
|
def resolve_tradingview_target(symbol: str) -> dict[str, str]:
|
|
tv_sym, tv_url = TRADINGVIEW_SYMBOL_MAP.get(
|
|
symbol.upper(),
|
|
(f"NASDAQ:{symbol.upper()}", f"https://www.tradingview.com/chart/?symbol={symbol.upper()}"),
|
|
)
|
|
return {"tradingview_symbol": tv_sym, "tradingview_url": tv_url}
|
|
|
|
|
|
def _make_sparkline(values: list[float | None]) -> str | None:
|
|
valid = [v for v in values if v is not None]
|
|
if not valid:
|
|
return None
|
|
lo, hi = min(valid), max(valid)
|
|
span = (hi - lo) if hi > lo else 1.0
|
|
out = []
|
|
for v in values:
|
|
if v is None:
|
|
out.append("·")
|
|
else:
|
|
idx = int(round((v - lo) / span * (len(_SPARK_BLOCKS) - 1)))
|
|
out.append(_SPARK_BLOCKS[max(0, min(len(_SPARK_BLOCKS) - 1, idx))])
|
|
return "".join(out)
|
|
|
|
|
|
def _pearson_corr(xs: list[float | None], ys: list[float | None]) -> float | None:
|
|
m = min(len(xs), len(ys))
|
|
pairs = [(float(xs[i]), float(ys[i])) for i in range(m) if xs[i] is not None and ys[i] is not None]
|
|
n = len(pairs)
|
|
if n < 3:
|
|
return None
|
|
mx = sum(p[0] for p in pairs) / n
|
|
my = sum(p[1] for p in pairs) / n
|
|
num = sum((p[0] - mx) * (p[1] - my) for p in pairs)
|
|
dx = math.sqrt(sum((p[0] - mx) ** 2 for p in pairs))
|
|
dy = math.sqrt(sum((p[1] - my) ** 2 for p in pairs))
|
|
if dx < 1e-9 or dy < 1e-9:
|
|
return None
|
|
return round(num / (dx * dy), 3)
|
|
|
|
|
|
def _extract_dated_news_dossiers(archive_dir: Path) -> dict[str, dict[str, Any]]:
|
|
"""
|
|
Scan ingglish-aq-archive strictly for periodic dated news dossiers (*-dossier-news-YYYY-MM-DD.md).
|
|
Asserts zero non-periodic files enter the returned map.
|
|
"""
|
|
dossiers_by_date: dict[str, dict[str, Any]] = {}
|
|
search_dir = archive_dir / "ingglish-aq-archive" if (archive_dir / "ingglish-aq-archive").is_dir() else archive_dir
|
|
if not search_dir.is_dir():
|
|
return dossiers_by_date
|
|
|
|
for p in sorted(search_dir.glob("*-dossier-news-*.md")):
|
|
m = _DATED_NEWS_RE.match(p.name)
|
|
if not m:
|
|
continue
|
|
dos_num, dt_str = int(m.group(1)), m.group(2)
|
|
txt = p.read_text(encoding="utf-8")
|
|
txt_low = txt.lower()
|
|
eqs: list[dict[str, Any]] = []
|
|
counts_by_target = {333: 0, 666: 0, 777: 0}
|
|
coords_hit: set[int] = set()
|
|
|
|
for line in txt.splitlines():
|
|
em = _EQ_LINE_RE.match(line.strip())
|
|
if em:
|
|
ing_p, eng_p, breakdown, tgt_s = em.group(1), em.group(2), em.group(3), int(em.group(4))
|
|
counts_by_target[tgt_s] = counts_by_target.get(tgt_s, 0) + 1
|
|
token_vals = [int(v) for v in re.findall(r"\((\d+)", breakdown)]
|
|
for tv in token_vals:
|
|
if tv in S1_S6_SIGNATURE_RINGS:
|
|
coords_hit.add(tv)
|
|
ring_hits = sorted(set(tv for tv in token_vals if tv in S1_S6_SIGNATURE_RINGS))
|
|
eqs.append({
|
|
"ing": ing_p,
|
|
"eng": eng_p,
|
|
"breakdown": breakdown.strip(),
|
|
"target": tgt_s,
|
|
"ring_coordinates": ring_hits,
|
|
"dossier_deep_link": f"/archive/{p.name}#:~:text={urllib.parse.quote(ing_p[:32])}",
|
|
"api_highlight_link": f"/api/v1/dossiers/{dos_num}?highlight={urllib.parse.quote(ing_p[:24])}",
|
|
"graph_hub_links": [f"/graph/index.html?select=aq:{c}" for c in ring_hits] + [f"/graph/index.html?select=aq:{tgt_s}"],
|
|
})
|
|
|
|
for c_ring in S1_S6_SIGNATURE_RINGS:
|
|
if f"`{c_ring}`" in txt or f"== {c_ring}" in txt or f"({c_ring})" in txt:
|
|
coords_hit.add(c_ring)
|
|
|
|
co_present_syms: list[str] = []
|
|
for item in CANONICAL_WATCHLIST_24:
|
|
sym = item["symbol"]
|
|
ent_low = item["entity_eng"].lower()
|
|
sym_clean = sym.split("-")[0].replace("^", "").replace("=F", "").lower()
|
|
if ent_low in txt_low or (len(sym_clean) >= 3 and f" {sym_clean} " in f" {txt_low} "):
|
|
co_present_syms.append(sym)
|
|
|
|
dossiers_by_date[dt_str] = {
|
|
"date_utc": dt_str,
|
|
"dossier_number": dos_num,
|
|
"dossier_file": p.name,
|
|
"archive_route": f"/archive/{p.name}",
|
|
"equation_counts": {
|
|
"eq_333": counts_by_target[333],
|
|
"eq_666": counts_by_target[666],
|
|
"eq_777": counts_by_target[777],
|
|
"total": len(eqs),
|
|
},
|
|
"active_ring_coordinates": sorted(coords_hit),
|
|
"co_present_symbols": sorted(co_present_syms),
|
|
"sample_equations": eqs[:12],
|
|
}
|
|
return dossiers_by_date
|
|
|
|
|
|
def _load_real_market_history_bars(cfg: Any) -> dict[str, dict[str, dict[str, Any]]]:
|
|
"""
|
|
Load real daily OHLCV bars from `site/quant/real-market-history.json`.
|
|
Never synthesizes or interpolates missing dates or private-entity prices:
|
|
any `(symbol, date_utc)` not present in the real exchange history returns `None`
|
|
and is reported as `"No data available"`.
|
|
"""
|
|
hist_path = cfg.core_dir / "site" / "quant" / "real-market-history.json"
|
|
if not hist_path.is_file():
|
|
return {}
|
|
try:
|
|
raw = json.loads(hist_path.read_text(encoding="utf-8"))
|
|
out: dict[str, dict[str, dict[str, Any]]] = {}
|
|
for sym, sym_obj in (raw.get("instruments") or {}).items():
|
|
out[sym] = dict(sym_obj.get("bars_by_date") or {})
|
|
return out
|
|
except Exception:
|
|
return {}
|
|
|
|
|
|
def compute_timeseries_moments(
|
|
daily_points: list[float | None],
|
|
active_flags: list[bool],
|
|
wire_shares: list[float | None],
|
|
cap_shares: list[float | None],
|
|
expected_null_locks: float | None,
|
|
observed_locks: int | None,
|
|
wire_vel_series: list[float | None],
|
|
abs_bps_series: list[float | None],
|
|
regime_series: list[set[str]],
|
|
baseline_replacement_pts: float = 18.0,
|
|
available_trading_days: int | None = None,
|
|
) -> dict[str, Any]:
|
|
"""
|
|
Compute the 6 canonical lens-neutral longitudinal time-series moments (`ts_*`).
|
|
Returns `None` (`null` in JSON) for unavailable metrics rather than defaulting to `0.0`.
|
|
"""
|
|
valid_pts = [float(p) for p in daily_points if p is not None]
|
|
avail_cnt = available_trading_days if available_trading_days is not None else len(valid_pts)
|
|
if avail_cnt <= 0 or not valid_pts:
|
|
return {
|
|
"ts_duty_cycle_pct": None,
|
|
"ts_weighted_resonance": None,
|
|
"ts_excess_over_null": None,
|
|
"ts_excess_over_replacement": None,
|
|
"ts_quantile_profile": {
|
|
"p20_floor": None,
|
|
"p90_ceiling": None,
|
|
"boom_pct": None,
|
|
"bust_pct": None,
|
|
"cv": None,
|
|
},
|
|
"ts_optimal_lag_days": None,
|
|
"ts_lag_correlation_curve": {str(tau): None for tau in range(-5, 6)},
|
|
"ts_regime_splits": {
|
|
"M1_ENTROPIC": None,
|
|
"M2_FLASH_CRASH": None,
|
|
"M3_LEVIATHAN": None,
|
|
},
|
|
"ts_sparkline_30d": None,
|
|
}
|
|
|
|
n_total = max(1, len(daily_points))
|
|
n_valid = max(1, len(valid_pts))
|
|
duty_pct = round(100.0 * sum(1 for f in active_flags if f) / n_valid, 1)
|
|
|
|
valid_wire = [float(w) for w in wire_shares if w is not None]
|
|
valid_cap = [float(c) for c in cap_shares if c is not None]
|
|
mean_wire_sh = sum(valid_wire) / len(valid_wire) if valid_wire else 0.0
|
|
mean_cap_sh = sum(valid_cap) / len(valid_cap) if valid_cap else 0.0
|
|
weighted_res = min(99.0, round(100.0 * (1.5 * mean_wire_sh + 0.7 * mean_cap_sh), 1))
|
|
|
|
loe = round((observed_locks or 0) - (expected_null_locks or 0.0), 2) if (observed_locks is not None and expected_null_locks is not None) else None
|
|
tot_pts = sum(valid_pts)
|
|
excess_over_repl = round((tot_pts - baseline_replacement_pts) / 6.5, 2)
|
|
|
|
sorted_pts = sorted(valid_pts)
|
|
p20_idx = min(n_valid - 1, max(0, int(0.20 * n_valid)))
|
|
p90_idx = min(n_valid - 1, max(0, int(0.90 * n_valid)))
|
|
mean_pt = tot_pts / n_valid
|
|
var_pt = sum((x - mean_pt) ** 2 for x in valid_pts) / n_valid
|
|
std_pt = math.sqrt(var_pt)
|
|
cv = round(std_pt / mean_pt, 2) if mean_pt > 0 else None
|
|
|
|
p20_norm = min(98.0, round(42.0 + 14.0 * sorted_pts[p20_idx], 1))
|
|
p90_norm = min(99.0, round(48.0 + 11.5 * sorted_pts[p90_idx], 1))
|
|
boom_pct = round(100.0 * sum(1 for x in valid_pts if x >= 3.5) / n_valid, 1)
|
|
bust_pct = round(100.0 * sum(1 for x in valid_pts if x <= 0.01) / n_valid, 1)
|
|
|
|
lag_corrs: dict[str, float | None] = {}
|
|
best_lag: int | None = None
|
|
best_abs_r = -1.0
|
|
for tau in range(-5, 6):
|
|
if tau >= 0:
|
|
xs = wire_vel_series[: n_total - tau]
|
|
ys = abs_bps_series[tau:]
|
|
else:
|
|
k = -tau
|
|
xs = wire_vel_series[k:]
|
|
ys = abs_bps_series[: n_total - k]
|
|
r_val = _pearson_corr(xs, ys)
|
|
lag_corrs[str(tau)] = r_val
|
|
if r_val is not None and abs(r_val) > best_abs_r:
|
|
best_abs_r = abs(r_val)
|
|
best_lag = tau
|
|
|
|
regime_splits: dict[str, float | None] = {}
|
|
for r_key, r_full in (
|
|
("M1_ENTROPIC", "M1_ENTROPIC_STAGNATION"),
|
|
("M2_FLASH_CRASH", "M2_FLASH_CRASH_TEMPLEX_SURGE"),
|
|
("M3_LEVIATHAN", "M3_LEVIATHAN_TRILLION_CAP_CONCENTRATION"),
|
|
):
|
|
sub_pts = [float(daily_points[i]) for i in range(n_total) if daily_points[i] is not None and r_full in regime_series[i]]
|
|
if sub_pts:
|
|
regime_splits[r_key] = round((sum(sub_pts) / len(sub_pts) - mean_pt) * 4.0, 1)
|
|
else:
|
|
regime_splits[r_key] = None
|
|
|
|
return {
|
|
"ts_duty_cycle_pct": duty_pct,
|
|
"ts_weighted_resonance": weighted_res,
|
|
"ts_excess_over_null": loe,
|
|
"ts_excess_over_replacement": excess_over_repl,
|
|
"ts_quantile_profile": {
|
|
"p20_floor": p20_norm,
|
|
"p90_ceiling": p90_norm,
|
|
"boom_pct": boom_pct,
|
|
"bust_pct": bust_pct,
|
|
"cv": cv,
|
|
},
|
|
"ts_optimal_lag_days": best_lag,
|
|
"ts_lag_correlation_curve": lag_corrs,
|
|
"ts_regime_splits": regime_splits,
|
|
"ts_sparkline_30d": _make_sparkline(daily_points),
|
|
}
|
|
|
|
|
|
def derive_pokedex_specimen_profile(
|
|
symbol: str,
|
|
inst_record: dict[str, Any],
|
|
) -> dict[str, Any]:
|
|
"""
|
|
Project a lens-neutral instrument record into a Gen IV INFO Pokedex specimen card.
|
|
Uses `None` (`null` in JSON) when time-series data is unavailable.
|
|
"""
|
|
sv = inst_record["structural_vector"]
|
|
tm = inst_record["timeseries_moments"]
|
|
proj = (inst_record.get("lens_projections") or {}).get("pokedex_scanner") or apply_all_lenses(
|
|
sv, tm, inst_record["composite_score"], ("pokedex_scanner",)
|
|
)["pokedex_scanner"]
|
|
|
|
qual = proj["qualitative_profile"]
|
|
duty_raw = tm.get("ts_duty_cycle_pct")
|
|
w_res_raw = tm.get("ts_weighted_resonance")
|
|
if duty_raw is None or w_res_raw is None:
|
|
level: int | None = None
|
|
rarity: str | None = None
|
|
else:
|
|
duty = float(duty_raw)
|
|
level = max(12, min(99, int(round(0.55 * inst_record["composite_score"] + 0.45 * float(w_res_raw)))))
|
|
rarity = (
|
|
"Common Keystone Encounter (21:30 UTC Closing Bell)"
|
|
if duty >= 60.0
|
|
else ("Uncommon Regime Encounter (00:00 UTC Rollover)" if duty >= 25.0 else "Legendary Roaming Anomaly (<5% Rate)")
|
|
)
|
|
return {
|
|
"dex_number": f"DEX #{inst_record['entity_ing_aq']:03d}",
|
|
"symbol": symbol,
|
|
"entity_eng": inst_record["entity_eng"],
|
|
"entity_ing": inst_record["entity_ing"],
|
|
"guilds": inst_record["guilds"],
|
|
"level": level,
|
|
"evolution_stage": proj["tier_classification"],
|
|
"nature": qual["archetype"],
|
|
"ability": qual["regime_specialization"],
|
|
"ev_yield": qual["causal_role"],
|
|
"encounter_rarity": rarity,
|
|
"base_stats_6": proj["labeled_structural"],
|
|
"timeseries_telemetry": proj["labeled_timeseries"],
|
|
"sparkline_30d": tm["ts_sparkline_30d"],
|
|
"tradingview_symbol": inst_record["tradingview_symbol"],
|
|
"tradingview_url": inst_record["tradingview_url"],
|
|
}
|
|
|
|
|
|
def build_quant_timeseries_bundle(
|
|
enabled_lenses: tuple[str, ...] | list[str] = ENABLED_LENSES,
|
|
write_files: bool = True,
|
|
) -> dict[str, Any]:
|
|
"""
|
|
Build the lens-neutral periodic time-series bundle across the 30-day November 2026 UTC calendar
|
|
(2026-11-01 .. 2026-11-30), cross-joining the 24 S1-S6 market tickers with the 21 dated
|
|
00:00 GMT news wire dossiers.
|
|
"""
|
|
cfg = load_workspace_config()
|
|
active_lenses = tuple(lid for lid in enabled_lenses if lid in LENS_REGISTRY)
|
|
if not active_lenses:
|
|
active_lenses = ("neutral_math",)
|
|
|
|
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
|
dated_dossiers = _extract_dated_news_dossiers(cfg.archive_dir)
|
|
real_history = _load_real_market_history_bars(cfg)
|
|
dates_utc = [f"2026-11-{d:02d}" for d in range(1, 31)]
|
|
num_days = len(dates_utc)
|
|
|
|
# Pre-collect all phrases needed for batch Ingglish translation from real observations only
|
|
raw_bars_by_sym: dict[str, list[dict[str, Any] | None]] = {}
|
|
phrases_to_translate: set[str] = set()
|
|
for item in CANONICAL_WATCHLIST_24:
|
|
sym = item["symbol"]
|
|
sym_clean = sym.split("-")[0].replace("^", "").replace("=F", "")
|
|
phrases_to_translate.add(sym_clean)
|
|
phrases_to_translate.add(item["entity_eng"])
|
|
sym_hist = real_history.get(sym) or {}
|
|
bars: list[dict[str, Any] | None] = []
|
|
for dt_s in dates_utc:
|
|
b = sym_hist.get(dt_s)
|
|
bars.append(b)
|
|
if b and b.get("close_usd") is not None:
|
|
phrases_to_translate.add(int_to_spoken_words(int(round(float(b["close_usd"])))))
|
|
if b and b.get("change_bps") is not None:
|
|
phrases_to_translate.add(int_to_spoken_words(abs(int(b["change_bps"]))))
|
|
if b and b.get("market_cap_str") and b["market_cap_str"] != NO_DATA_AVAILABLE:
|
|
phrases_to_translate.add(expand_quant_spoken(str(b["market_cap_str"])))
|
|
raw_bars_by_sym[sym] = bars
|
|
|
|
ing_map = translate_batch(sorted(phrases_to_translate))
|
|
|
|
# Build daily wire summary series (2026-11-01 .. 2026-11-30)
|
|
daily_wire_series: list[dict[str, Any]] = []
|
|
wire_vel_global: list[float | None] = []
|
|
for dt_s in dates_utc:
|
|
dos = dated_dossiers.get(dt_s)
|
|
if dos:
|
|
daily_wire_series.append(dos)
|
|
wire_vel_global.append(float(dos["equation_counts"]["total"]))
|
|
else:
|
|
daily_wire_series.append({
|
|
"date_utc": dt_s,
|
|
"dossier_number": None,
|
|
"dossier_file": None,
|
|
"archive_route": None,
|
|
"equation_counts": {"eq_333": None, "eq_666": None, "eq_777": None, "total": None},
|
|
"active_ring_coordinates": [],
|
|
"co_present_symbols": [],
|
|
"sample_equations": [],
|
|
})
|
|
wire_vel_global.append(None)
|
|
|
|
# Compute per-day regime states and total volume-weighted locked bps for WOPR share
|
|
daily_regimes: list[set[str]] = [set() for _ in range(num_days)]
|
|
daily_total_locked_displacement: list[float] = [0.0 for _ in range(num_days)]
|
|
|
|
per_sym_series: dict[str, list[dict[str, Any]]] = {}
|
|
for item in CANONICAL_WATCHLIST_24:
|
|
sym = item["symbol"]
|
|
sym_clean = sym.split("-")[0].replace("^", "").replace("=F", "")
|
|
sym_eng_aq = compute_aq(sym_clean)
|
|
sym_ing = ing_map.get(sym_clean, sym_clean.lower())
|
|
sym_ing_aq = compute_aq(sym_ing)
|
|
ent_eng = item["entity_eng"]
|
|
ent_ing = ing_map.get(ent_eng, ent_eng.lower())
|
|
ent_eng_aq = compute_aq(ent_eng)
|
|
ent_ing_aq = compute_aq(ent_ing)
|
|
series_rows: list[dict[str, Any]] = []
|
|
|
|
for d_idx, dt_s in enumerate(dates_utc):
|
|
b = raw_bars_by_sym[sym][d_idx]
|
|
dos = dated_dossiers.get(dt_s)
|
|
co_present = bool(dos and sym in dos["co_present_symbols"])
|
|
|
|
if b is None or b.get("close_usd") is None:
|
|
series_rows.append({
|
|
"date_utc": dt_s,
|
|
"data_available": False,
|
|
"status": NO_DATA_AVAILABLE,
|
|
"feed_source": None,
|
|
"close_usd": None,
|
|
"change_pct": None,
|
|
"change_bps": None,
|
|
"volume_ratio_20d": None,
|
|
"market_cap_str": NO_DATA_AVAILABLE,
|
|
"close_digit_aq": None,
|
|
"close_spoken_eng": NO_DATA_AVAILABLE,
|
|
"close_spoken_eng_aq": None,
|
|
"close_spoken_ing": NO_DATA_AVAILABLE,
|
|
"close_spoken_ing_aq": None,
|
|
"scaled_cap_spoken_eng": NO_DATA_AVAILABLE,
|
|
"scaled_cap_spoken_eng_aq": None,
|
|
"scaled_cap_spoken_ing": NO_DATA_AVAILABLE,
|
|
"scaled_cap_spoken_ing_aq": None,
|
|
"bps_digit_aq": None,
|
|
"bps_spoken_eng": NO_DATA_AVAILABLE,
|
|
"bps_spoken_eng_aq": None,
|
|
"bps_spoken_ing": NO_DATA_AVAILABLE,
|
|
"bps_spoken_ing_aq": None,
|
|
"scope1_locks": [],
|
|
"scope2_ring_coordinates": [],
|
|
"shared_dossier_coordinates": [],
|
|
"co_present_in_news_wire": co_present,
|
|
"confluence_dose": None,
|
|
"dose_taxon_label": None,
|
|
"contingent_points": 1.0 if co_present else None,
|
|
"_locked_disp": None,
|
|
})
|
|
continue
|
|
|
|
close_val = float(b["close_usd"])
|
|
close_int = int(round(close_val))
|
|
close_sp_eng = int_to_spoken_words(close_int)
|
|
close_sp_eng_aq = compute_aq(close_sp_eng)
|
|
close_sp_ing = ing_map.get(close_sp_eng, close_sp_eng)
|
|
close_dig_aq = compute_aq(str(close_int))
|
|
close_sp_aq = compute_aq(close_sp_ing)
|
|
|
|
chg_bps_raw = b.get("change_bps")
|
|
chg_pct_raw = b.get("change_pct")
|
|
if chg_bps_raw is not None:
|
|
bps_abs: int | None = abs(int(chg_bps_raw))
|
|
bps_sp_eng = int_to_spoken_words(bps_abs)
|
|
bps_sp_eng_aq: int | None = compute_aq(bps_sp_eng)
|
|
bps_sp_ing = ing_map.get(bps_sp_eng, bps_sp_eng)
|
|
bps_dig_aq: int | None = compute_aq(str(bps_abs))
|
|
bps_sp_aq: int | None = compute_aq(bps_sp_ing)
|
|
else:
|
|
bps_abs = None
|
|
bps_sp_eng = NO_DATA_AVAILABLE
|
|
bps_sp_eng_aq = None
|
|
bps_sp_ing = NO_DATA_AVAILABLE
|
|
bps_dig_aq = None
|
|
bps_sp_aq = None
|
|
|
|
mcap_raw = b.get("market_cap_str")
|
|
if mcap_raw and mcap_raw != NO_DATA_AVAILABLE:
|
|
mcap_s = str(mcap_raw)
|
|
mcap_sp_eng = expand_quant_spoken(mcap_s)
|
|
mcap_sp_eng_aq: int | None = compute_aq(mcap_sp_eng)
|
|
mcap_sp_ing = ing_map.get(mcap_sp_eng, mcap_sp_eng)
|
|
mcap_sp_aq: int | None = compute_aq(mcap_sp_ing)
|
|
else:
|
|
mcap_s = NO_DATA_AVAILABLE
|
|
mcap_sp_eng = NO_DATA_AVAILABLE
|
|
mcap_sp_eng_aq = None
|
|
mcap_sp_ing = NO_DATA_AVAILABLE
|
|
mcap_sp_aq = None
|
|
|
|
vol_r_raw = b.get("volume_ratio_20d")
|
|
vol_r = float(vol_r_raw) if vol_r_raw is not None else None
|
|
chg_pct = float(chg_pct_raw) if chg_pct_raw is not None else None
|
|
|
|
scope1_locks: list[str] = []
|
|
scope2_coords: list[int] = []
|
|
|
|
if close_int == ent_ing_aq or close_int == ent_eng_aq:
|
|
scope1_locks.append(f"CLOSE_SELF_LOCK ({close_int}=={ent_ing})")
|
|
if close_int == sym_eng_aq or close_int == sym_ing_aq:
|
|
scope1_locks.append(f"SYMBOL_SELF_LOCK ({close_int}=={sym_clean})")
|
|
if is_repdigit_37(close_sp_aq) or is_repdigit_37(close_sp_eng_aq) or is_repdigit_37(close_int):
|
|
rep_v = close_int if is_repdigit_37(close_int) else (close_sp_aq if is_repdigit_37(close_sp_aq) else close_sp_eng_aq)
|
|
scope1_locks.append(f"REPDIGIT_ATTRACTOR ({rep_v})")
|
|
if bps_abs is not None and (bps_abs == ent_ing_aq or bps_abs == ent_eng_aq or bps_abs == sym_eng_aq):
|
|
scope1_locks.append(f"BPS_SELF_LOCK ({bps_abs}=={ent_ing})")
|
|
if bps_sp_aq is not None and is_repdigit_37(bps_sp_aq):
|
|
scope1_locks.append(f"BPS_REPDIGIT_ATTRACTOR ({bps_sp_aq})")
|
|
|
|
cand_coords = [close_int, close_sp_eng_aq, close_sp_aq]
|
|
if bps_abs is not None:
|
|
cand_coords.append(bps_abs)
|
|
if bps_sp_eng_aq is not None:
|
|
cand_coords.append(bps_sp_eng_aq)
|
|
if bps_sp_aq is not None:
|
|
cand_coords.append(bps_sp_aq)
|
|
for c_val in cand_coords:
|
|
if c_val in S1_S6_SIGNATURE_RINGS and c_val not in scope2_coords:
|
|
scope2_coords.append(c_val)
|
|
|
|
dos_rings = set((dos or {}).get("active_ring_coordinates") or [])
|
|
shared_dos_coords = sorted(set(cand_coords) & dos_rings)
|
|
|
|
# 4-Species Confluence Dose (D in {0..4})
|
|
has_sp1 = int(len(scope1_locks) > 0)
|
|
has_sp2 = int(len(scope2_coords) > 0)
|
|
has_sp3 = int(len(shared_dos_coords) > 0)
|
|
has_sp4 = int(bool(co_present))
|
|
dose_val = has_sp1 + has_sp2 + has_sp3 + has_sp4
|
|
if dose_val >= 3:
|
|
dose_label = "Dose 3+: Phase-Transition Surge"
|
|
elif dose_val == 2:
|
|
dose_label = "Dose 2: G1/G4 Pinning Well"
|
|
elif dose_val == 1:
|
|
dose_label = "Dose 1: Single-Species Stub"
|
|
else:
|
|
dose_label = "Dose 0: Uncoupled Drift"
|
|
|
|
if vol_r is not None and chg_pct is not None and vol_r < 0.45 and abs(chg_pct) < 0.15:
|
|
daily_regimes[d_idx].add("M1_ENTROPIC_STAGNATION")
|
|
if (chg_pct is not None and chg_pct <= -5.0) or (vol_r is not None and vol_r >= 2.5) or (sym == "^VIX" and close_int >= 25):
|
|
daily_regimes[d_idx].add("M2_FLASH_CRASH_TEMPLEX_SURGE")
|
|
if mcap_s.endswith("T"):
|
|
daily_regimes[d_idx].add("M3_LEVIATHAN_TRILLION_CAP_CONCENTRATION")
|
|
|
|
pts = (
|
|
3.0 * len(scope1_locks)
|
|
+ 1.5 * len(scope2_coords)
|
|
+ 2.0 * len(shared_dos_coords)
|
|
+ (2.5 if (co_present and (scope1_locks or scope2_coords)) else (1.0 if co_present else 0.0))
|
|
)
|
|
locked_disp = ((bps_abs or 0) * (vol_r or 1.0)) if (scope1_locks or scope2_coords) else 0.0
|
|
daily_total_locked_displacement[d_idx] += locked_disp
|
|
|
|
series_rows.append({
|
|
"date_utc": dt_s,
|
|
"data_available": True,
|
|
"status": "ok",
|
|
"feed_source": b.get("feed_source") or "yahoo_v8_json",
|
|
"close_usd": close_val,
|
|
"change_pct": chg_pct,
|
|
"change_bps": int(chg_bps_raw) if chg_bps_raw is not None else None,
|
|
"volume_ratio_20d": vol_r,
|
|
"market_cap_str": mcap_s,
|
|
"close_digit_aq": close_dig_aq,
|
|
"close_spoken_eng": close_sp_eng,
|
|
"close_spoken_eng_aq": close_sp_eng_aq,
|
|
"close_spoken_ing": close_sp_ing,
|
|
"close_spoken_ing_aq": close_sp_aq,
|
|
"scaled_cap_spoken_eng": mcap_sp_eng,
|
|
"scaled_cap_spoken_eng_aq": mcap_sp_eng_aq,
|
|
"scaled_cap_spoken_ing": mcap_sp_ing,
|
|
"scaled_cap_spoken_ing_aq": mcap_sp_aq,
|
|
"bps_digit_aq": bps_dig_aq,
|
|
"bps_spoken_eng": bps_sp_eng,
|
|
"bps_spoken_eng_aq": bps_sp_eng_aq,
|
|
"bps_spoken_ing": bps_sp_ing,
|
|
"bps_spoken_ing_aq": bps_sp_aq,
|
|
"scope1_locks": scope1_locks,
|
|
"scope2_ring_coordinates": scope2_coords,
|
|
"shared_dossier_coordinates": shared_dos_coords,
|
|
"co_present_in_news_wire": co_present,
|
|
"confluence_dose": dose_val,
|
|
"dose_taxon_label": dose_label,
|
|
"contingent_points": round(pts, 2),
|
|
"_locked_disp": locked_disp,
|
|
})
|
|
per_sym_series[sym] = series_rows
|
|
|
|
# Finalize per-instrument structural vectors, time-series moments, and lens projections
|
|
instruments_out: list[dict[str, Any]] = []
|
|
for item in CANONICAL_WATCHLIST_24:
|
|
sym = item["symbol"]
|
|
sym_clean = sym.split("-")[0].replace("^", "").replace("=F", "")
|
|
sym_eng_aq = compute_aq(sym_clean)
|
|
sym_ing = ing_map.get(sym_clean, sym_clean.lower())
|
|
sym_ing_aq = compute_aq(sym_ing)
|
|
ent_eng = item["entity_eng"]
|
|
ent_ing = ing_map.get(ent_eng, ent_eng.lower())
|
|
ent_eng_aq = compute_aq(ent_eng)
|
|
ent_ing_aq = compute_aq(ent_ing)
|
|
s_rows = per_sym_series[sym]
|
|
avail_rows = [r for r in s_rows if r.get("data_available")]
|
|
|
|
daily_pts: list[float | None] = [float(r["contingent_points"]) if r.get("contingent_points") is not None else None for r in s_rows]
|
|
active_flags = [bool(r["scope1_locks"] or r["scope2_ring_coordinates"] or r["co_present_in_news_wire"]) for r in s_rows if r.get("data_available")]
|
|
abs_bps: list[float | None] = [float(abs(int(r["change_bps"]))) if r.get("change_bps") is not None else None for r in s_rows]
|
|
|
|
wire_shares: list[float | None] = []
|
|
cap_shares: list[float | None] = []
|
|
tot_locks = 0
|
|
for d_idx, r in enumerate(s_rows):
|
|
tot_locks += len(r["scope1_locks"]) + len(r["scope2_ring_coordinates"])
|
|
dos = dated_dossiers.get(dates_utc[d_idx])
|
|
if dos and dos["active_ring_coordinates"]:
|
|
hit = 1.0 if (ent_ing_aq in dos["active_ring_coordinates"] or sym in dos["co_present_symbols"]) else 0.0
|
|
wire_shares.append(hit / max(1, len(CANONICAL_WATCHLIST_24) * 0.35))
|
|
else:
|
|
wire_shares.append(None)
|
|
ld_val = r.pop("_locked_disp", None)
|
|
if ld_val is not None:
|
|
denom = max(1.0, daily_total_locked_displacement[d_idx])
|
|
cap_shares.append(float(ld_val) / denom)
|
|
else:
|
|
cap_shares.append(None)
|
|
|
|
is_iso = ent_eng_aq == ent_ing_aq
|
|
is_p_ing = prime_rank(ent_ing_aq) is not None
|
|
is_p_eng = prime_rank(ent_eng_aq) is not None
|
|
struct_vec = {
|
|
"struct_isometric_armor": 92.0 if is_iso else 76.0,
|
|
"struct_drift_velocity": max(55.0, min(98.0, 95.0 - abs(ent_ing_aq - ent_eng_aq) * 0.6)),
|
|
"struct_variance_collapse": 91.0 if ent_ing_aq in S1_S6_SIGNATURE_RINGS else 74.0,
|
|
"struct_trophic_capture": 94.0 if ("S6" in item["guilds"] and len(item["guilds"]) >= 2) else (84.0 if len(item["guilds"]) >= 2 else 68.0),
|
|
"struct_prime_density": 95.0 if (is_p_ing and is_p_eng) else (86.0 if is_p_ing else 64.0),
|
|
"struct_repricing_resilience": min(98.0, round(58.0 + 1.2 * tot_locks, 1)),
|
|
}
|
|
comp_score = round(
|
|
0.20 * struct_vec["struct_trophic_capture"]
|
|
+ 0.18 * struct_vec["struct_variance_collapse"]
|
|
+ 0.18 * struct_vec["struct_isometric_armor"]
|
|
+ 0.16 * struct_vec["struct_prime_density"]
|
|
+ 0.14 * struct_vec["struct_drift_velocity"]
|
|
+ 0.14 * struct_vec["struct_repricing_resilience"],
|
|
1,
|
|
)
|
|
|
|
ts_moments = compute_timeseries_moments(
|
|
daily_points=daily_pts,
|
|
active_flags=active_flags,
|
|
wire_shares=wire_shares,
|
|
cap_shares=cap_shares,
|
|
expected_null_locks=round(len(avail_rows) * 0.32, 2) if avail_rows else None,
|
|
observed_locks=tot_locks if avail_rows else None,
|
|
wire_vel_series=wire_vel_global,
|
|
abs_bps_series=abs_bps,
|
|
regime_series=daily_regimes,
|
|
available_trading_days=len(avail_rows),
|
|
)
|
|
ts_moments["available_trading_days"] = len(avail_rows)
|
|
ts_moments["missing_trading_days"] = num_days - len(avail_rows)
|
|
ts_moments["market_data_status"] = "ok" if avail_rows else NO_DATA_AVAILABLE
|
|
|
|
tv_info = resolve_tradingview_target(sym)
|
|
doc_refs = build_instrument_doc_references(sym, ent_eng, ent_ing, ent_ing_aq, item["guilds"])
|
|
inst_obj: dict[str, Any] = {
|
|
"symbol": sym,
|
|
"symbol_clean": sym_clean,
|
|
"symbol_eng_aq": sym_eng_aq,
|
|
"symbol_ing": sym_ing,
|
|
"symbol_ing_aq": sym_ing_aq,
|
|
"entity_eng": ent_eng,
|
|
"entity_ing": ent_ing,
|
|
"entity_eng_aq": ent_eng_aq,
|
|
"entity_ing_aq": ent_ing_aq,
|
|
"isometric_entity": is_iso,
|
|
"guilds": item["guilds"],
|
|
"data_available": len(avail_rows) > 0,
|
|
"status": "ok" if avail_rows else f"{NO_DATA_AVAILABLE} (private entity — no public exchange feed)",
|
|
"available_trading_days": len(avail_rows),
|
|
"tradingview_symbol": tv_info["tradingview_symbol"],
|
|
"tradingview_url": tv_info["tradingview_url"],
|
|
"doc_references": doc_refs,
|
|
"composite_score": comp_score,
|
|
"structural_vector": struct_vec,
|
|
"timeseries_moments": ts_moments,
|
|
"lens_projections": apply_all_lenses(struct_vec, ts_moments, comp_score, active_lenses),
|
|
"bars": s_rows,
|
|
}
|
|
if "pokedex_scanner" in active_lenses:
|
|
inst_obj["pokedex_profile"] = derive_pokedex_specimen_profile(sym, inst_obj)
|
|
instruments_out.append(inst_obj)
|
|
|
|
# Aggregate guild / assemblage build time-series profiles (connecting to TierZoo assemblage-builds-tier-list.json)
|
|
tl_path = cfg.zoology_dir / "taxonomy" / "assemblage-builds-tier-list.json"
|
|
builds_out: list[dict[str, Any]] = []
|
|
if tl_path.is_file():
|
|
tl_data = json.loads(tl_path.read_text(encoding="utf-8"))
|
|
for row in tl_data.get("rows", []):
|
|
s6 = row.get("stats_6") or {}
|
|
b_struct = {
|
|
"struct_isometric_armor": float(s6.get("ARM_chokepoint_armor", 70)),
|
|
"struct_drift_velocity": float(s6.get("VEL_teleoplexic_velocity", 70)),
|
|
"struct_variance_collapse": float(s6.get("COL_variance_collapse", 70)),
|
|
"struct_trophic_capture": float(s6.get("CAP_trophic_capture", 70)),
|
|
"struct_prime_density": float(s6.get("PRM_prime_mutation_iq", 70)),
|
|
"struct_repricing_resilience": float(s6.get("RES_repricing_resilience", 70)),
|
|
}
|
|
b_code = str(row.get("eval_file", "S1"))
|
|
g_prefix = b_code[:2]
|
|
matching_insts = [inst for inst in instruments_out if g_prefix in inst["guilds"]]
|
|
if not matching_insts:
|
|
matching_insts = instruments_out[:3]
|
|
|
|
b_daily_pts: list[float | None] = []
|
|
b_abs_bps: list[float | None] = []
|
|
for d_i in range(num_days):
|
|
pts_d = [float(inst["bars"][d_i]["contingent_points"]) for inst in matching_insts if inst["bars"][d_i]["contingent_points"] is not None]
|
|
b_daily_pts.append(round(sum(pts_d) / len(pts_d), 2) if pts_d else None)
|
|
bps_d = [abs(int(inst["bars"][d_i]["change_bps"])) for inst in matching_insts if inst["bars"][d_i]["change_bps"] is not None]
|
|
b_abs_bps.append(round(sum(bps_d) / len(bps_d), 1) if bps_d else None)
|
|
b_active = [any((inst["bars"][d_i]["contingent_points"] or 0) > 0 for inst in matching_insts) for d_i in range(num_days)]
|
|
b_wire_sh: list[float | None] = [None for _ in range(num_days)]
|
|
b_cap_sh: list[float | None] = [None for _ in range(num_days)]
|
|
b_locks = sum(
|
|
len(inst["bars"][d_i]["scope1_locks"]) + len(inst["bars"][d_i]["scope2_ring_coordinates"])
|
|
for inst in matching_insts
|
|
for d_i in range(num_days)
|
|
) // max(1, len(matching_insts))
|
|
|
|
b_ts = compute_timeseries_moments(
|
|
daily_points=b_daily_pts,
|
|
active_flags=b_active,
|
|
wire_shares=b_wire_sh,
|
|
cap_shares=b_cap_sh,
|
|
expected_null_locks=round(num_days * 0.32, 2),
|
|
observed_locks=b_locks,
|
|
wire_vel_series=wire_vel_global,
|
|
abs_bps_series=b_abs_bps,
|
|
regime_series=daily_regimes,
|
|
)
|
|
base_eti = float(row.get("curve_score", 75))
|
|
eor_val = b_ts.get("ts_excess_over_replacement")
|
|
live_eti = (
|
|
max(40.0, min(99.0, round(base_eti + 0.35 * float(eor_val), 1)))
|
|
if eor_val is not None
|
|
else base_eti
|
|
)
|
|
builds_out.append({
|
|
"rank": row.get("rank"),
|
|
"build_code": b_code,
|
|
"title": row.get("title"),
|
|
"roster_slot": row.get("roster_slot"),
|
|
"base_composite_score": base_eti,
|
|
"live_timeseries_score": live_eti,
|
|
"doc_references": {
|
|
"encyclopedia_volume_rel": "07-ecological-trophic-index-and-tier-list/a-to-z-arm-chokepoint-armor-to-zoological-tie-breaker.pdf",
|
|
"encyclopedia_deep_link": f"/encyclopedia/07-ecological-trophic-index-and-tier-list/a-to-z-arm-chokepoint-armor-to-zoological-tie-breaker.pdf#page=1&search={urllib.parse.quote(g_prefix)}",
|
|
"knowledge_graph_deep_link": f"/graph/index.html?select=build:{g_prefix}",
|
|
"exemplar_dossier_deep_link": f"/zoology/tier-list-technocapital-assemblage-builds.pdf#page=1&search={urllib.parse.quote(g_prefix)}",
|
|
"rest_api_deep_link": f"/api/v1/zoology/tier-list?build_filter={urllib.parse.quote(g_prefix)}",
|
|
},
|
|
"structural_vector": b_struct,
|
|
"timeseries_moments": b_ts,
|
|
"lens_projections": apply_all_lenses(b_struct, b_ts, live_eti, active_lenses),
|
|
})
|
|
|
|
anchor_revision_series = [
|
|
{
|
|
"anchor_id": "lazarus_heist_6b",
|
|
"date_utc": "2026-11-01",
|
|
"symbol": "BTC-USD",
|
|
"q_old_digit": "$6B",
|
|
"q_new_digit": "$6B",
|
|
"coordinate": 211,
|
|
"source_dossier": "25-dossier-news-2026-11-01.md",
|
|
"description": "Lazarus $6B heist ('siks bilyan' = 211 [47th PRIME] == wor masheen == koper waier) in Dossier 25.",
|
|
},
|
|
{
|
|
"anchor_id": "anthropic_ipo_price_83",
|
|
"date_utc": "2026-11-18",
|
|
"symbol": "ANTHR-PVT",
|
|
"q_old_digit": "$83",
|
|
"q_new_digit": "$83",
|
|
"coordinate": 202,
|
|
"source_dossier": "55-dossier-news-2026-11-18.md",
|
|
"description": "Anthropic valuation share anchor $83 ('aytee three' = 202) in Dossier 55 (no public exchange market data available).",
|
|
},
|
|
{
|
|
"anchor_id": "bangladesh_factories_481",
|
|
"date_utc": "2026-11-24",
|
|
"symbol": "TSM",
|
|
"q_old_digit": "481",
|
|
"q_new_digit": "481",
|
|
"coordinate": 13,
|
|
"source_dossier": "62-dossier-news-2026-11-24.md",
|
|
"description": "481 halted garment factories ('4+8+1 = 13') in Dossier 62.",
|
|
},
|
|
]
|
|
|
|
receipt = guard.audit_receipt()
|
|
bundle: dict[str, Any] = {
|
|
"$schema": "./schemas/v1/quant-timeseries.schema.json",
|
|
"$id": "urn:io:hyperstitionstud:schema:v1:quant-timeseries",
|
|
"version": CURRENT_VERSION,
|
|
"namespace_urn": f"urn:io:hyperstitionstud:quant-timeseries:{CURRENT_VERSION}",
|
|
"generated_at_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
|
"synthetic_data_eliminated": True,
|
|
"periodicity_gate": {
|
|
"enforced": True,
|
|
"allowed_cadences": ["1d-us-closing-bell-2130-utc", "24h-news-wire-rollover-0000-utc"],
|
|
"dated_news_dossiers_ingested": len(dated_dossiers),
|
|
"excluded_non_periodic_sources": EXCLUDED_NON_PERIODIC_SOURCES,
|
|
"non_periodic_records_ingested": 0,
|
|
"missing_data_policy": "No data available (never synthesized or interpolated)",
|
|
},
|
|
"enabled_lenses": list(active_lenses),
|
|
"default_lens": DEFAULT_LENS if DEFAULT_LENS in active_lenses else active_lenses[0],
|
|
"lens_registry_meta": {
|
|
lid: {
|
|
"lens_id": LENS_REGISTRY[lid]["lens_id"],
|
|
"title": LENS_REGISTRY[lid]["title"],
|
|
"short_label": LENS_REGISTRY[lid]["short_label"],
|
|
"structural_labels": LENS_REGISTRY[lid]["structural_labels"],
|
|
"timeseries_labels": LENS_REGISTRY[lid]["timeseries_labels"],
|
|
}
|
|
for lid in active_lenses
|
|
},
|
|
"dates_utc": dates_utc,
|
|
"instruments": instruments_out,
|
|
"builds": builds_out,
|
|
"daily_wire_series": daily_wire_series,
|
|
"anchor_revision_series": anchor_revision_series,
|
|
"isolation_receipt": receipt,
|
|
}
|
|
bundle["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1(bundle)}
|
|
|
|
if write_files:
|
|
quant_site_dir = cfg.core_dir / "site" / "quant"
|
|
quant_site_dir.mkdir(parents=True, exist_ok=True)
|
|
json_path = quant_site_dir / "quant-timeseries.json"
|
|
js_path = quant_site_dir / "quant-timeseries-data.js"
|
|
write_pretty_and_dag_json(json_path, bundle)
|
|
js_content = (
|
|
"// Auto-generated synchronous time-series bundle for file:// and https:// portability\n"
|
|
"window.HyperstitionStudio = window.HyperstitionStudio || {};\n"
|
|
f"window.HyperstitionStudio.QuantTimeSeries = {json.dumps(bundle, ensure_ascii=False)};\n"
|
|
)
|
|
js_path.write_text(js_content, encoding="utf-8")
|
|
|
|
return bundle
|