Metadata-Version: 2.4
Name: alphakiln
Version: 0.3.1
Summary: Agent-ready quantitative factor research harness
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/GSX-Eis/alphakiln
Project-URL: Repository, https://github.com/GSX-Eis/alphakiln
Project-URL: Issues, https://github.com/GSX-Eis/alphakiln/issues
Project-URL: Changelog, https://github.com/GSX-Eis/alphakiln/blob/main/CHANGELOG.md
Keywords: quantitative-finance,factor-research,ai-agent,time-series,duckdb
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: <3.13,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy<2,>=1.26.4
Requires-Dist: pandas<3,>=2.3.3
Requires-Dist: pandas_market_calendars==5.6.0
Requires-Dist: scipy<2,>=1.10
Requires-Dist: duckdb==1.5.3
Requires-Dist: pyarrow<20,>=19.0.1
Requires-Dist: python-dateutil>=2.8
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-xdist>=3.5; extra == "dev"
Requires-Dist: alphalens-reloaded<0.5,>=0.4; extra == "dev"
Requires-Dist: httpx>=0.27; extra == "dev"
Provides-Extra: synthesis
Requires-Dist: scikit-learn<1.8,>=1.3; extra == "synthesis"
Requires-Dist: dcor<0.7,>=0.6; extra == "synthesis"
Requires-Dist: threadpoolctl>=3; extra == "synthesis"
Requires-Dist: joblib>=1.3; extra == "synthesis"
Requires-Dist: lightgbm<5,>=4; extra == "synthesis"
Requires-Dist: matplotlib; extra == "synthesis"
Requires-Dist: seaborn; extra == "synthesis"
Provides-Extra: qlib
Requires-Dist: pyqlib<0.10,>=0.9.7; extra == "qlib"
Requires-Dist: filelock>=3; extra == "qlib"
Provides-Extra: acceleration
Requires-Dist: numba>=0.59; extra == "acceleration"
Provides-Extra: backtest
Requires-Dist: vectorbt<1.1,>=0.26; extra == "backtest"
Requires-Dist: plotly<6,>=5; extra == "backtest"
Provides-Extra: mining
Requires-Dist: torch>=2.0; extra == "mining"
Requires-Dist: deap<2,>=1.4; extra == "mining"
Provides-Extra: viz
Requires-Dist: fastapi>=0.115.0; extra == "viz"
Requires-Dist: uvicorn>=0.30.0; extra == "viz"
Requires-Dist: streamlit<2,>=1.40; extra == "viz"
Requires-Dist: plotly<7,>=5; extra == "viz"
Provides-Extra: mcp
Requires-Dist: mcp<2,>=1.13; extra == "mcp"
Provides-Extra: markets
Requires-Dist: requests>=2.31; extra == "markets"
Requires-Dist: akshare<2,>=1.14; extra == "markets"
Provides-Extra: all
Requires-Dist: alphakiln[acceleration,backtest,markets,mcp,mining,qlib,synthesis,viz]; extra == "all"
Dynamic: license-file

<div align="center">

# AlphaKiln

**An AI-native, end-to-end quantitative research harness — one closed loop from Factor Mining → Factor Evaluation → Factor Synthesis → Local Backtest via CLI and MCP.**

**100% Local & Offline · Zero Telemetry / Zero Data Upload · Once dependencies are installed, the full workflow runs air-gapped** *(network access occurs only when you opt in to fetch optional public market benchmarks)*

English · [简体中文](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/README.zh-CN.md)

