fix(quant): eliminate all synthetic market/timeseries data, use 100% real exchange bars, and report 'No data available' when absent (v2.0.23)
This commit is contained in:
1 parent
9716a0ab61
commit
922f485388
27 files changed
+24021
-17509
No files matched your search
@@ -2,10 +2,13 @@
|
||||
"""
|
||||
hyperstitionstud_io.quant.collector — Periodic Quantitative Financial Telemetry & Contingent Meaning Collector (`hs-quant-harvest`).
|
||||
|
||||
Evaluates quantitative financial telemetry across 3 anti-pareidolia contingent meaning scopes:
|
||||
1. Scope 1 (Intra-Instrument Self-Lock): Entity/Ticker AQ locks or closes 333/666/777 with its own price, cap, or bps move.
|
||||
2. Scope 2 (Causal S1-S6 Supply-Chain Ring Migration): Repriced metric migrates across S1-S6 signature coordinates.
|
||||
3. Scope 3 (Objective Numerical State-Gate Activation): VIX, drawdown %, volume ratio, and cap thresholds trigger M1-M6.
|
||||
Strict Data Integrity Policy:
|
||||
- Never synthesizes or hardcodes fake market prices, basis-point moves, or market caps.
|
||||
- Uses only real market observations from Yahoo Finance v8, Stooq CSV, CoinGecko v3, or
|
||||
the verified real exchange history cache (`site/quant/real-market-history.json`).
|
||||
- Whenever market data is unavailable for an instrument (e.g. private entity `ANTHR-PVT`
|
||||
or missing feed fields like `market_cap_str`), explicitly reports `"No data available"`
|
||||
(`data_available = False`, numeric fields `None`).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -47,6 +50,8 @@ os.environ["TZ"] = "UTC"
|
||||
if hasattr(time, "tzset"):
|
||||
time.tzset()
|
||||
|
||||
NO_DATA_AVAILABLE = "No data available"
|
||||
|
||||
S1_S6_SIGNATURE_RINGS: dict[int, list[str]] = {
|
||||
292: ["S1: shizohnalizis / abstrakt masheen / sinthetik dayta", "S6: asset management [Gen 0]"],
|
||||
260: ["S3: teknohkapital / kiler rohbots"],
|
||||
@@ -80,31 +85,32 @@ S1_S6_SIGNATURE_RINGS: dict[int, list[str]] = {
|
||||
71: ["S3: gpu [Iso]"],
|
||||
}
|
||||
|
||||
# Static watchlist metadata ONLY — zero hardcoded or synthesized prices/moves/caps.
|
||||
CANONICAL_WATCHLIST_24: list[dict[str, Any]] = [
|
||||
{"symbol": "NVDA", "entity_eng": "Nvidia", "guilds": ["S1", "S3"], "close_usd": 137.00, "change_pct": -1.45, "change_bps": -145, "volume_ratio_20d": 1.18, "market_cap_str": "$3.35T"},
|
||||
{"symbol": "ASML", "entity_eng": "ASML", "guilds": ["S3", "S6"], "close_usd": 710.00, "change_pct": 0.81, "change_bps": 81, "volume_ratio_20d": 1.05, "market_cap_str": "$280B"},
|
||||
{"symbol": "TSM", "entity_eng": "TSMC", "guilds": ["S3", "S6"], "close_usd": 191.00, "change_pct": 1.25, "change_bps": 125, "volume_ratio_20d": 1.12, "market_cap_str": "$990B"},
|
||||
{"symbol": "ANTHR-PVT", "entity_eng": "Anthropic", "guilds": ["S1", "S2"], "close_usd": 89.00, "change_pct": 7.23, "change_bps": 723, "volume_ratio_20d": 1.60, "market_cap_str": "$61B"},
|
||||
{"symbol": "MSFT", "entity_eng": "Microsoft", "guilds": ["S1", "S6"], "close_usd": 425.00, "change_pct": 0.40, "change_bps": 40, "volume_ratio_20d": 0.92, "market_cap_str": "$3.16T"},
|
||||
{"symbol": "GOOGL", "entity_eng": "Alphabet", "guilds": ["S1", "S6"], "close_usd": 183.00, "change_pct": -0.95, "change_bps": -95, "volume_ratio_20d": 0.98, "market_cap_str": "$2.25T"},
|
||||
{"symbol": "META", "entity_eng": "Meta", "guilds": ["S1", "S6"], "close_usd": 592.00, "change_pct": 1.33, "change_bps": 133, "volume_ratio_20d": 1.04, "market_cap_str": "$1.49T"},
|
||||
{"symbol": "ORCL", "entity_eng": "Oracle", "guilds": ["S1", "S6"], "close_usd": 189.00, "change_pct": 1.60, "change_bps": 160, "volume_ratio_20d": 1.15, "market_cap_str": "$520B"},
|
||||
{"symbol": "AVGO", "entity_eng": "Broadcom", "guilds": ["S3", "S6"], "close_usd": 163.00, "change_pct": 0.91, "change_bps": 91, "volume_ratio_20d": 1.01, "market_cap_str": "$760B"},
|
||||
{"symbol": "ARM", "entity_eng": "Arm", "guilds": ["S3", "S1"], "close_usd": 135.00, "change_pct": -1.28, "change_bps": -128, "volume_ratio_20d": 0.88, "market_cap_str": "$142B"},
|
||||
{"symbol": "AMD", "entity_eng": "AMD", "guilds": ["S3", "S1"], "close_usd": 137.00, "change_pct": -0.71, "change_bps": -71, "volume_ratio_20d": 0.94, "market_cap_str": "$222B"},
|
||||
{"symbol": "PLTR", "entity_eng": "Palantir", "guilds": ["S3", "S6"], "close_usd": 66.00, "change_pct": 2.60, "change_bps": 260, "volume_ratio_20d": 1.45, "market_cap_str": "$150B"},
|
||||
{"symbol": "LMT", "entity_eng": "Lockheed", "guilds": ["S3"], "close_usd": 534.00, "change_pct": 0.39, "change_bps": 39, "volume_ratio_20d": 0.85, "market_cap_str": "$127B"},
|
||||
{"symbol": "RTX", "entity_eng": "Raytheon", "guilds": ["S3"], "close_usd": 121.00, "change_pct": 0.41, "change_bps": 41, "volume_ratio_20d": 0.82, "market_cap_str": "$161B"},
|
||||
{"symbol": "HG=F", "entity_eng": "Copper", "guilds": ["S3", "S2"], "close_usd": 4.15, "change_pct": 2.11, "change_bps": 211, "volume_ratio_20d": 1.22, "market_cap_str": "$211B"},
|
||||
{"symbol": "^VIX", "entity_eng": "VIX", "guilds": ["S2"], "close_usd": 14.20, "change_pct": -5.33, "change_bps": -533, "volume_ratio_20d": 1.10, "market_cap_str": "$0B"},
|
||||
{"symbol": "BTC-USD", "entity_eng": "Bitcoin", "guilds": ["S2", "S6"], "close_usd": 96000.00, "change_pct": 1.93, "change_bps": 193, "volume_ratio_20d": 1.35, "market_cap_str": "$1.90T"},
|
||||
{"symbol": "ETH-USD", "entity_eng": "Ethereum", "guilds": ["S2"], "close_usd": 3600.00, "change_pct": 1.83, "change_bps": 183, "volume_ratio_20d": 1.20, "market_cap_str": "$433B"},
|
||||
{"symbol": "SOL-USD", "entity_eng": "Solana", "guilds": ["S2"], "close_usd": 244.00, "change_pct": 1.29, "change_bps": 129, "volume_ratio_20d": 1.18, "market_cap_str": "$116B"},
|
||||
{"symbol": "COIN", "entity_eng": "Coinbase", "guilds": ["S2", "S6"], "close_usd": 292.00, "change_pct": 2.56, "change_bps": 256, "volume_ratio_20d": 1.40, "market_cap_str": "$73B"},
|
||||
{"symbol": "CEG", "entity_eng": "Constellation", "guilds": ["S4", "S3"], "close_usd": 256.00, "change_pct": 1.16, "change_bps": 116, "volume_ratio_20d": 1.08, "market_cap_str": "$80B"},
|
||||
{"symbol": "LLY", "entity_eng": "Eli Lilly", "guilds": ["S5", "S6"], "close_usd": 777.00, "change_pct": 0.84, "change_bps": 84, "volume_ratio_20d": 0.96, "market_cap_str": "$740B"},
|
||||
{"symbol": "^TNX", "entity_eng": "Treasury", "guilds": ["S6", "S2"], "close_usd": 4.18, "change_pct": -0.71, "change_bps": -71, "volume_ratio_20d": 1.00, "market_cap_str": "$28T"},
|
||||
{"symbol": "BLK", "entity_eng": "BlackRock", "guilds": ["S6"], "close_usd": 1025.00, "change_pct": 1.25, "change_bps": 125, "volume_ratio_20d": 1.02, "market_cap_str": "$153B"},
|
||||
{"symbol": "NVDA", "entity_eng": "Nvidia", "guilds": ["S1", "S3"]},
|
||||
{"symbol": "ASML", "entity_eng": "ASML", "guilds": ["S3", "S6"]},
|
||||
{"symbol": "TSM", "entity_eng": "TSMC", "guilds": ["S3", "S6"]},
|
||||
{"symbol": "ANTHR-PVT", "entity_eng": "Anthropic", "guilds": ["S1", "S2"]},
|
||||
{"symbol": "MSFT", "entity_eng": "Microsoft", "guilds": ["S1", "S6"]},
|
||||
{"symbol": "GOOGL", "entity_eng": "Alphabet", "guilds": ["S1", "S6"]},
|
||||
{"symbol": "META", "entity_eng": "Meta", "guilds": ["S1", "S6"]},
|
||||
{"symbol": "ORCL", "entity_eng": "Oracle", "guilds": ["S1", "S6"]},
|
||||
{"symbol": "AVGO", "entity_eng": "Broadcom", "guilds": ["S3", "S6"]},
|
||||
{"symbol": "ARM", "entity_eng": "Arm", "guilds": ["S3", "S1"]},
|
||||
{"symbol": "AMD", "entity_eng": "AMD", "guilds": ["S3", "S1"]},
|
||||
{"symbol": "PLTR", "entity_eng": "Palantir", "guilds": ["S3", "S6"]},
|
||||
{"symbol": "LMT", "entity_eng": "Lockheed", "guilds": ["S3"]},
|
||||
{"symbol": "RTX", "entity_eng": "Raytheon", "guilds": ["S3"]},
|
||||
{"symbol": "HG=F", "entity_eng": "Copper", "guilds": ["S3", "S2"]},
|
||||
{"symbol": "^VIX", "entity_eng": "VIX", "guilds": ["S2"]},
|
||||
{"symbol": "BTC-USD", "entity_eng": "Bitcoin", "guilds": ["S2", "S6"]},
|
||||
{"symbol": "ETH-USD", "entity_eng": "Ethereum", "guilds": ["S2"]},
|
||||
{"symbol": "SOL-USD", "entity_eng": "Solana", "guilds": ["S2"]},
|
||||
{"symbol": "COIN", "entity_eng": "Coinbase", "guilds": ["S2", "S6"]},
|
||||
{"symbol": "CEG", "entity_eng": "Constellation", "guilds": ["S4", "S3"]},
|
||||
{"symbol": "LLY", "entity_eng": "Eli Lilly", "guilds": ["S5", "S6"]},
|
||||
{"symbol": "^TNX", "entity_eng": "Treasury", "guilds": ["S6", "S2"]},
|
||||
{"symbol": "BLK", "entity_eng": "BlackRock", "guilds": ["S6"]},
|
||||
]
|
||||
|
||||
_USER_AGENT = "Mozilla/5.0 (compatible; HyperstitionStudioQuantCollector/2.0; +urn:io:hyperstitionstud)"
|
||||
@@ -116,18 +122,26 @@ _STOOQ_MAP = {
|
||||
"RTX": "rtx.us", "COIN": "coin.us", "CEG": "ceg.us", "LLY": "lly.us", "BLK": "blk.us",
|
||||
}
|
||||
|
||||
# Precomputed 2-word (noun + prep or verb + article) closures for 333 / 666 / 777intra-instrument verified equations
|
||||
_EQ_CLOSURES_333: dict[int, list[str]] = {
|
||||
137: [
|
||||
71: [
|
||||
"envideea (137) + fohldz (125) + gpu (71) = 333",
|
||||
"daireeoh (137) + fohldz (125) + gpu (71) = 333",
|
||||
],
|
||||
81: [
|
||||
"asml (81) + akselerayshan (256) - 4 = 333",
|
||||
"asml (81) + chaildz (126) + chaildz (126) = 333",
|
||||
],
|
||||
91: [
|
||||
"tsmc (91) + fohldz (125) +ekst (117) = 333",
|
||||
"tsmc (91) + fohldz (125) + tekst (117) = 333",
|
||||
],
|
||||
125: [
|
||||
"envideea (137) + fohldz (125) + gpu (71) = 333",
|
||||
],
|
||||
137: [
|
||||
"envideea (137) + fohldz (125) + gpu (71) = 333",
|
||||
"daireeoh (137) + fohldz (125) + gpu (71) = 333",
|
||||
],
|
||||
163: [
|
||||
"manopalee (163) + in (41) + blakwel (129) = 333",
|
||||
],
|
||||
191: [
|
||||
"derivativ (191) + aiern (92) + tab (50) = 333",
|
||||
@@ -153,7 +167,9 @@ _EQ_CLOSURES_333: dict[int, list[str]] = {
|
||||
|
||||
|
||||
def _fetch_yahoo_chart(symbol: str, timeout: float = 6.0) -> dict[str, Any] | None:
|
||||
"""Source 1: Keyless Yahoo Finance v8 Chart JSON API."""
|
||||
"""Source 1: Keyless Yahoo Finance v8 Chart JSON API (using actual prior trading day close)."""
|
||||
if symbol == "ANTHR-PVT":
|
||||
return None
|
||||
enc_sym = urllib.parse.quote(symbol, safe="")
|
||||
url = f"https://query1.finance.yahoo.com/v8/finance/chart/{enc_sym}?range=1mo&interval=1d"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": _USER_AGENT, "Accept": "application/json"})
|
||||
@@ -162,26 +178,46 @@ def _fetch_yahoo_chart(symbol: str, timeout: float = 6.0) -> dict[str, Any] | No
|
||||
res_list = (data.get("chart") or {}).get("result") or []
|
||||
if not res_list:
|
||||
return None
|
||||
meta = res_list[0].get("meta") or {}
|
||||
ts_list = res_list[0].get("timestamp") or []
|
||||
quotes = (((res_list[0].get("indicators") or {}).get("quote") or [{}])[0])
|
||||
closes = [float(x) for x in (quotes.get("close") or []) if x is not None]
|
||||
vols = [float(x) for x in (quotes.get("volume") or []) if x is not None and x > 0]
|
||||
close_usd = float(meta.get("regularMarketPrice") or (closes[-1] if closes else 0.0))
|
||||
raw_closes = quotes.get("close") or []
|
||||
raw_vols = quotes.get("volume") or []
|
||||
|
||||
valid_pairs = [
|
||||
(ts_list[i], float(raw_closes[i]), float(raw_vols[i]) if i < len(raw_vols) and raw_vols[i] is not None else None)
|
||||
for i in range(min(len(ts_list), len(raw_closes)))
|
||||
if raw_closes[i] is not None
|
||||
]
|
||||
if not valid_pairs:
|
||||
return None
|
||||
|
||||
last_ts, close_usd, last_vol = valid_pairs[-1]
|
||||
if close_usd <= 0:
|
||||
return None
|
||||
prev_close = float(meta.get("chartPreviousClose") or (closes[-2] if len(closes) >= 2 else close_usd))
|
||||
chg_pct = ((close_usd - prev_close) / prev_close * 100.0) if prev_close > 0 else 0.0
|
||||
chg_bps = int(round(chg_pct * 100.0))
|
||||
vol_ratio = 1.0
|
||||
if len(vols) >= 2:
|
||||
avg_v = sum(vols[:-1][-20:]) / max(1, len(vols[:-1][-20:]))
|
||||
obs_date = datetime.datetime.fromtimestamp(last_ts, datetime.timezone.utc).strftime("%Y-%m-%d")
|
||||
|
||||
prev_close = valid_pairs[-2][1] if len(valid_pairs) >= 2 else None
|
||||
if prev_close and prev_close > 0:
|
||||
chg_pct: float | None = round((close_usd - prev_close) / prev_close * 100.0, 2)
|
||||
chg_bps: int | None = int(round(chg_pct * 100.0))
|
||||
else:
|
||||
chg_pct = None
|
||||
chg_bps = None
|
||||
|
||||
vol_ratio: float | None = None
|
||||
prior_vols = [x[2] for x in valid_pairs[:-1][-20:] if x[2] is not None and x[2] > 0]
|
||||
if last_vol is not None and last_vol > 0 and prior_vols:
|
||||
avg_v = sum(prior_vols) / len(prior_vols)
|
||||
if avg_v > 0:
|
||||
vol_ratio = round(vols[-1] / avg_v, 2)
|
||||
vol_ratio = round(last_vol / avg_v, 2)
|
||||
|
||||
return {
|
||||
"observation_date_utc": obs_date,
|
||||
"close_usd": round(close_usd, 2),
|
||||
"change_pct": round(chg_pct, 2),
|
||||
"change_pct": chg_pct,
|
||||
"change_bps": chg_bps,
|
||||
"volume_ratio_20d": vol_ratio,
|
||||
"market_cap_str": None,
|
||||
"feed_source": "yahoo_v8_json",
|
||||
}
|
||||
|
||||
@@ -199,20 +235,22 @@ def _fetch_stooq_csv(symbol: str, timeout: float = 6.0) -> dict[str, Any] | None
|
||||
if not rows or "Close" not in rows[-1] or rows[-1]["Close"] in ("", "N/D", None):
|
||||
return None
|
||||
close_usd = float(rows[-1]["Close"])
|
||||
prev_close = float(rows[-2]["Close"]) if len(rows) >= 2 and rows[-2].get("Close") not in ("", "N/D", None) else close_usd
|
||||
chg_pct = ((close_usd - prev_close) / prev_close * 100.0) if prev_close > 0 else 0.0
|
||||
chg_bps = int(round(chg_pct * 100.0))
|
||||
prev_close = float(rows[-2]["Close"]) if len(rows) >= 2 and rows[-2].get("Close") not in ("", "N/D", None) else None
|
||||
chg_pct = round((close_usd - prev_close) / prev_close * 100.0, 2) if (prev_close and prev_close > 0) else None
|
||||
chg_bps = int(round(chg_pct * 100.0)) if chg_pct is not None else None
|
||||
vols = [float(r["Volume"]) for r in rows[-21:] if r.get("Volume") and r["Volume"].replace(".", "").isdigit()]
|
||||
vol_ratio = 1.0
|
||||
vol_ratio = None
|
||||
if len(vols) >= 2:
|
||||
avg_v = sum(vols[:-1]) / max(1, len(vols[:-1]))
|
||||
if avg_v > 0:
|
||||
vol_ratio = round(vols[-1] / avg_v, 2)
|
||||
return {
|
||||
"observation_date_utc": rows[-1].get("Date"),
|
||||
"close_usd": round(close_usd, 2),
|
||||
"change_pct": round(chg_pct, 2),
|
||||
"change_pct": chg_pct,
|
||||
"change_bps": chg_bps,
|
||||
"volume_ratio_20d": vol_ratio,
|
||||
"market_cap_str": None,
|
||||
"feed_source": "stooq_csv",
|
||||
}
|
||||
|
||||
@@ -228,51 +266,109 @@ def _fetch_coingecko_crypto(timeout: float = 6.0) -> dict[str, dict[str, Any]]:
|
||||
for sym, cg_id in _COINGECKO_MAP.items():
|
||||
if cg_id in data and "usd" in data[cg_id]:
|
||||
c_usd = float(data[cg_id]["usd"])
|
||||
chg_pct = float(data[cg_id].get("usd_24h_change") or 0.0)
|
||||
chg_raw = data[cg_id].get("usd_24h_change")
|
||||
chg_pct = round(float(chg_raw), 2) if chg_raw is not None else None
|
||||
mcap = float(data[cg_id].get("usd_market_cap") or 0.0)
|
||||
mcap_str = f"${mcap / 1e12:.2f}T" if mcap >= 1e12 else (f"${int(round(mcap / 1e9))}B" if mcap >= 1e9 else "$0B")
|
||||
mcap_str = f"${mcap / 1e12:.2f}T" if mcap >= 1e12 else (f"${int(round(mcap / 1e9))}B" if mcap >= 1e9 else None)
|
||||
out[sym] = {
|
||||
"close_usd": round(c_usd, 2),
|
||||
"change_pct": round(chg_pct, 2),
|
||||
"change_bps": int(round(chg_pct * 100.0)),
|
||||
"change_pct": chg_pct,
|
||||
"change_bps": int(round(chg_pct * 100.0)) if chg_pct is not None else None,
|
||||
"market_cap_str": mcap_str,
|
||||
"feed_source": "coingecko_v3_json",
|
||||
}
|
||||
return out
|
||||
|
||||
|
||||
def _load_real_history_latest_bars() -> dict[str, dict[str, Any]]:
|
||||
"""
|
||||
Read the latest real exchange bar per symbol from `site/quant/real-market-history.json`
|
||||
(populated strictly from real Yahoo Finance v8 / CoinGecko responses; never synthesized).
|
||||
"""
|
||||
cfg = load_workspace_config()
|
||||
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, Any]] = {}
|
||||
for sym, sym_obj in (raw.get("instruments") or {}).items():
|
||||
bars_by_date = sym_obj.get("bars_by_date") or {}
|
||||
if bars_by_date:
|
||||
latest_dt = sorted(bars_by_date.keys())[-1]
|
||||
bar = dict(bars_by_date[latest_dt])
|
||||
bar["observation_date_utc"] = latest_dt
|
||||
out[sym] = bar
|
||||
return out
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
def fetch_live_watchlist(
|
||||
base_watchlist: list[dict[str, Any]] | None = None,
|
||||
timeout: float = 6.0,
|
||||
allow_live_network: bool = True,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""
|
||||
Attempt multi-source keyless HTTP ingestion (Yahoo Finance v8 -> Stooq CSV -> CoinGecko JSON),
|
||||
falling back deterministically per instrument to CANONICAL_WATCHLIST_24 if offline or rate-limited.
|
||||
Resolve real market observations for the 24 watchlist instruments.
|
||||
Never invents or synthesizes missing data: if an instrument has no real exchange observation
|
||||
(e.g. private company `ANTHR-PVT`), its numeric fields remain `None` and `status` is
|
||||
`"No data available"`.
|
||||
"""
|
||||
watchlist = [dict(x) for x in (base_watchlist or CANONICAL_WATCHLIST_24)]
|
||||
cached_latest = _load_real_history_latest_bars()
|
||||
cg_quotes: dict[str, dict[str, Any]] = {}
|
||||
try:
|
||||
cg_quotes = _fetch_coingecko_crypto(timeout=timeout)
|
||||
except Exception:
|
||||
cg_quotes = {}
|
||||
if allow_live_network:
|
||||
try:
|
||||
cg_quotes = _fetch_coingecko_crypto(timeout=timeout)
|
||||
except Exception:
|
||||
cg_quotes = {}
|
||||
|
||||
def _resolve_one(item: dict[str, Any]) -> dict[str, Any]:
|
||||
sym = item["symbol"]
|
||||
merged = dict(item)
|
||||
merged["feed_source"] = "canonical_snapshot"
|
||||
merged = {
|
||||
"symbol": sym,
|
||||
"entity_eng": item["entity_eng"],
|
||||
"guilds": list(item["guilds"]),
|
||||
"data_available": False,
|
||||
"status": NO_DATA_AVAILABLE,
|
||||
"feed_source": None,
|
||||
"observation_date_utc": None,
|
||||
"close_usd": None,
|
||||
"change_pct": None,
|
||||
"change_bps": None,
|
||||
"volume_ratio_20d": None,
|
||||
"market_cap_str": None,
|
||||
}
|
||||
if sym == "ANTHR-PVT":
|
||||
merged["status"] = "No data available (private entity — not publicly traded)"
|
||||
return merged
|
||||
if sym in cg_quotes:
|
||||
merged.update(cg_quotes[sym])
|
||||
|
||||
if allow_live_network:
|
||||
for fetcher in (_fetch_yahoo_chart, _fetch_stooq_csv):
|
||||
try:
|
||||
q = fetcher(sym, timeout=timeout)
|
||||
if q and q.get("close_usd") is not None:
|
||||
merged.update(q)
|
||||
if sym in cg_quotes and cg_quotes[sym].get("market_cap_str"):
|
||||
merged["market_cap_str"] = cg_quotes[sym]["market_cap_str"]
|
||||
merged["data_available"] = True
|
||||
merged["status"] = "ok"
|
||||
return merged
|
||||
except Exception:
|
||||
continue
|
||||
if sym in cg_quotes and cg_quotes[sym].get("close_usd") is not None:
|
||||
merged.update(cg_quotes[sym])
|
||||
merged["data_available"] = True
|
||||
merged["status"] = "ok"
|
||||
return merged
|
||||
|
||||
if sym in cached_latest and cached_latest[sym].get("close_usd") is not None:
|
||||
merged.update(cached_latest[sym])
|
||||
merged["data_available"] = True
|
||||
merged["status"] = "ok"
|
||||
return merged
|
||||
for fetcher in (_fetch_yahoo_chart, _fetch_stooq_csv):
|
||||
try:
|
||||
q = fetcher(sym, timeout=timeout)
|
||||
if q:
|
||||
merged.update(q)
|
||||
return merged
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
return merged
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:
|
||||
@@ -289,26 +385,27 @@ def build_financial_quant_harvest(
|
||||
with ReadOnlyIsolationGuard(cfg.read_only_files) as guard:
|
||||
if snapshot_path and Path(snapshot_path).is_file():
|
||||
raw_watchlist = json.loads(Path(snapshot_path).read_text(encoding="utf-8"))
|
||||
elif live_fetch:
|
||||
raw_watchlist = fetch_live_watchlist(CANONICAL_WATCHLIST_24)
|
||||
else:
|
||||
raw_watchlist = [dict(x) for x in CANONICAL_WATCHLIST_24]
|
||||
raw_watchlist = fetch_live_watchlist(
|
||||
CANONICAL_WATCHLIST_24,
|
||||
allow_live_network=bool(live_fetch),
|
||||
)
|
||||
|
||||
# Batch translate entity names and all 4 quantitative normalization modes:
|
||||
# Mode 1: q_digit, Mode 2: q_spoken_int, Mode 3: q_spoken_scaled, Mode 4: q_delta_bps
|
||||
phrases_to_translate: list[str] = []
|
||||
for item in raw_watchlist:
|
||||
phrases_to_translate.append(item["entity_eng"])
|
||||
close_int = int(round(float(item["close_usd"])))
|
||||
bps_abs = abs(int(item["change_bps"]))
|
||||
mcap_sp_eng = expand_quant_spoken(str(item.get("market_cap_str", "$0B")))
|
||||
phrases_to_translate.append(int_to_spoken_words(close_int))
|
||||
phrases_to_translate.append(int_to_spoken_words(bps_abs))
|
||||
phrases_to_translate.append(mcap_sp_eng)
|
||||
if item.get("close_usd") is not None:
|
||||
close_int = int(round(float(item["close_usd"])))
|
||||
phrases_to_translate.append(int_to_spoken_words(close_int))
|
||||
if item.get("change_bps") is not None:
|
||||
bps_abs = abs(int(item["change_bps"]))
|
||||
phrases_to_translate.append(int_to_spoken_words(bps_abs))
|
||||
mcap_raw = item.get("market_cap_str")
|
||||
if mcap_raw and mcap_raw != NO_DATA_AVAILABLE:
|
||||
phrases_to_translate.append(expand_quant_spoken(str(mcap_raw)))
|
||||
|
||||
ing_map = translate_batch(phrases_to_translate)
|
||||
|
||||
# Resolve same-day news headlines for cross-join (Check 4 in PLAN-QUANTITATIVE-FINANCIAL-TELEMETRY-PIPELINE)
|
||||
effective_news_path = Path(join_news_path) if join_news_path else (cfg.archive_dir / "news-aq-harvest-latest.json")
|
||||
news_entities: dict[str, list[str]] = {}
|
||||
if effective_news_path.is_file():
|
||||
@@ -350,48 +447,103 @@ def build_financial_quant_harvest(
|
||||
instruments_out: list[dict[str, Any]] = []
|
||||
active_memetic_states: set[str] = set()
|
||||
emergent_m7_quant_triggers: list[dict[str, Any]] = []
|
||||
vix_close_val = 14.2
|
||||
us10y_yield_val = 4.18
|
||||
vix_close_val: float | None = None
|
||||
us10y_yield_val: float | None = None
|
||||
|
||||
for item in raw_watchlist:
|
||||
sym = item["symbol"]
|
||||
if sym == "^VIX":
|
||||
vix_close_val = float(item["close_usd"])
|
||||
elif sym == "^TNX":
|
||||
us10y_yield_val = float(item["close_usd"])
|
||||
|
||||
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)
|
||||
|
||||
close_int = int(round(float(item["close_usd"])))
|
||||
bps_abs = abs(int(item["change_bps"]))
|
||||
mcap_s = str(item.get("market_cap_str", "$0B"))
|
||||
|
||||
close_sp_eng = int_to_spoken_words(close_int)
|
||||
close_sp_ing = ing_map.get(close_sp_eng, close_sp_eng)
|
||||
bps_sp_eng = int_to_spoken_words(bps_abs)
|
||||
bps_sp_ing = ing_map.get(bps_sp_eng, bps_sp_eng)
|
||||
mcap_sp_eng = expand_quant_spoken(mcap_s)
|
||||
mcap_sp_ing = ing_map.get(mcap_sp_eng, mcap_sp_eng)
|
||||
|
||||
close_dig_aq = compute_aq(str(close_int))
|
||||
close_sp_aq = compute_aq(close_sp_ing)
|
||||
bps_dig_aq = compute_aq(str(bps_abs))
|
||||
bps_sp_aq = compute_aq(bps_sp_ing)
|
||||
mcap_sp_aq = compute_aq(mcap_sp_ing)
|
||||
|
||||
locks: list[dict[str, Any]] = []
|
||||
co_present = sym in news_entities
|
||||
|
||||
# Scope 1: Intra-Instrument Self-Locks & Repdigit Attractors
|
||||
has_price = item.get("close_usd") is not None
|
||||
if not has_price:
|
||||
instruments_out.append({
|
||||
"symbol": sym,
|
||||
"entity_eng": ent_eng,
|
||||
"entity_ing": ent_ing,
|
||||
"entity_eng_aq": ent_eng_aq,
|
||||
"entity_ing_aq": ent_ing_aq,
|
||||
"guilds": item["guilds"],
|
||||
"data_available": False,
|
||||
"status": item.get("status") or NO_DATA_AVAILABLE,
|
||||
"feed_source": None,
|
||||
"observation_date_utc": None,
|
||||
"co_present_in_news_wire": co_present,
|
||||
"metrics": {
|
||||
"close_usd": None,
|
||||
"change_pct": None,
|
||||
"change_bps": None,
|
||||
"volume_ratio_20d": None,
|
||||
"market_cap_str": NO_DATA_AVAILABLE,
|
||||
},
|
||||
"quant_encodings": {
|
||||
"status": NO_DATA_AVAILABLE,
|
||||
"close_digit_aq": None,
|
||||
"close_spoken_eng": NO_DATA_AVAILABLE,
|
||||
"close_spoken_ing": NO_DATA_AVAILABLE,
|
||||
"close_spoken_ing_aq": None,
|
||||
"close_spoken_prime_rank": None,
|
||||
"scaled_cap_spoken_eng": NO_DATA_AVAILABLE,
|
||||
"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_ing": NO_DATA_AVAILABLE,
|
||||
"bps_spoken_ing_aq": None,
|
||||
},
|
||||
"contingent_locks": [],
|
||||
})
|
||||
continue
|
||||
|
||||
close_val = float(item["close_usd"])
|
||||
if sym == "^VIX":
|
||||
vix_close_val = close_val
|
||||
elif sym == "^TNX":
|
||||
us10y_yield_val = close_val
|
||||
|
||||
close_int = int(round(close_val))
|
||||
close_sp_eng = int_to_spoken_words(close_int)
|
||||
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 = item.get("change_bps")
|
||||
chg_pct_raw = item.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_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_ing = NO_DATA_AVAILABLE
|
||||
bps_dig_aq = None
|
||||
bps_sp_aq = None
|
||||
|
||||
mcap_raw = item.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_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_ing = NO_DATA_AVAILABLE
|
||||
mcap_sp_aq = None
|
||||
|
||||
locks: list[dict[str, Any]] = []
|
||||
|
||||
if close_int == ent_ing_aq or close_int == ent_eng_aq:
|
||||
eqs = list(_EQ_CLOSURES_333.get(close_int, []))
|
||||
locks.append({
|
||||
"scope": "SCOPE1_INTRA_INSTRUMENT_SELF_LOCK",
|
||||
"description": f"{sym} integer close (${close_int}) equals its own AQ coordinate ({ent_ing}={ent_ing_aq}).",
|
||||
"verified_equations": eqs,
|
||||
"verified_equations": list(_EQ_CLOSURES_333.get(close_int, [])),
|
||||
})
|
||||
if is_repdigit_37(close_sp_aq) or is_repdigit_37(close_int):
|
||||
rep_val = close_sp_aq if is_repdigit_37(close_sp_aq) else close_int
|
||||
@@ -400,15 +552,21 @@ def build_financial_quant_harvest(
|
||||
"description": f"{sym} close ${close_int} ('{close_sp_ing}') locks onto repdigit attractor {rep_val}.",
|
||||
"verified_equations": [f"{close_sp_ing} = {close_sp_aq}"],
|
||||
})
|
||||
if bps_abs == ent_ing_aq or bps_abs == ent_eng_aq:
|
||||
if bps_abs is not None and (bps_abs == ent_ing_aq or bps_abs == ent_eng_aq):
|
||||
locks.append({
|
||||
"scope": "SCOPE1_BPS_ISOMETRIC_SELF_LOCK",
|
||||
"description": f"{sym} basis-point move ({bps_abs} bps) equals its own isometric AQ coordinate ({ent_ing}={ent_ing_aq}).",
|
||||
"verified_equations": list(_EQ_CLOSURES_333.get(bps_abs, [])),
|
||||
})
|
||||
|
||||
# Scope 2: S1-S6 Signature Ring Migrations
|
||||
for coord_val, label_mode in ((close_int, "close_int"), (close_sp_aq, "close_spoken_aq"), (bps_abs, "change_bps")):
|
||||
coord_checks: list[tuple[int, str]] = [
|
||||
(close_int, "close_int"),
|
||||
(close_sp_aq, "close_spoken_aq"),
|
||||
]
|
||||
if bps_abs is not None:
|
||||
coord_checks.append((bps_abs, "change_bps"))
|
||||
|
||||
for coord_val, label_mode in coord_checks:
|
||||
if coord_val in S1_S6_SIGNATURE_RINGS:
|
||||
locks.append({
|
||||
"scope": "SCOPE2_S1_S6_RING_MIGRATION",
|
||||
@@ -425,17 +583,15 @@ def build_financial_quant_harvest(
|
||||
"partners": S1_S6_SIGNATURE_RINGS[129],
|
||||
})
|
||||
|
||||
# Scope 3: Objective Numerical State-Gate Activation
|
||||
vol_ratio = float(item.get("volume_ratio_20d", 1.0))
|
||||
chg_pct = float(item.get("change_pct", 0.0))
|
||||
if vol_ratio < 0.45 and abs(chg_pct) < 0.10:
|
||||
vol_ratio = float(item["volume_ratio_20d"]) if item.get("volume_ratio_20d") is not None else None
|
||||
chg_pct = float(chg_pct_raw) if chg_pct_raw is not None else None
|
||||
if vol_ratio is not None and chg_pct is not None and vol_ratio < 0.45 and abs(chg_pct) < 0.10:
|
||||
active_memetic_states.add("M1_ENTROPIC_STAGNATION")
|
||||
if chg_pct <= -5.0 or vol_ratio >= 2.5 or (sym == "^VIX" and close_int >= 25):
|
||||
if (chg_pct is not None and chg_pct <= -5.0) or (vol_ratio is not None and vol_ratio >= 2.5) or (sym == "^VIX" and close_int >= 25):
|
||||
active_memetic_states.add("M2_FLASH_CRASH_TEMPLEX_SURGE")
|
||||
if mcap_s.endswith("T"):
|
||||
active_memetic_states.add("M3_LEVIATHAN_TRILLION_CAP_CONCENTRATION")
|
||||
|
||||
# Scope 4 / News-Wire Co-Presence Lock (when entity is in news wire AND triggers Scope 1-2 lock)
|
||||
if co_present and locks:
|
||||
locks.append({
|
||||
"scope": "SCOPE3_NEWS_WIRE_CO_PRESENCE_LOCK",
|
||||
@@ -450,15 +606,20 @@ def build_financial_quant_harvest(
|
||||
"entity_eng_aq": ent_eng_aq,
|
||||
"entity_ing_aq": ent_ing_aq,
|
||||
"guilds": item["guilds"],
|
||||
"data_available": True,
|
||||
"status": "ok",
|
||||
"feed_source": item.get("feed_source") or "real_market_cache",
|
||||
"observation_date_utc": item.get("observation_date_utc"),
|
||||
"co_present_in_news_wire": co_present,
|
||||
"metrics": {
|
||||
"close_usd": item["close_usd"],
|
||||
"close_usd": close_val,
|
||||
"change_pct": chg_pct,
|
||||
"change_bps": item["change_bps"],
|
||||
"change_bps": int(chg_bps_raw) if chg_bps_raw is not None else None,
|
||||
"volume_ratio_20d": vol_ratio,
|
||||
"market_cap_str": mcap_s,
|
||||
},
|
||||
"quant_encodings": {
|
||||
"status": "ok",
|
||||
"close_digit_aq": close_dig_aq,
|
||||
"close_spoken_eng": close_sp_eng,
|
||||
"close_spoken_ing": close_sp_ing,
|
||||
@@ -475,41 +636,29 @@ def build_financial_quant_harvest(
|
||||
"contingent_locks": locks,
|
||||
})
|
||||
|
||||
# Evaluate registered anchor revisions against taxonomy/quantitative-economic-anchors.json
|
||||
anc_revs = [
|
||||
{
|
||||
"anchor_id": "anthropic_ipo_price_83",
|
||||
"q_old_digit": "$83",
|
||||
"q_new_digit": "$89",
|
||||
"q_old_spoken_ing": "aytee three (202)",
|
||||
"q_new_spoken_ing": "aytee nain (193 [44th PRIME])",
|
||||
"migration": "Migrates into 193 == anthropik == flash krash == Dario Amodei [Gen 0] (Scope 1 + Scope 2 Exact Self-Lock).",
|
||||
"counter_substitutions": {
|
||||
"path_a_verb_swap": "hohldz (127) ->iksprest / +9 shift",
|
||||
"path_b_tail_chokepoint": "tab (50) -> 59 (arm [Iso]) in 'aytee nain in dha arm = 333'",
|
||||
"verified_333": "aytee nain (193) + koinbays (140) = 333",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
receipt = guard.audit_receipt()
|
||||
available_count = sum(1 for x in instruments_out if x.get("data_available"))
|
||||
unavailable_syms = [x["symbol"] for x in instruments_out if not x.get("data_available")]
|
||||
payload: dict[str, Any] = {
|
||||
"$schema": "./schemas/v1/financial-aq-harvest.schema.json",
|
||||
"$id": "urn:io:hyperstitionstud:schema:v1:financial-aq-harvest",
|
||||
"version": "2.0.22",
|
||||
"version": "2.0.23",
|
||||
"target_date_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
|
||||
"harvest_mode": harvest_mode,
|
||||
"synthetic_data_eliminated": True,
|
||||
"regime_summary": {
|
||||
"instrument_count": len(instruments_out),
|
||||
"instruments_with_data_count": available_count,
|
||||
"instruments_without_data": unavailable_syms,
|
||||
"total_contingent_locks": sum(len(x["contingent_locks"]) for x in instruments_out),
|
||||
"vix_close": vix_close_val,
|
||||
"us10y_yield_pct": us10y_yield_val,
|
||||
"vix_close": vix_close_val if vix_close_val is not None else NO_DATA_AVAILABLE,
|
||||
"us10y_yield_pct": us10y_yield_val if us10y_yield_val is not None else NO_DATA_AVAILABLE,
|
||||
"news_wire_co_present_symbols": sorted(news_entities.keys()),
|
||||
"active_memetic_states": sorted(active_memetic_states),
|
||||
"emergent_m7_quant_triggers": emergent_m7_quant_triggers,
|
||||
},
|
||||
"instruments": instruments_out,
|
||||
"anchor_revisions_detected": anc_revs,
|
||||
"anchor_revisions_detected": [],
|
||||
"isolation_receipt": receipt,
|
||||
}
|
||||
payload["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1(payload)}
|
||||
@@ -517,7 +666,7 @@ def build_financial_quant_harvest(
|
||||
|
||||
|
||||
def synthesize_quant_dossier_markdown(payload: dict[str, Any]) -> str:
|
||||
"""Synthesize a verified 7X-dossier-quant-YYYY-MM-DD.md Markdown dossier from a harvest payload."""
|
||||
"""Format a Markdown report strictly from real observed harvest data (stating 'No data available' when absent)."""
|
||||
dt = payload["target_date_utc"]
|
||||
mode = payload["harvest_mode"]
|
||||
cid = payload["ipld_dag_json_cidv1"]["/"]
|
||||
@@ -527,43 +676,35 @@ def synthesize_quant_dossier_markdown(payload: dict[str, Any]) -> str:
|
||||
"",
|
||||
f"- **Target Date (UTC):** `{dt}`",
|
||||
f"- **Harvest Mode:** `{mode}`",
|
||||
f"- **Instruments Audited:** `{reg['instrument_count']}` (`S1–S6` Canonical Watchlist)",
|
||||
f"- **Instruments Audited:** `{reg['instrument_count']}` (`{reg.get('instruments_with_data_count', 0)}` with market data; `{', '.join(reg.get('instruments_without_data', [])) or 'none'}`: No data available)",
|
||||
f"- **Total Contingent Locks:** `{reg['total_contingent_locks']}`",
|
||||
f"- **Active Memetic States:** `{', '.join(reg['active_memetic_states'])}`",
|
||||
f"- **Active Memetic States:** `{', '.join(reg['active_memetic_states']) or 'None'}`",
|
||||
f"- **IPLD `dag-json` `CIDv1`:** `{cid}`",
|
||||
"",
|
||||
"## 1. Scope 1 & Scope 2 Instrument Locks",
|
||||
"## 1. Instrument Telemetry & Observed Locks",
|
||||
"",
|
||||
"| Symbol | Entity (`Gen 0 -> Gen 1`) | Close (USD) | Spoken Close (`Gen 1` AQ) | Change (bps) | Active Contingent Locks |",
|
||||
"| Symbol | Entity (`Gen 0 -> Gen 1`) | Close (USD) | Spoken Close (`Gen 1` AQ) | Change (bps) | Status / Active Contingent Locks |",
|
||||
"| :--- | :--- | :---: | :--- | :---: | :--- |",
|
||||
]
|
||||
for inst in payload["instruments"]:
|
||||
if not inst["contingent_locks"]:
|
||||
if not inst.get("data_available"):
|
||||
lines.append(
|
||||
f"| `{inst['symbol']}` | `{inst['entity_eng']} -> {inst['entity_ing']}` (`{inst['entity_eng_aq']}->{inst['entity_ing_aq']}`) | "
|
||||
f"*{NO_DATA_AVAILABLE}* | *{NO_DATA_AVAILABLE}* | *{NO_DATA_AVAILABLE}* | {inst.get('status', NO_DATA_AVAILABLE)} |"
|
||||
)
|
||||
continue
|
||||
q = inst["quant_encodings"]
|
||||
lock_strs = "; ".join(
|
||||
l.get("description") or f"{l['scope']} ({l.get('coordinate')} -> {', '.join(l.get('ring_partners', []))})"
|
||||
for l in inst["contingent_locks"]
|
||||
)
|
||||
) or "No locks triggered"
|
||||
bps_disp = inst["metrics"]["change_bps"] if inst["metrics"]["change_bps"] is not None else NO_DATA_AVAILABLE
|
||||
lines.append(
|
||||
f"| `{inst['symbol']}` | `{inst['entity_eng']} -> {inst['entity_ing']}` (`{inst['entity_eng_aq']}->{inst['entity_ing_aq']}`) | "
|
||||
f"`${inst['metrics']['close_usd']}` | `{q['close_spoken_ing']}` (`{q['close_spoken_ing_aq']}`) | "
|
||||
f"`{inst['metrics']['change_bps']}` | {lock_strs} |"
|
||||
f"`{bps_disp}` | {lock_strs} |"
|
||||
)
|
||||
lines.extend([
|
||||
"",
|
||||
"## 2. Verified Multi-Scale (`333 / 666 / 777`) Quantitative Equations",
|
||||
"",
|
||||
"- `envideea fohldz gpu` (\"Nvidia folds GPU\") — `envideea (137) + fohldz (125) + gpu (71) = 333`",
|
||||
"- `daireeoh fohldz gpu` (\"Dario folds GPU\") — `daireeoh (137) + fohldz (125) + gpu (71) = 333`",
|
||||
"- `anthropik koinbays` (\"Anthropic Coinbase\") — `anthropik (193) + koinbays (140) = 333`",
|
||||
"- `flash krash koinbays` (\"flash crash Coinbase\") — `flash krash (193) + koinbays (140) = 333`",
|
||||
"- `lap for siks bilyan` (\"lap for six billion\") — `lap (56) + for (66) + siks bilyan (211) = 333`",
|
||||
"- `lap for koper waier` (\"lap for copper wire\") — `lap (56) + for (66) + koper waier (211) = 333`",
|
||||
"- `aytee nain in dha arm` (\"eighty nine in the Arm\") — `aytee (98) + nain (95) + in (41) + dha (40) + arm (59) = 333`",
|
||||
"- `siks bilyan hohldz dha kohld asml in gpu` (\"six billion holds the cold ASML in GPU\") — `siks (76) + bilyan (135) + hohldz (127) + dha (40) + kohld (95) + asml (81) + in (41) + gpu (71) = 666`",
|
||||
"",
|
||||
])
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@@ -571,9 +712,9 @@ def main(argv: list[str] | None = None) -> int:
|
||||
ap = argparse.ArgumentParser(prog="hs-quant-harvest", description="Periodic Quantitative Financial Telemetry & Contingent Meaning Collector.")
|
||||
ap.add_argument("--mode", choices=["us-closing-bell", "utc-rollover"], default="us-closing-bell")
|
||||
ap.add_argument("--from-snapshot", default=None, help="Optional offline JSON snapshot file.")
|
||||
ap.add_argument("--live", action="store_true", help="Attempt live keyless HTTP fetch (Yahoo v8 / Stooq CSV / CoinGecko) with snapshot fallback.")
|
||||
ap.add_argument("--live", action="store_true", help="Attempt live keyless HTTP fetch (Yahoo v8 / Stooq CSV / CoinGecko).")
|
||||
ap.add_argument("--join-news", default=None, help="Optional path to news-aq-harvest-latest.json.")
|
||||
ap.add_argument("--write-dossier", default=None, help="Optional path to emit synthesized Markdown quant dossier.")
|
||||
ap.add_argument("--write-dossier", default=None, help="Optional path to emit Markdown quant report.")
|
||||
ap.add_argument("--out", default=None, help="Output JSON path (default: <archive_dir>/financial-aq-harvest-latest.json).")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
@@ -593,7 +734,6 @@ def main(argv: list[str] | None = None) -> int:
|
||||
d_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
d_path.write_text(synthesize_quant_dossier_markdown(payload), encoding="utf-8")
|
||||
|
||||
# Refresh the periodic time-series bundle (/quant/) whenever hs-quant-harvest runs
|
||||
from hyperstitionstud_io.quant.timeseries import build_quant_timeseries_bundle
|
||||
ts_bundle = build_quant_timeseries_bundle(write_files=True)
|
||||
|
||||
@@ -603,6 +743,8 @@ def main(argv: list[str] | None = None) -> int:
|
||||
"output_path": str(out_path),
|
||||
"harvest_mode": payload["harvest_mode"],
|
||||
"instrument_count": payload["regime_summary"]["instrument_count"],
|
||||
"instruments_with_data_count": payload["regime_summary"]["instruments_with_data_count"],
|
||||
"instruments_without_data": payload["regime_summary"]["instruments_without_data"],
|
||||
"total_contingent_locks": payload["regime_summary"]["total_contingent_locks"],
|
||||
"news_wire_co_present_symbols": payload["regime_summary"]["news_wire_co_present_symbols"],
|
||||
"active_memetic_states": payload["regime_summary"]["active_memetic_states"],
|
||||
|
||||
@@ -34,15 +34,11 @@ from hyperstitionstud_io.ciphers import (
|
||||
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.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,
|
||||
)
|
||||
|
||||
@@ -145,29 +141,35 @@ def resolve_tradingview_target(symbol: str) -> dict[str, str]:
|
||||
return {"tradingview_symbol": tv_sym, "tradingview_url": tv_url}
|
||||
|
||||
|
||||
def _make_sparkline(values: list[float]) -> str:
|
||||
if not values:
|
||||
return ""
|
||||
lo, hi = min(values), max(values)
|
||||
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:
|
||||
idx = int(round((v - lo) / span * (len(_SPARK_BLOCKS) - 1)))
|
||||
out.append(_SPARK_BLOCKS[max(0, min(len(_SPARK_BLOCKS) - 1, idx))])
|
||||
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], ys: list[float]) -> float:
|
||||
n = min(len(xs), len(ys))
|
||||
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 0.0
|
||||
mx = sum(xs[:n]) / n
|
||||
my = sum(ys[:n]) / n
|
||||
num = sum((xs[i] - mx) * (ys[i] - my) for i in range(n))
|
||||
dx = math.sqrt(sum((xs[i] - mx) ** 2 for i in range(n)))
|
||||
dy = math.sqrt(sum((ys[i] - my) ** 2 for i in range(n)))
|
||||
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 0.0
|
||||
return None
|
||||
return round(num / (dx * dy), 3)
|
||||
|
||||
|
||||
@@ -243,144 +245,123 @@ def _extract_dated_news_dossiers(archive_dir: Path) -> dict[str, dict[str, Any]]
|
||||
return dossiers_by_date
|
||||
|
||||
|
||||
def _generate_deterministic_bar_for_date(
|
||||
item: dict[str, Any],
|
||||
dt_str: str,
|
||||
day_index: int,
|
||||
total_days: int,
|
||||
) -> dict[str, Any]:
|
||||
def _load_real_market_history_bars(cfg: Any) -> dict[str, dict[str, dict[str, Any]]]:
|
||||
"""
|
||||
Generate the deterministic daily closing-bell bar for date `dt_str` anchored to the
|
||||
canonical 2026-11-30 closing-bell telemetry snapshot so the final bar (t = N-1) equals
|
||||
CANONICAL_WATCHLIST_24 exactly and earlier bars trace a reproducible trajectory.
|
||||
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"`.
|
||||
"""
|
||||
sym = item["symbol"]
|
||||
base_close = float(item["close_usd"])
|
||||
base_chg_pct = float(item["change_pct"])
|
||||
base_bps = int(item["change_bps"])
|
||||
base_vol = float(item["volume_ratio_20d"])
|
||||
mcap_s = str(item["market_cap_str"])
|
||||
|
||||
if day_index == total_days - 1:
|
||||
return {
|
||||
"close_usd": base_close,
|
||||
"change_pct": base_chg_pct,
|
||||
"change_bps": base_bps,
|
||||
"volume_ratio_20d": base_vol,
|
||||
"market_cap_str": mcap_s,
|
||||
}
|
||||
|
||||
# Special step-series handling for ANTHR-PVT ($83 pre-Nov 18 -> $89 from Nov 18 onward)
|
||||
if sym == "ANTHR-PVT":
|
||||
close_v = 83.0 if dt_str < "2026-11-18" else (89.0 if dt_str >= "2026-11-26" else 86.0)
|
||||
bps_v = 0 if dt_str < "2026-11-18" else (723 if dt_str == "2026-11-26" else 125)
|
||||
return {
|
||||
"close_usd": close_v,
|
||||
"change_pct": round(bps_v / 100.0, 2),
|
||||
"change_bps": bps_v,
|
||||
"volume_ratio_20d": 1.60 if bps_v >= 200 else 1.05,
|
||||
"market_cap_str": "$57B" if close_v < 89 else "$61B",
|
||||
}
|
||||
|
||||
seed_bytes = hashlib.sha256(f"{sym}:{dt_str}:v2".encode("utf-8")).digest()
|
||||
wave_a = ((seed_bytes[0] / 255.0) - 0.5) * 2.0
|
||||
wave_b = ((seed_bytes[1] / 255.0) - 0.5) * 2.0
|
||||
rem = (total_days - 1 - day_index) / float(max(1, total_days - 1))
|
||||
|
||||
if base_close >= 20.0:
|
||||
# Step integer prices across nearby coordinates including occasional signature ring hits
|
||||
offset_int = int(round(wave_a * 6.0 * rem + 3.0 * math.sin(day_index * 0.55)))
|
||||
close_v = float(max(1, int(round(base_close)) + offset_int))
|
||||
else:
|
||||
close_v = round(max(0.5, base_close * (1.0 + 0.04 * wave_a * rem)), 2)
|
||||
|
||||
bps_v = int(round(base_bps * 0.35 + wave_b * 185.0))
|
||||
# Periodically snap basis-point moves onto canonical S1-S6 signature ring integers on resonant days
|
||||
ring_candidates = (71, 81, 91, 95, 115, 125, 128, 129, 133, 135, 137, 153, 160, 163, 183, 189, 191, 193, 211, 256, 260)
|
||||
if seed_bytes[2] % 4 == 0:
|
||||
chosen_ring = ring_candidates[seed_bytes[3] % len(ring_candidates)]
|
||||
bps_v = chosen_ring if wave_b >= 0 else -chosen_ring
|
||||
|
||||
vol_v = round(max(0.32, min(3.10, base_vol + 0.45 * wave_a)), 2)
|
||||
return {
|
||||
"close_usd": close_v,
|
||||
"change_pct": round(bps_v / 100.0, 2),
|
||||
"change_bps": bps_v,
|
||||
"volume_ratio_20d": vol_v,
|
||||
"market_cap_str": mcap_s,
|
||||
}
|
||||
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],
|
||||
daily_points: list[float | None],
|
||||
active_flags: list[bool],
|
||||
wire_shares: list[float],
|
||||
cap_shares: list[float],
|
||||
expected_null_locks: float,
|
||||
observed_locks: int,
|
||||
wire_vel_series: list[float],
|
||||
abs_bps_series: list[float],
|
||||
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`.
|
||||
"""
|
||||
n = max(1, len(daily_points))
|
||||
duty_pct = round(100.0 * sum(1 for f in active_flags if f) / n, 1)
|
||||
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,
|
||||
}
|
||||
|
||||
mean_wire_sh = sum(wire_shares) / n if wire_shares else 0.0
|
||||
mean_cap_sh = sum(cap_shares) / n if cap_shares else 0.0
|
||||
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 - expected_null_locks, 2)
|
||||
tot_pts = sum(daily_points)
|
||||
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(daily_points)
|
||||
p20_idx = min(n - 1, max(0, int(0.20 * n)))
|
||||
p90_idx = min(n - 1, max(0, int(0.90 * n)))
|
||||
mean_pt = tot_pts / n
|
||||
var_pt = sum((x - mean_pt) ** 2 for x in daily_points) / n
|
||||
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 / max(0.25, mean_pt), 2)
|
||||
cv = round(std_pt / mean_pt, 2) if mean_pt > 0 else None
|
||||
|
||||
# Normalize P20 floor and P90 ceiling onto a 0-100 diagnostic scale for cross-lens comparability
|
||||
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 daily_points if x >= 3.5) / n, 1)
|
||||
bust_pct = round(100.0 * sum(1 for x in daily_points if x <= 0.01) / n, 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)
|
||||
|
||||
# Lead-lag cross-correlation profile across tau in [-5 .. +5] days
|
||||
lag_corrs: dict[str, float] = {}
|
||||
best_lag = 0
|
||||
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 - tau]
|
||||
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 - k]
|
||||
ys = abs_bps_series[: n_total - k]
|
||||
r_val = _pearson_corr(xs, ys)
|
||||
lag_corrs[str(tau)] = r_val
|
||||
if abs(r_val) > best_abs_r:
|
||||
if r_val is not None and abs(r_val) > best_abs_r:
|
||||
best_abs_r = abs(r_val)
|
||||
best_lag = tau
|
||||
|
||||
# Conditional regime splits
|
||||
regime_splits: dict[str, float] = {}
|
||||
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 = [daily_points[i] for i in range(n) if r_full in regime_series[i]]
|
||||
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] = 0.0
|
||||
regime_splits[r_key] = None
|
||||
|
||||
return {
|
||||
"ts_duty_cycle_pct": duty_pct,
|
||||
@@ -407,6 +388,7 @@ def derive_pokedex_specimen_profile(
|
||||
) -> 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"]
|
||||
@@ -415,13 +397,19 @@ def derive_pokedex_specimen_profile(
|
||||
)["pokedex_scanner"]
|
||||
|
||||
qual = proj["qualitative_profile"]
|
||||
duty = float(tm["ts_duty_cycle_pct"])
|
||||
level = max(12, min(99, int(round(0.55 * inst_record["composite_score"] + 0.45 * float(tm["ts_weighted_resonance"])))))
|
||||
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)")
|
||||
)
|
||||
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,
|
||||
@@ -458,29 +446,34 @@ def build_quant_timeseries_bundle(
|
||||
|
||||
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
|
||||
raw_bars_by_sym: dict[str, list[dict[str, Any]]] = {}
|
||||
# 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"]
|
||||
phrases_to_translate.add(item["entity_eng"])
|
||||
bars = []
|
||||
for d_idx, dt_s in enumerate(dates_utc):
|
||||
b = _generate_deterministic_bar_for_date(item, dt_s, d_idx, num_days)
|
||||
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)
|
||||
phrases_to_translate.add(int_to_spoken_words(int(round(float(b["close_usd"])))))
|
||||
phrases_to_translate.add(int_to_spoken_words(abs(int(b["change_bps"]))))
|
||||
phrases_to_translate.add(expand_quant_spoken(str(b["market_cap_str"])))
|
||||
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] = []
|
||||
wire_vel_global: list[float | None] = []
|
||||
for dt_s in dates_utc:
|
||||
dos = dated_dossiers.get(dt_s)
|
||||
if dos:
|
||||
@@ -492,12 +485,12 @@ def build_quant_timeseries_bundle(
|
||||
"dossier_number": None,
|
||||
"dossier_file": None,
|
||||
"archive_route": None,
|
||||
"equation_counts": {"eq_333": 0, "eq_666": 0, "eq_777": 0, "total": 0},
|
||||
"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(0.0)
|
||||
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)]
|
||||
@@ -514,24 +507,71 @@ def build_quant_timeseries_bundle(
|
||||
|
||||
for d_idx, dt_s in enumerate(dates_utc):
|
||||
b = raw_bars_by_sym[sym][d_idx]
|
||||
close_int = int(round(float(b["close_usd"])))
|
||||
bps_abs = abs(int(b["change_bps"]))
|
||||
mcap_s = str(b["market_cap_str"])
|
||||
vol_r = float(b["volume_ratio_20d"])
|
||||
chg_pct = float(b["change_pct"])
|
||||
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_ing": NO_DATA_AVAILABLE,
|
||||
"close_spoken_ing_aq": None,
|
||||
"scaled_cap_spoken_ing": NO_DATA_AVAILABLE,
|
||||
"scaled_cap_spoken_ing_aq": None,
|
||||
"bps_digit_aq": None,
|
||||
"bps_spoken_ing": NO_DATA_AVAILABLE,
|
||||
"bps_spoken_ing_aq": None,
|
||||
"scope1_locks": [],
|
||||
"scope2_ring_coordinates": [],
|
||||
"co_present_in_news_wire": co_present,
|
||||
"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_ing = ing_map.get(close_sp_eng, close_sp_eng)
|
||||
bps_sp_eng = int_to_spoken_words(bps_abs)
|
||||
bps_sp_ing = ing_map.get(bps_sp_eng, bps_sp_eng)
|
||||
mcap_sp_eng = expand_quant_spoken(mcap_s)
|
||||
mcap_sp_ing = ing_map.get(mcap_sp_eng, mcap_sp_eng)
|
||||
|
||||
close_dig_aq = compute_aq(str(close_int))
|
||||
close_sp_aq = compute_aq(close_sp_ing)
|
||||
bps_dig_aq = compute_aq(str(bps_abs))
|
||||
bps_sp_aq = compute_aq(bps_sp_ing)
|
||||
mcap_sp_aq = compute_aq(mcap_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_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_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_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_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] = []
|
||||
@@ -540,19 +580,19 @@ def build_quant_timeseries_bundle(
|
||||
scope1_locks.append(f"CLOSE_SELF_LOCK ({close_int}=={ent_ing})")
|
||||
if is_repdigit_37(close_sp_aq) or is_repdigit_37(close_int):
|
||||
scope1_locks.append(f"REPDIGIT_ATTRACTOR ({close_int if is_repdigit_37(close_int) else close_sp_aq})")
|
||||
if bps_abs == ent_ing_aq or bps_abs == ent_eng_aq:
|
||||
if bps_abs is not None and (bps_abs == ent_ing_aq or bps_abs == ent_eng_aq):
|
||||
scope1_locks.append(f"BPS_SELF_LOCK ({bps_abs}=={ent_ing})")
|
||||
|
||||
for c_val in (close_int, close_sp_aq, bps_abs):
|
||||
cand_coords = [close_int, close_sp_aq]
|
||||
if bps_abs is not None:
|
||||
cand_coords.append(bps_abs)
|
||||
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 = dated_dossiers.get(dt_s)
|
||||
co_present = bool(dos and sym in dos["co_present_symbols"])
|
||||
|
||||
if vol_r < 0.45 and abs(chg_pct) < 0.15:
|
||||
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 <= -5.0 or vol_r >= 2.5 or (sym == "^VIX" and close_int >= 25):
|
||||
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")
|
||||
@@ -562,14 +602,17 @@ def build_quant_timeseries_bundle(
|
||||
+ 1.5 * len(scope2_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 * vol_r) if (scope1_locks or scope2_coords) 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,
|
||||
"close_usd": b["close_usd"],
|
||||
"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": b["change_bps"],
|
||||
"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,
|
||||
@@ -597,26 +640,30 @@ def build_quant_timeseries_bundle(
|
||||
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 = [float(r["contingent_points"]) 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]
|
||||
abs_bps = [float(abs(int(r["change_bps"]))) for r in s_rows]
|
||||
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] = []
|
||||
cap_shares: list[float] = []
|
||||
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.15
|
||||
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(0.0)
|
||||
denom = max(1.0, daily_total_locked_displacement[d_idx])
|
||||
cap_shares.append(float(r.pop("_locked_disp", 0.0)) / denom)
|
||||
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)
|
||||
|
||||
# Structural 6-vector for the instrument
|
||||
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
|
||||
@@ -643,12 +690,17 @@ def build_quant_timeseries_bundle(
|
||||
active_flags=active_flags,
|
||||
wire_shares=wire_shares,
|
||||
cap_shares=cap_shares,
|
||||
expected_null_locks=round(num_days * 0.32, 2),
|
||||
observed_locks=tot_locks,
|
||||
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] = {
|
||||
@@ -659,6 +711,9 @@ def build_quant_timeseries_bundle(
|
||||
"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,
|
||||
@@ -693,17 +748,16 @@ def build_quant_timeseries_bundle(
|
||||
if not matching_insts:
|
||||
matching_insts = instruments_out[:3]
|
||||
|
||||
b_daily_pts = [
|
||||
round(sum(inst["bars"][d_i]["contingent_points"] for inst in matching_insts) / len(matching_insts), 2)
|
||||
for d_i in range(num_days)
|
||||
]
|
||||
b_active = [any(inst["bars"][d_i]["contingent_points"] > 0 for inst in matching_insts) for d_i in range(num_days)]
|
||||
b_abs_bps = [
|
||||
round(sum(abs(int(inst["bars"][d_i]["change_bps"])) for inst in matching_insts) / len(matching_insts), 1)
|
||||
for d_i in range(num_days)
|
||||
]
|
||||
b_wire_sh = [0.18 if b_active[d_i] else 0.02 for d_i in range(num_days)]
|
||||
b_cap_sh = [0.16 if b_daily_pts[d_i] >= 2.0 else 0.04 for d_i in range(num_days)]
|
||||
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
|
||||
@@ -722,12 +776,11 @@ def build_quant_timeseries_bundle(
|
||||
regime_series=daily_regimes,
|
||||
)
|
||||
base_eti = float(row.get("curve_score", 75))
|
||||
live_eti = max(
|
||||
40.0,
|
||||
min(
|
||||
99.0,
|
||||
round(base_eti + 0.35 * b_ts["ts_excess_over_replacement"], 1),
|
||||
),
|
||||
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"),
|
||||
@@ -756,34 +809,28 @@ def build_quant_timeseries_bundle(
|
||||
"q_old_digit": "$6B",
|
||||
"q_new_digit": "$6B",
|
||||
"coordinate": 211,
|
||||
"description": "Lazarus $6B heist ('siks bilyan' = 211 [47th PRIME] == wor masheen == koper waier).",
|
||||
"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_baseline",
|
||||
"anchor_id": "anthropic_ipo_price_83",
|
||||
"date_utc": "2026-11-18",
|
||||
"symbol": "ANTHR-PVT",
|
||||
"q_old_digit": "$83",
|
||||
"q_new_digit": "$83",
|
||||
"coordinate": 202,
|
||||
"description": "Anthropic initial valuation share anchor $83 ('aytee three' = 202) in Dossier 55.",
|
||||
"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": "841",
|
||||
"q_new_digit": "481",
|
||||
"coordinate": 13,
|
||||
"description": "481 halted factories ('4+8+1 = 13' Iso-Digital conservation with 841 = 29^2) in Dossier 62.",
|
||||
},
|
||||
{
|
||||
"anchor_id": "anthropic_ipo_price_83_repricing",
|
||||
"date_utc": "2026-11-26",
|
||||
"symbol": "ANTHR-PVT",
|
||||
"q_old_digit": "$83",
|
||||
"q_new_digit": "$89",
|
||||
"coordinate": 193,
|
||||
"description": "Repriced $83 -> $89 ('aytee nain' = 193 [44th PRIME] == anthropik == flash krash == Dario Amodei [Gen 0]).",
|
||||
"source_dossier": "62-dossier-news-2026-11-24.md",
|
||||
"description": "481 halted garment factories ('4+8+1 = 13') in Dossier 62.",
|
||||
},
|
||||
]
|
||||
|
||||
@@ -794,12 +841,14 @@ def build_quant_timeseries_bundle(
|
||||
"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],
|
||||
|
||||
Reference in new issue
Block a user