feat(v2.0.8): implement ipld dag-json/CIDv1, quant financial collector, MCP server (hs-mcp), /learn/ sub-page, /gallery/ sub-page, and global Lemurs footer
This commit is contained in:
1 parent
b767f8a4e9
commit
c17f74097b
55 files changed
+3974
-10
No files matched your search
Executable
+296
@@ -0,0 +1,296 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
_SRC_DIR = Path(__file__).resolve().parents[2]
|
||||
if _SRC_DIR.is_dir() and str(_SRC_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(_SRC_DIR))
|
||||
|
||||
from hyperstitionstud_io.ciphers import ( # noqa: E402
|
||||
compute_aq,
|
||||
int_to_spoken_words,
|
||||
is_repdigit_37,
|
||||
prime_rank,
|
||||
)
|
||||
from hyperstitionstud_io.config import load_workspace_config # noqa: E402
|
||||
from hyperstitionstud_io.glossary import ReadOnlyIsolationGuard # noqa: E402
|
||||
from hyperstitionstud_io.ipld import ( # noqa: E402
|
||||
compute_dag_json_cidv1,
|
||||
write_pretty_and_dag_json,
|
||||
)
|
||||
from hyperstitionstud_io.phonetics import translate_batch # noqa: E402
|
||||
|
||||
os.environ["TZ"] = "UTC"
|
||||
if hasattr(time, "tzset"):
|
||||
time.tzset()
|
||||
|
||||
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"],
|
||||
256: ["S2: akselerayshan / hai-freekwansee", "S6: sovran welth"],
|
||||
246: ["S1: transformer [Iso]"],
|
||||
237: ["S6: kansorsheeam [Iso]"],
|
||||
222: ["S1: danyela amodai", "S6: enterpraiz"],
|
||||
215: ["S3: jensan hwang / hohlee grayl"],
|
||||
211: ["S3: wor masheen / koper waier", "S2/Q0: siks bilyan"],
|
||||
197: ["S3: lathografee", "S6: monopoly [Gen 0]"],
|
||||
193: ["S1: anthropik / Dario Amodei [Gen 0]", "S2: flash krash"],
|
||||
191: ["S2: derivativ", "S6: lajistiks"],
|
||||
189: ["S2: likwidatee / hangkerchif / imerjansee"],
|
||||
183: ["S2: ruhnaway / tempaleks / laytansee", "S6: alakayshan"],
|
||||
166: ["S2: order buk / noo flesh"],
|
||||
163: ["S6: manopalee / masheenz"],
|
||||
160: ["S6: kapasatee / truhst / rohbots / kriptoh / straiks"],
|
||||
153: ["S6: aperatas / serplas", "S2: raizohm / reealatee [Iso]"],
|
||||
137: ["S1: daireeoh", "S3: envideea", "M1: hawlts / inersha"],
|
||||
136: ["S6: charter [Iso] / portal [Iso]", "M1: slohth"],
|
||||
135: ["S1: dilooz / asemblaj / tenser"],
|
||||
133: ["S1: wayts / sworm", "S6: ekwatee"],
|
||||
129: ["S3: blakwel / ruhsha", "M7+: awflain"],
|
||||
128: ["S3: nik land / masheen / serkat"],
|
||||
125: ["S6: kapatal [Iso] / kapcher", "S2: fohldz / saires"],
|
||||
115: ["S1: proof [Iso]"],
|
||||
96: ["S1: klawd / failam / dayta"],
|
||||
95: ["S2: lejer / faiber", "S5: flesh / huks"],
|
||||
91: ["S3: tsmc [Iso] / laws"],
|
||||
81: ["S3: asml [Iso]", "S6: aset"],
|
||||
71: ["S3: gpu [Iso]"],
|
||||
}
|
||||
|
||||
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"},
|
||||
]
|
||||
|
||||
|
||||
def build_financial_quant_harvest(
|
||||
harvest_mode: str = "us-closing-bell",
|
||||
snapshot_path: str | Path | None = None,
|
||||
join_news_path: str | Path | None = None,
|
||||
) -> dict[str, Any]:
|
||||
cfg = load_workspace_config()
|
||||
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"))
|
||||
else:
|
||||
raw_watchlist = CANONICAL_WATCHLIST_24
|
||||
|
||||
# Batch translate entity names and spoken integer/bps strings
|
||||
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"]))
|
||||
phrases_to_translate.append(int_to_spoken_words(close_int))
|
||||
phrases_to_translate.append(int_to_spoken_words(bps_abs))
|
||||
|
||||
ing_map = translate_batch(phrases_to_translate)
|
||||
|
||||
news_entities: set[str] = set()
|
||||
if join_news_path and Path(join_news_path).is_file():
|
||||
news_obj = json.loads(Path(join_news_path).read_text(encoding="utf-8"))
|
||||
for st in news_obj.get("stories", news_obj.get("headlines", [])):
|
||||
txt_hl = (st.get("headline_eng") or st.get("title") or "").lower()
|
||||
for item in raw_watchlist:
|
||||
if item["entity_eng"].lower() in txt_hl or item["symbol"].lower() in txt_hl:
|
||||
news_entities.add(item["symbol"])
|
||||
|
||||
instruments_out: list[dict[str, Any]] = []
|
||||
active_memetic_states: set[str] = set()
|
||||
|
||||
for item in raw_watchlist:
|
||||
sym = item["symbol"]
|
||||
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"]))
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
locks: list[dict[str, Any]] = []
|
||||
|
||||
# Scope 1: Intra-Instrument Self-Locks & Repdigit Attractors
|
||||
if close_int == ent_ing_aq or close_int == ent_eng_aq:
|
||||
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}).",
|
||||
})
|
||||
if is_repdigit_37(close_sp_aq) or is_repdigit_37(close_int):
|
||||
locks.append({
|
||||
"scope": "SCOPE1_SPOKEN_REPDIGIT_ATTRACTOR",
|
||||
"description": f"{sym} close ${close_int} ('{close_sp_ing}') locks onto repdigit attractor {close_sp_aq if is_repdigit_37(close_sp_aq) else close_int}.",
|
||||
})
|
||||
if 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}).",
|
||||
})
|
||||
|
||||
# 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")):
|
||||
if coord_val in S1_S6_SIGNATURE_RINGS:
|
||||
locks.append({
|
||||
"scope": "SCOPE2_S1_S6_RING_MIGRATION",
|
||||
"metric_mode": label_mode,
|
||||
"coordinate": coord_val,
|
||||
"ring_partners": S1_S6_SIGNATURE_RINGS[coord_val],
|
||||
})
|
||||
|
||||
# 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))
|
||||
mcap_s = str(item.get("market_cap_str", ""))
|
||||
if 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:
|
||||
active_memetic_states.add("M2_FLASH_CRASH_TEMPLEX_SURGE")
|
||||
if mcap_s.endswith("T"):
|
||||
active_memetic_states.add("M3_LEVIATHAN_TRILLION_CAP_CONCENTRATION")
|
||||
|
||||
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"],
|
||||
"co_present_in_news_wire": sym in news_entities,
|
||||
"metrics": {
|
||||
"close_usd": item["close_usd"],
|
||||
"change_pct": chg_pct,
|
||||
"change_bps": item["change_bps"],
|
||||
"volume_ratio_20d": vol_ratio,
|
||||
"market_cap_str": mcap_s,
|
||||
},
|
||||
"quant_encodings": {
|
||||
"close_digit_aq": close_dig_aq,
|
||||
"close_spoken_eng": close_sp_eng,
|
||||
"close_spoken_ing": close_sp_ing,
|
||||
"close_spoken_ing_aq": close_sp_aq,
|
||||
"close_spoken_prime_rank": prime_rank(close_sp_aq),
|
||||
"bps_digit_aq": bps_dig_aq,
|
||||
"bps_spoken_eng": bps_sp_eng,
|
||||
"bps_spoken_ing": bps_sp_ing,
|
||||
"bps_spoken_ing_aq": bps_sp_aq,
|
||||
},
|
||||
"contingent_locks": locks,
|
||||
})
|
||||
|
||||
# Evaluate registered anchor revisions
|
||||
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).",
|
||||
}
|
||||
]
|
||||
|
||||
receipt = guard.audit_receipt()
|
||||
payload: dict[str, Any] = {
|
||||
"$schema": "./schemas/v1/financial-aq-harvest.schema.json",
|
||||
"$id": "urn:io:hyperstitionstud:schema:v1:financial-aq-harvest",
|
||||
"version": "2.0.0",
|
||||
"target_date_utc": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
|
||||
"harvest_mode": harvest_mode,
|
||||
"regime_summary": {
|
||||
"instrument_count": len(instruments_out),
|
||||
"total_contingent_locks": sum(len(x["contingent_locks"]) for x in instruments_out),
|
||||
"active_memetic_states": sorted(active_memetic_states),
|
||||
},
|
||||
"instruments": instruments_out,
|
||||
"anchor_revisions_detected": anc_revs,
|
||||
"isolation_receipt": receipt,
|
||||
}
|
||||
payload["ipld_dag_json_cidv1"] = {"/": compute_dag_json_cidv1(payload)}
|
||||
return payload
|
||||
|
||||
|
||||
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("--join-news", default=None, help="Optional path to news-aq-harvest-latest.json.")
|
||||
ap.add_argument("--out", default=None, help="Output JSON path (default: <archive_dir>/financial-aq-harvest-latest.json).")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
cfg = load_workspace_config()
|
||||
out_path = Path(args.out) if args.out else (cfg.archive_dir / "financial-aq-harvest-latest.json")
|
||||
join_news = args.join_news or str(cfg.archive_dir / "news-aq-harvest-latest.json")
|
||||
|
||||
payload = build_financial_quant_harvest(
|
||||
harvest_mode=args.mode,
|
||||
snapshot_path=args.from_snapshot,
|
||||
join_news_path=join_news,
|
||||
)
|
||||
info = write_pretty_and_dag_json(out_path, payload)
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"output_path": str(out_path),
|
||||
"harvest_mode": payload["harvest_mode"],
|
||||
"instrument_count": payload["regime_summary"]["instrument_count"],
|
||||
"total_contingent_locks": payload["regime_summary"]["total_contingent_locks"],
|
||||
"active_memetic_states": payload["regime_summary"]["active_memetic_states"],
|
||||
"dag_json_cidv1": info["cidv1"],
|
||||
"isolation_all_unchanged": payload["isolation_receipt"]["all_unchanged"],
|
||||
},
|
||||
indent=2,
|
||||
)
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user