SPB Git

spb/wp39_uqo

Public
1.9 KB · 43 lines python
1#!/usr/bin/env python2"""Phase 0: authenticated probe of FinData OS — contract reconciliation, no raw data, no credentials printed."""3from __future__ import annotations45import json6import sys7from pathlib import Path89sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))10from wp39.api_client import FinDataClient  # noqa: E40211from wp39.catalog import probe  # noqa: E40212from wp39.pipeline import Paths, get_logger, load_config  # noqa: E40213from wp39.provenance import git_sha, now_iso, write_json  # noqa: E402141516def main() -> int:17    P = Paths.default()18    log = get_logger("00_probe", P.logs / "00_probe.log")19    contract = load_config("data_contract")20    client = FinDataClient(log_path=P.logs / "api_calls.jsonl")21    rep = probe(client, contract)22    rep["probed_at"], rep["code_sha"] = now_iso(), git_sha(P.root)23    # spot-check fundamentals + export schema on one well-known entity, counts only24    f = client.fundamentals("frd:AAPL", period_type="q", limit=20000)25    rep["aapl_quarterly_facts"] = len(f.get("data", []))26    rep["aapl_metrics"] = sorted({r["metric"] for r in f.get("data", [])})27    rep["pit_policy"] = f.get("meta", {}).get("pit_policy")28    periods = client.fundamentals_periods("frd:AAPL")29    rep["aapl_periods"] = len(periods)30    rep["aapl_first_filing"] = min(p["filing_date"] for p in periods if p.get("filing_date"))31    write_json(P.logs / "phase0_probe.json", rep)32    log.info("health=%s datasets=%d schema_ok=%s earnings_route=%s", rep["health_status"], rep["n_datasets"],33             rep["bars_fields_ok"], rep["has_earnings_route"])34    for k, v in rep["required_datasets"].items():35        log.info("dataset %s: %s", k, v)36    print(json.dumps({k: rep[k] for k in ("health_status", "n_datasets", "bars_fields_ok", "has_earnings_route",37                                            "aapl_quarterly_facts", "aapl_periods", "lake_free_gb")}, indent=1))38    return 0394041if __name__ == "__main__":42    raise SystemExit(main())43
Files · 42edd965d464895e91a65b5b6e7ea7e9f619e658
Menu

Theme