[![CI](https://img.shields.io/github/actions/workflow/status/GSX-Eis/alphakiln/ci.yml?branch=main&label=CI)](https://github.com/GSX-Eis/alphakiln/actions/workflows/ci.yml?query=branch%3Amain)
[![PyPI](https://img.shields.io/pypi/v/alphakiln?color=blue)](https://pypi.org/project/alphakiln/)
![Python 3.11–3.12](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)
[![Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/LICENSE)

</div>

<div align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://github.com/GSX-Eis/alphakiln/raw/v0.3.1/docs/assets/architecture-dark.svg">
    <img src="https://github.com/GSX-Eis/alphakiln/raw/v0.3.1/docs/assets/architecture-light.svg" width="100%" alt="AlphaKiln architecture from AI agents through the CLI and quantitative core to local evidence and a read-only dashboard">
  </picture>
</div>

## End-to-End Quantitative Workflow

### 1. Factor Mining

*Automated search without brittle manual formulas.*

- **PyTorch DSO** (policy search with structural priors) + **DEAP GP** (genetic programming meld) + **QuantaAlpha** proposal gate
- Compiles passing candidates into standalone, auditable `FactorBase` modules
- Extra: `[mining]` (`torch`, `deap`) · Entry: `symbolic-factor-mining` · [run_symbolic_factor_mining.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/run_symbolic_factor_mining.py)

### 2. Factor Evaluation & Anti-Overfitting

*Blocks lookahead bias and lucky-trial inflation.*

- Unified daily cross-section & minute-Bar evaluation: **Rank IC / ICIR**, quantile long-short, directional hit rate
- **Causal Gate** (lookahead rejection) + **Purged OOS** + **Rank IC / ICIR** + **Adaptive HAC** + **Moving-Block Bootstrap v2** + **TrialLedger (Holm / BH)** + `calibration_status`
- Extra: `Core` · Entry: `single-factor-analysis` / `time-series-analysis` · [Evaluation policy](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/EVAL_POLICY.md) · [Evaluation engine](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/EVALUATION_ENGINE.en.md)

### 3. Factor Synthesis

*Controls collinearity and signal-to-execution drift.*

- **Weighted Sum · LASSO · ElasticNet · LightGBM** (plus Ridge / PCA / Dynamic Blend / Size-Conditional)
- Purged rolling splits + approximate DSR / correlation pre-screening → immutable SHA-256 `StrategyBundle`
- Extra: `[synthesis]` · Entry: `factor-synthesis` · [Synthesis guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/SYNTHESIS.md)

### 4. Local Backtest

*Bridges factor metrics to local portfolio execution.*

- **VectorBT + DuckDB** local backtest engine sharing the unified `ExecutionScheduler` clock
- Supports equity cross-sections and single-account futures (session rolls, margin caps, lot rounding), with cross-market `signal_export` / `jq_cloud` export & offline alignment verification
- Extra: `[backtest]` · Entry: `export-strategy` / `verify-target-alignment` · [Custom market & deploy guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CUSTOM_MARKET_AND_DEPLOY_GUIDE.en.md) · [JoinQuant adapter](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/JOINQUANT.md)

## Why AlphaKiln?

Most open-source quant projects excel at one isolated layer while leaving three recurring gaps in day-to-day factor research:

1. **Fragmented toolchains & signal-to-execution clock drift**: Mining scripts, research notebooks, and backtesters often assume different timestamps or return conventions. AlphaKiln aligns them through one `ExecutionScheduler` clock and local DuckDB contracts across daily cross-sections and intraday Bars.
2. **Hidden lookahead & multiple-testing significance inflation**: Unverified feature engineering leaks future prices, while repeated screening inflates naive p-values. Built-in **Causal Gate**, **Purged OOS**, **Adaptive HAC**, **Moving-Block Bootstrap v2**, **TrialLedger (Holm / BH)**, and explicit `calibration_status` gates filter fragile candidates before synthesis.
3. **No auditable, deterministic execution surface for AI agents**: Interactive notebooks are hard for autonomous agents to verify reliably. Every command exposes strict JSON output, `--dry-run` preflight plans, deterministic exit codes, and a local stdio MCP server.

### How AlphaKiln Fits the Ecosystem

AlphaKiln is built to **complement** existing open-source quant tools rather than replace them—supplying the shared execution clock, causal and calibration-aware evaluation engine, and deterministic CLI/MCP layer around them.

| Ecosystem Tool | Integration | How They Work Together |
| --- | --- | --- |
| [VectorBT](https://github.com/polakowo/vectorbt) | **Built-in (`[backtest]`)** | Runs underneath our local backtester on one `ExecutionScheduler` clock and DuckDB contract |
| [Alphalens](https://github.com/quantopian/alphalens) | **Aligned & extended** | Keeps daily tear-sheet semantics while adding lookahead, bootstrap, and multiple-testing gates |
| [Qlib](https://github.com/microsoft/qlib) | **Adapter (`[qlib]`)** | Connects Qlib models and datasets to our causal and calibration-aware evaluation gates |
| [RD-Agent](https://github.com/microsoft/RD-Agent) | **Paired harness** | RD-Agent drives hypothesis evolution; AlphaKiln executes deterministic JSON CLI & MCP checks |
| [TradingAgents](https://github.com/TauricResearch/TradingAgents) | **Orthogonal signals** | Pairs LLM textual/fundamental signals with local PIT numerical factor pipelines |

## 60-Second Quickstart

> **100% local & offline (zero telemetry):** All core workflows — synthetic demos, DuckDB storage, Causal Gate, evaluation, synthesis, local backtesting, CLI, and the stdio MCP server — run completely offline on your machine with zero telemetry and zero data upload (network access is used only if you explicitly download optional `[markets]` datasets).
>
> **Environment:** **Python 3.11–3.12** (Python 3.13 is not yet supported). Install inside an isolated virtual environment — **`uv venv --python 3.12 --seed` is recommended (~4s install)**. See the [English Getting Started guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/GETTING_STARTED_EN.md) for connecting your own CSV/DuckDB data and custom factors.
>
> **Platform support:** macOS and Linux (Python 3.11–3.12) pass CI; on Windows, the core CLI and cross-platform file locking (`utils/file_lock.py` via `msvcrt.locking`) are implemented and verified under `fcntl`-disabled simulation tests, while native Windows end-to-end CI validation is still in progress. For the full CI-verified experience on Windows, we recommend running under **WSL2** with Python 3.11–3.12.

Install from PyPI on macOS or Linux with `uv` (recommended) or `pip`.

**uv (recommended, ~4s install)**

```bash
uv venv --python 3.12 --seed
source .venv/bin/activate
uv pip install 'alphakiln[synthesis,backtest,viz]'
```

**pip**

```bash
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install 'alphakiln[synthesis,backtest,viz]'
```

To install from a source checkout instead, run `git clone https://github.com/GSX-Eis/alphakiln.git && cd alphakiln` and install `'.[synthesis,backtest,viz]'`.

<details>
<summary>Optional extras reference</summary>

Install only the extras your workflow needs (`python3 -m pip install 'alphakiln[<extra>]'`, or `'.[<extra>]'` from a source checkout):

| Extra | Enables | Install command |
| --- | --- | --- |
| `Core` | Daily & minute-Bar evaluation, Causal Gate, `import-demo`, `mining-demo`, `read-bar-evaluations`, DuckDB store | `python3 -m pip install 'alphakiln'` |
| `[mining]` | PyTorch DSO policy search & DEAP GP symbolic mining (`symbolic-factor-mining`) | `python3 -m pip install 'alphakiln[mining]'` |
| `[synthesis]` | LASSO, ElasticNet, LightGBM, PCA, Dynamic Blend & `factor-synthesis-demo` | `python3 -m pip install 'alphakiln[synthesis]'` |
| `[backtest]` | VectorBT local portfolio backtest engine & `backtest-demo` | `python3 -m pip install 'alphakiln[backtest]'` |
| `[markets]` | Public market extractors (Kenneth French, Binance Vision, AKShare) | `python3 -m pip install 'alphakiln[markets]'` |
| `[viz,mcp]` | Read-only Streamlit dashboard (`dashboard`) & stdio MCP server (`alphakiln-mcp`) | `python3 -m pip install 'alphakiln[viz,mcp]'` |
| `[qlib]` | Qlib adapter (`pyqlib`, `filelock`) | `python3 -m pip install 'alphakiln[qlib]'` |
| `[acceleration]` | Numba kernel acceleration | `python3 -m pip install 'alphakiln[acceleration]'` |
| `[dev]` | Pytest suite (`pytest`, `pytest-xdist`, `alphalens-reloaded`) | `python3 -m pip install 'alphakiln[dev]'` |
| `[all]` | All optional extras (subject to platform Torch/Qlib wheel availability) | `python3 -m pip install 'alphakiln[all]'` |

</details>

Run these independent synthetic demos across all 5 workflow stages (data import, mining, evaluation, synthesis, and local backtest) from a writable directory. Each demo runs on self-contained synthetic fixtures and allocates fresh run directories (only `read-bar-evaluations` and `dashboard` consume `bar-demo`'s DuckDB); `backtest-demo` requires `[backtest]` and compiles VectorBT/Numba caches once on its first cold run (~20–25s), while warm-cache core execution finishes in <1s.

```bash
alphakiln import-demo > import.json
alphakiln mining-demo > mining.json
alphakiln daily-demo > daily.json
alphakiln bar-demo > bar.json
alphakiln factor-synthesis-demo --method weighted_sum > synthesis.json
alphakiln backtest-demo > backtest.json
db="$(python3 -c 'import json; print(json.load(open("bar.json"))["metrics"]["results_db"]["path"])')"
alphakiln read-bar-evaluations --results-db "$db" > bar-read.json
alphakiln dashboard --results-db "$db" --dry-run
# Drop --dry-run to open the read-only dashboard at http://127.0.0.1:8501.
```

The Bar response includes this diagnostic for the 1-Bar horizon, excerpted from a synthetic run.

```json
{
  "ok": true,
  "exit_code": 0,
  "metrics": {
    "diagnostics_report": {
      "schema": "time_series_diagnostics.v1",
      "horizons": [
        {
          "horizon_bars": 1,
          "ic": {"sample_count": 239, "spearman_ic": 0.5012956647093985, "reason": null},
          "bootstrap": {
            "block_length": 27,
            "n_boot": 999,
            "valid_replicates": 999,
            "lower": 0.46960199268106917,
            "upper": 0.5448401913479641,
            "reason": null
          },
          "interval_usability": {"descriptive_stats_usable": true}
        }
      ]
    }
  },
  "next_actions": ["Pass metrics.results_db.path to read-bar-evaluations --results-db."]
}
```

The [AI workflow showcase](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/AI_WORKFLOW_SHOWCASE.md) follows several candidates through preflight, calibration and trial gates, synthesis, a toy backtest and DuckDB read-back.

The two NQ intraday futures examples below require running from the root of a cloned source checkout (see the source checkout note above; passing `--output-dir` without `--output-root` isolates sidecar metadata beside your output directory so the repository root stays free of `outputs/`, `tmp/`, and `cache/`). For a self-contained intraday futures fixture (single-contract `NQZ26` `1m` bars on `CMEGlobex_Equity` with `ETH` / `RTH` session views), see the [NQ 1min ETH/RTH example](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/nq_intraday_futures/README.md):

```bash
python3 -m tools.agent_harness.cli time-series-analysis --config examples/nq_intraday_futures/eval_eth.json --output-dir work/nq-eth-eval
python3 -m tools.agent_harness.cli time-series-analysis --config examples/nq_intraday_futures/eval_rth.json --output-dir work/nq-rth-eval
# Or via the public CLI:
alphakiln time-series-analysis --config examples/nq_intraday_futures/eval_eth.json --output-dir /tmp/nq-eth-eval
```

For the full multi-session NQ `1m` end-to-end report pipeline (Train/OOS splits, PIT `5m`/`15m` → `1m` alignment via [full_report_factor.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/nq_intraday_futures/full_report_factor.py), adaptive bootstrap, Holm trial selection, Markdown/CSV `return_unit: decimal` diagnostics, and DuckDB ingestion/readback), run [run_full_report_example.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/nq_intraday_futures/run_full_report_example.py):

```bash
python3 examples/nq_intraday_futures/run_full_report_example.py --output-dir /tmp/nq-full-report
```

## AI Agent & CLI Interface

### Agent Skill & Claude Code Plugin

Copy the entire [Factor Research Skill](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/skills/factor-research/SKILL.md) directory, including its references, into your client's skills directory. With Claude Code, run `claude --plugin-dir .` from the checkout to load the [plugin manifest](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/.claude-plugin/plugin.json) and invoke `/alphakiln:factor-research`. See [AGENTS.md](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/AGENTS.md) or [CLAUDE.md](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/CLAUDE.md) for project instructions.

### Stdio MCP Server

With `uvx` on the MCP client's PATH, add this entry to `mcpServers` in Claude Desktop, Cursor, Claude Code or Windsurf to launch the server directly from PyPI (for a source checkout, replace only the `alphakiln` package name with `/path/to/alphakiln` and keep `[mcp,synthesis,backtest]`). The `[synthesis]` and `[backtest]` extras let the server run `run_factor_synthesis_demo` and `run_backtest_demo`.

```json
{
  "mcpServers": {
    "alphakiln": {
      "command": "uvx",
      "args": ["--python", "3.12", "--from", "alphakiln[mcp,synthesis,backtest]", "alphakiln-mcp"]
    }
  }
}
```

The server runs locally. Use absolute paths for tool inputs. See the [CLI and MCP mapping](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/skills/factor-research/references/cli_contract.md).

### Two-Tier CLI (alphakiln & Full Harness)

AlphaKiln exposes a **two-tier CLI**, with strict JSON output and `--dry-run` preflight across commands:

- **Public agent CLI (`alphakiln`)**: 10 focused commands covering end-to-end demos (`import-demo`, `mining-demo`, `daily-demo`, `bar-demo`, `factor-synthesis-demo`, `backtest-demo`), local evaluation (`single-factor-analysis`, `time-series-analysis`), DuckDB read-back (`read-bar-evaluations`), and the local viewer (`dashboard`), with `--compact` single-line JSON output. See the [CLI and MCP mapping](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/skills/factor-research/references/cli_contract.md).
- **Full research harness (`python3 -m tools.agent_harness.cli`)**: 21 subcommands for external orchestrators and multi-market pipelines, alongside standalone research entry points ([run_analysis_main.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/run_analysis_main.py), [run_factor_synthesis.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/run_factor_synthesis.py), [run_symbolic_factor_mining.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/run_symbolic_factor_mining.py)). See [public scope](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/PUBLIC_SCOPE.md).

<details>
<summary>Full Harness CLI command reference (21 commands)</summary>

| Group | Commands |
| --- | --- |
| **Market DB & bar governance** | `market-db` (`init` / `adopt` / `show` / `migrate-profile`), `import-bars`, `build-bars`, `audit-bars`, `build-roll-schedule` |
| **Factor value store** | `write-factor-values`, `read-factor-values`, `verify-factor-values` |
| **Evaluation, causal gate & queries** | `single-factor-analysis`, `time-series-analysis`, `verify-factor-causality`, `read-bar-evaluations` |
| **Symbolic mining & screening** | `symbolic-factor-mining`, `quanta-alpha-realize`, `parent-factor-screen` |
| **Synthesis & deployment alignment** | `factor-synthesis`, `export-strategy`, `verify-target-alignment`, `alignment-run` |
| **Monitoring & cleanup** | `monitor-refresh`, `outputs-gc` |

```bash
# Export and verify portable cross-market target positions and orders from a StrategyBundle
python3 -m tools.agent_harness.cli export-strategy --target signal_export \
  --bundle-dir "$BUNDLE_DIR" --output-dir work/signal-candidate
python3 -m tools.agent_harness.cli verify-target-alignment --target signal_export \
  --bundle-dir "$BUNDLE_DIR" --artifact-dir work/signal-candidate
```

</details>

<details>
<summary>Copy a research prompt</summary>

```text
Use the Factor Research Skill and run the AI workflow showcase in a fresh
writable directory. Freeze the hypothesis, candidates, split and screening
rule. Use only synthetic data. Preflight each evaluation, capture stdout and
stderr, and report the IC and sample count, null reasons, calibration status
and complete trial family. Combine only the candidates eligible for the
synthetic backtest. Verify the DuckDB and dashboard plan. Report rejected
candidates, artifact paths, and whether the evidence permits a significance claim.
```

</details>

## Multi-Market Data & Public Benchmarks

### Declarative Multi-Market Adapters (`slot.yaml`)

Connect local [CSV, Parquet or DuckDB](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/DATA_IMPORT.md) feeds without writing a custom Python adapter by declaring a versioned `slot.yaml`, or use built-in native market slots:

| Market | Coverage | Adapter | Guide |
| --- | --- | --- | --- |
| **China A-shares (daily / minute)** | XSHG / XSHE with point-in-time adjustment and microstructure rules | Native `jq_ashare_local` or CSV / DuckDB | [Local workflow](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/LOCAL_WORKFLOW.md) · [Stock pools](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/STOCK_POOLS.en.md) |
| **US equities & global indices** | XNYS / XNAS with verified PMC calendars and DST handling | Declarative `slot.yaml` + MarketDB profile | [Market database guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/MARKET_DATABASE_GUIDE.en.md) · [Config reference](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CONFIG.md) |
| **Domestic & global futures** | CME / SHFE / INE / DCE / CZCE / CFFEX / GFEX (ETH/RTH & session rolls) | Native `cn_futures` / `global_futures` or declarative `slot.yaml` | [NQ 1min ETH/RTH example](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/nq_intraday_futures/README.md) · [Trading calendar](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/TRADING_CALENDAR.en.md) |
| **24/7 crypto & custom markets** | Arbitrary timezones, 24/7 sessions, and auxiliary series such as funding rates | Zero-code declarative `slot.yaml` | [Crypto example](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/declarative_crypto/README.md) · [Custom market & deploy guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CUSTOM_MARKET_AND_DEPLOY_GUIDE.en.md) |

### 10-Minute Reproducible Public Benchmark (`[markets]`, No AI Assistant Required)

Install `alphakiln[markets]` to download, SHA-256 freeze, and build three reproducible public market DuckDBs with versioned `MarketDB` profiles (enforcing single-market isolation against accidental cross-database mixing) — add `[synthesis]` (`python3 -m pip install 'alphakiln[markets,synthesis]'`) if you also want to render the evaluation plot with `--plot-out`:

- **Kenneth R. French**: 49 industry portfolios + FF3 daily series (since 1963)
- **Binance Vision**: 10 USDT spot pairs at `1min` and derived `1d` bars
- **AKShare**: China broad-based indices and Shenwan Level-1 industry daily indices

Run the end-to-end Kenneth French 49-industry 12–1 month momentum evaluation directly from the CLI (~3 min to download & build DuckDB + ~15s for Causal Gate & cross-sectional evaluation), or open the step-by-step [French quickstart notebook](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/french_quickstart.ipynb) (also see [Getting Started (EN)](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/GETTING_STARTED_EN.md)):

```bash
python3 -m pip install 'alphakiln[markets,synthesis]'
python3 -m data_pipeline.extractors.public_markets.french \
  --work-dir work/french --db work/french/market.duckdb
python3 -m examples.french_industry_momentum \
  --work-dir work/french --plot-out work/french/evaluation-result.png
```

Real exploratory output from [french_industry_momentum.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/french_industry_momentum.py) across default horizons (`1d`, `5d`, `20d`) on Kenneth R. French 49 US value-weighted industry portfolios (`2022-01-03` to `2026-09-30`; upstream Kenneth French ZIP snapshot date `2026-11-24` — upstream historical revisions may slightly shift trailing digits of the `1d` metrics; Causal Gate `passed`, `trial_selection={"method": "holm"}` family complete). Per [evaluation policy](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/EVAL_POLICY.md), `causal_gate.ok` establishes non-lookahead compliance rather than statistical significance: raw `nw94_prewhitened` Adaptive HAC `p_value` and Holm `adjusted_p_value` below are diagnostic (`calibration_status: "uncalibrated"`, `significance_interpretation_usable: false`, `significant: false`, not `calibrated_pass`), and quintile curves in the chart are descriptive close-only uncosted buckets rather than a tradable backtest:

```json
{
  "ok": true,
  "dataset": "kf_us_portfolios_v1",
  "evaluation_scope": "exploratory_diagnostic_uncalibrated",
  "factor": "industry_momentum_252_21",
  "start_date": "2022-01-03",
  "end_date": "2026-09-30",
  "instruments": 49,
  "causal_gate": {"ok": true, "status": "passed", "resolved_mode": "vectorized"},
  "horizons": [
    {
      "horizon_bars": 1,
      "valid_cross_sections": 1189,
      "mean_spearman_ic": 0.031506513858631645,
      "adaptive_hac": {"lag": 16, "t_stat": 4.3228540587243085, "p_value": 3.52900069524004e-05},
      "holm": {"method": "holm", "adjusted_p_value": 0.00010587002085720121, "significant": false},
      "interval_usability": {"calibration_status": "uncalibrated", "descriptive_stats_usable": true, "significance_interpretation_usable": false}
    },
    {
      "horizon_bars": 5,
      "valid_cross_sections": 1185,
      "mean_spearman_ic": 0.039823043141307156,
      "adaptive_hac": {"lag": 49, "t_stat": 2.8490549593115566, "p_value": 0.00728710591904723},
      "holm": {"method": "holm", "adjusted_p_value": 0.01457421183809446, "significant": false},
      "interval_usability": {"calibration_status": "uncalibrated", "descriptive_stats_usable": true, "significance_interpretation_usable": false}
    },
    {
      "horizon_bars": 20,
      "valid_cross_sections": 1170,
      "mean_spearman_ic": 0.03989647653933368,
      "adaptive_hac": {"lag": 33, "t_stat": 1.2695351729658155, "p_value": 0.21002508753263233},
      "holm": {"method": "holm", "adjusted_p_value": 0.21002508753263233, "significant": false},
      "interval_usability": {"calibration_status": "uncalibrated", "descriptive_stats_usable": true, "significance_interpretation_usable": false}
    }
  ]
}
```

> **Why is `"significant": false` shown even when 1d `adjusted_p_value` (`0.000106`) < `0.05`?** Because the 49-industry cross-section is outside the pre-registered simulation calibration grid, the gate conservatively outputs `calibration_status: "uncalibrated"` and suppresses `significant: true` rather than claiming calibrated significance—this is intentional gate conservatism, not a p-value calculation error.

![Kenneth French 49 US Industry Portfolios 12-1 Month Momentum Evaluation](https://github.com/GSX-Eis/alphakiln/raw/v0.3.1/docs/assets/evaluation-result.png)

See [public market databases](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/PUBLIC_MARKET_DATABASES.en.md) for Binance / AKShare rebuild commands, snapshot verification, and upstream data terms.

> **Proxy / self-signed CA troubleshooting:** If `[markets]` downloads fail with an SSL certificate error behind a campus or corporate proxy, set the standard `requests` CA bundle variable before running:
> `export REQUESTS_CA_BUNDLE=/path/to/ca.pem`

### Persistent Bar & Factor Storage

When scaling beyond single CSV runs, store validated bars and futures roll schedules in profile-checked DuckDB (`import-bars`, `build-bars`, `audit-bars`, `build-roll-schedule`), and persist cross-frequency factor values in `MarketFactorValueStore` (Hive-partitioned Parquet + append-only JSONL ledgers + read-only DuckDB views via `write-factor-values` / `read-factor-values` / `verify-factor-values`). See the [Bar and storage contract](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/TIME_SERIES_CONTRACT.en.md), [factor interface](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/FACTOR_INTERFACE.md), [factor template](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/FACTOR_TEMPLATE.md), [data semantics](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/SEMANTICS.md), [cache invalidation](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CACHE_INVALIDATION.md), and [canonical data reads](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CANONICAL_DATA_READS.md).

## For Academic Research & Teaching

### Method-to-Module Map

| Academic Concept | Implementation & Documentation |
| --- | --- |
| **Purged OOS & Embargo Splits** | [split.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/backtest_and_analysis/evaluation/split.py) · [research_split.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/factor_synthesis/research_split.py) · [Evaluation policy](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/EVAL_POLICY.md) |
| **Newey-West / Adaptive HAC & Block Bootstrap** | [cross_section.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/backtest_and_analysis/evaluation/cross_section.py) (`nw94_prewhitened`) · [inference.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/backtest_and_analysis/time_series/inference.py) (Moving-Block Bootstrap v2) · [Evaluation engine](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/EVALUATION_ENGINE.en.md) |
| **FWER / FDR Multiple Testing & Calibration Gate** | [inference.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/backtest_and_analysis/time_series/inference.py) · [calibration.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/backtest_and_analysis/evaluation/calibration.py) (`TrialLedger`: Holm FWER / Benjamini-Hochberg FDR + `calibration_status` gate) |
| **Kenneth R. French Reproducible Benchmark** | [french.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/data_pipeline/extractors/public_markets/french.py) · [french_industry_momentum.py](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/french_industry_momentum.py) · [french_quickstart.ipynb](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/french_quickstart.ipynb) |

### Connecting Local CRSP / WRDS Exports (100% Offline)

Local CRSP / WRDS export ingestion runs 100% locally and offline — AlphaKiln ships **no** built-in WRDS account credentials or online downloader. After exporting CSV or Parquet files locally from WRDS / CRSP (date, stable `PERMNO` or `TICKER` security identifier, price, adjusted return, volume, or custom factor columns), choose one of the verified local paths below:

1. **Profile-Checked MarketDB via `import-bars`** — choose the sub-path that matches your input format:
   - **Normalized CSV + Metadata (`us_equity.yaml` starting template)**: [us_equity.yaml](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/config/market_databases/us_equity.yaml) is an example fixture template scoped to `allowed_slot_providers: [duckdb_table]`, `1d`, `calendar_coverage: 2020-01-02..2026-12-31`, and `instrument_id_pattern: ^[A-Z.]+\.(XNYS|XNAS)$`. When ingesting CRSP / WRDS histories (such as pre-2020 date ranges or stable numeric `PERMNO` identifiers rather than reusable `TICKER` symbols), copy this template, update `db_id`, `calendar_coverage`, and `instrument_id_pattern` as needed, normalize bars into UTC session bar-start timestamps + OHLCV CSV and metadata JSON, and run:

     ```bash
     python3 -m tools.agent_harness.cli market-db init --profile work/crsp_equity.yaml --db work/crsp_equity.duckdb
     python3 -m tools.agent_harness.cli import-bars --db work/crsp_equity.duckdb --bars work/crsp_bars.csv --metadata work/instruments.json
     ```

   - **Declarative `--manifest slot.yaml` (`csv_files` / `parquet_glob` sources)**: Use a custom MarketDB profile whose `allowed_slot_providers` explicitly includes `csv_files` (or `parquet_glob`) alongside `duckdb_table` — see [examples/declarative_crypto/market_db.yaml](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/examples/declarative_crypto/market_db.yaml) and the [custom market & deploy guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/CUSTOM_MARKET_AND_DEPLOY_GUIDE.en.md) — rather than `us_equity.yaml` directly (which only allows `duckdb_table`), then run `python3 -m tools.agent_harness.cli import-bars --db <target.duckdb> --manifest slot.yaml`.

   See the [market database guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/MARKET_DATABASE_GUIDE.en.md) for full `import-bars` and `slot.yaml` schemas.

2. **Direct `DuckDBAdapter` / Partitioned Parquet**: Read locally imported DuckDB tables (for example `price_data_daily`) or Hive-partitioned Parquet directories (`<parquet_dir>/<table>/year=YYYY/month=M/*.parquet`) via `DuckDBAdapter` and [data_access.json](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/config/data_access.json) with minimal required columns `date`, `stock_code`, and price/return/volume or custom factor columns. See the [local data import guide](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/docs/DATA_IMPORT.md).

### Citation

If you use AlphaKiln in academic research or coursework, see [CITATION.cff](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/CITATION.cff) — GitHub's native **Cite this repository** button generates BibTeX and APA entries directly from it.

## Feedback & Community

[Open an issue](https://github.com/GSX-Eis/alphakiln/issues/new/choose) to report a bug, request a market calendar or data contract, or share an AI workflow. Share synthetic or sanitized examples. See [contributing](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/CONTRIBUTING.md), [security](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/SECURITY.md), and the [changelog](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/CHANGELOG.md).

Licensed under the [Apache License 2.0](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/LICENSE). See [NOTICE](https://github.com/GSX-Eis/alphakiln/blob/v0.3.1/NOTICE) for attribution.
