How ak495867/kraken works
Purpose and Entry Points
Kraken is a local-first, deterministic market-research engine for point-in-time analysis, empirical forecast calibration, regime/dynamics diagnostics, and governed vendor-data workflows. Its user-facing entry point is the Python CLI/package at src/kraken/__main__.py and src/kraken/cli.py. Native computations are exposed to Python through cpp/bindings.cpp.
Native Deterministic Analytics Core
The C++17 core owns numerical consistency and market-time validity gates before analytics execute. It computes stable statistics, features, empirical forecast bands, calibration distances, regime labels, and dynamics diagnostics.
• Core contracts and value types: cpp/include/kraken_core/core.hpp, cpp/include/kraken_core/types.hpp
• Input/cutoff/availability validation: cpp/validation.cpp, cpp/include/kraken_core/validation.hpp
• Analytics stages: cpp/features.cpp, cpp/sonar.cpp, cpp/calibration.cpp
• Regime and liquidity/volatility structure: cpp/regime.cpp, cpp/dynamics.cpp
Primary boundary: Python supplies typed, validated workflow inputs; pybind11 calls deterministic native routines; native results return to Python for reports, audit artifacts, and orchestration.
Point-in-Time Research and Walk-Forward Workflows
Python composes local CSV/JSON data into chronological research runs. It enforces availability timestamps, partitions history into train/embargo/validation/evaluation segments, and keeps post-cutoff outcomes separate from fit history.
• Research orchestration: src/kraken/research.py, src/kraken/analysis.py
• Forecast calibration workflow: src/kraken/calibration.py
• Historical equity/options workflow: src/kraken/backtest.py
• Domain inputs and event handling: src/kraken/corporate_actions.py, src/kraken/distributions.py, src/kraken/earnings.py
The flow is local input → parsing/normalization → point-in-time validation → native features/analytics → chronological calibration or backtest report.
Data, Vendor Governance, and Provenance
Kraken deliberately has no remote market-data connector or bundled licensed dataset. Vendor exports are accepted through versioned local mapping contracts, then fingerprinted and governed by manifest/attestation checks.
• File and schema handling: src/kraken/io.py, src/kraken/normalizers.py
• Vendor plugin discovery and acceptance: src/kraken/vendor.py, src/kraken/acceptance.py
• Hashes, run lineage, and report artifacts: src/kraken/provenance.py, src/kraken/audit.py
• Plugin assets/contracts: vendor_plugins/canonical/1.0.0/plugin.json, vendor_plugins/snapshot_v1/1.0.0/plugin.json
Important trust boundary: manifests, calendars, authorization attestations, and every referenced local file must agree by SHA-256; invalid or incomplete contracts fail closed.
Configuration and Result Packaging
Strict versioned research configuration is parsed at both Python/runtime and native layers, supporting reproducible output for identical inputs and compiler policy.
• Python runtime configuration: src/kraken/config_runtime.py
• Native configuration API/parser: cpp/config.cpp, cpp/include/kraken_core/config.hpp
• Versioned configurations: configs/research_config.v1.kcfg, configs/production_risk_limits.json
• Bundle/report assembly: src/kraken/bundles.py, src/kraken/diagnostics.py
Operational Runtime Boundary
A separate container-oriented runtime can ingest HTTPS JSON observations, persist immutable records in SQLite WAL, emit JSONL alerts and Prometheus-compatible metrics, and run paper-first execution controls. It is operationally distinct from the research pipelines and refuses live brokerage without a provider-specific implementation and approvals.
• Runtime orchestration: src/kraken/production.py, tools/run_production.py
• Risk, execution, and operations endpoints: src/kraken/risk.py, src/kraken/execution.py, src/kraken/operations.py
• Deployment container/runbook: deploy/Dockerfile, deploy/README.md
External/runtime dependencies materially include CPython 3.10–3.12, CMake/C++17, pybind11/scikit-build-core packaging, local SQLite, HTTPS ingestion clients, and Prometheus scrape consumers.
Build and Release Integrity
CMake builds the native extension; Python packaging produces source distributions and platform wheels. Release verification checks versioning, archive contents, native/plugin inclusion, generated-artifact exclusion, and checksums.
• Build definitions: CMakeLists.txt, pyproject.toml
• Release verification: tools/check_release.py, tools/wheel_smoke.py
• CI/release matrix: .github/workflows/native-quality.yml
Main entry points: research.py Research orchestration · calibration.py Calibration and backtest · bindings.cpp pybind11 bindings · acceptance.py Acceptance and attestation
Components 22
Research workflows
Local point-in-time analysis and reporting.
- Python CLI/package
src/kraken/__main__.py - Research orchestration
src/kraken/research.py - Calibration and backtest · Chronological train, embargo, validation, and evaluation workflows.
src/kraken/calibration.py - Corporate and event inputs
src/kraken/corporate_actions.py - Bundles and diagnostics
src/kraken/bundles.py - Runtime configuration · Strict versioned research configuration.
src/kraken/config_runtime.py
Native analytics
Deterministic C++17 computation boundary.
- pybind11 bindings
cpp/bindings.cpp - Market-time validation · Rejects invalid inputs, cutoffs, and availability states before analytics.
cpp/validation.cpp - Features and calibration · Stable statistics, forecast bands, and calibration distances.
cpp/features.cpp - Regime and dynamics · Liquidity/volatility structure and dynamics diagnostics.
cpp/regime.cpp
Data governance
Versioned local vendor inputs and provenance.
- Local CSV/JSON exports · No bundled licensed dataset or remote market-data connector.
- Parsing and normalization
src/kraken/io.py - Vendor plugin contracts · Local mappings define accepted vendor exports.
vendor_plugins/canonical/1.0.0/plugin.json - Acceptance and attestation · Manifest, calendar, authorization, and file hashes fail closed.
src/kraken/acceptance.py - Lineage and audit artifacts
src/kraken/provenance.py
Operational runtime
Separate container-oriented paper-first runtime.
- Production orchestrator
src/kraken/production.py - HTTPS observations
- SQLite WAL records
- Risk and paper execution · Refuses live brokerage without provider implementation and approvals.
src/kraken/execution.py - Alerts and metrics · JSONL alerts and Prometheus-compatible metrics.
src/kraken/operations.py
Build and release
Native extension packaging and release verification.
- CMake and Python packaging · Builds the C++ extension and source/platform distributions.
CMakeLists.txt - Release verification · Checks archives, inclusion, exclusions, and checksums.
tools/check_release.py
Connections 21
- Python CLI/package → Research orchestration: starts
- Research orchestration → Calibration and backtest: composes
- Local CSV/JSON exports → Parsing and normalization: read locally
- Vendor plugin contracts → Acceptance and attestation: defines mapping
- Parsing and normalization → Acceptance and attestation: normalized exports
- Acceptance and attestation → Research orchestration: accepted inputs
- Corporate and event inputs → Research orchestration: event context
- Runtime configuration → Research orchestration: governs run
- Research orchestration → pybind11 bindings: typed workflow inputs
- pybind11 bindings → Market-time validation: calls
- Market-time validation → Features and calibration: valid inputs
- Features and calibration → Regime and dynamics: diagnostic features
- Regime and dynamics → Calibration and backtest: deterministic results
- Calibration and backtest → Bundles and diagnostics: reports
- Bundles and diagnostics → Lineage and audit artifacts: audit artifacts
- HTTPS observations → Production orchestrator: JSON observations
- Production orchestrator → SQLite WAL records: immutable records
- SQLite WAL records → Risk and paper execution: observations
- Risk and paper execution → Alerts and metrics: alerts and metrics
- CMake and Python packaging → pybind11 bindings: compiles extension
- CMake and Python packaging → Release verification: packages