Files
qlib/backend/app/quant/qlib_adapter/engine.py
T
Simon 8f8b6d274f feat: 解决 aarch64 上 Qlib 安装(源码 git 固化依赖)并记录下载代理规则
- backend/pyproject.toml + uv.lock: pyqlib 以 git+https 固定 commit 79633dd 注册为核心依赖,
  替代无法在 Linux aarch64 安装的 PyPI wheel(ROADMAP §2 旧备注)
- engine.py: 更正占位说明(Qlib 现已可安装,工作流实现待 Phase 2 补齐)
- AGENT.md §0: 网络下载困难时使用 HTTP 代理 192.168.1.160:3128
- README / ROADMAP: 同步 Qlib 安装方式与代理说明
2026-09-06 17:45:01 +08:00

39 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Qlib 后端引擎(桥接占位)。
本模块是 Qlib 引擎的桥接边界(AGENT.md §14 / §15:Qlib 只允许在
quant/qlib_adapter/ 内被引用)。Qlib(pyqlib)已通过「源码 git 安装」成功
部署到本机(Linux aarch64 + CPython 3.12,backend/.venv,uv 管理;
backend/pyproject.toml 固定 commit,细节见 docs/ROADMAP.md §2 备注)。
基于 Qlib 的因子 / 回测工作流(Parquet/本地行情 → QlibDataset → Alpha158 →
LightGBM 训练/预测 → 回测,并归一化为 domain.entities.research 输出)属
Phase 2 后续实现;当前默认研究引擎仍为 LocalEngine(纯 pandas,见
app/quant/engine.py),业务层经 QuantEngine Protocol 注入,切换无需改业务代码。
"""
from __future__ import annotations
import pandas as pd
from app.domain.entities.research import BacktestResult, FactorTestReport, ResearchSpec
from app.quant.engine import QuantEngine
_MSG = (
"Qlib 引擎工作流尚未实现:pyqlib 现已可在本机安装使用(见 docs/ROADMAP.md §2),"
"但 QlibDataset → LightGBM 的实现待 Phase 2 补齐。当前请使用默认 LocalEngine。"
)
class QlibEngine(QuantEngine):
"""pyqlib 后端占位:抛 NotImplementedError 并给出启用指引。"""
name = "qlib"
def run_factor_test(
self, daily: pd.DataFrame, spec: ResearchSpec, horizon_days: int = 21
) -> FactorTestReport:
raise NotImplementedError(_MSG)
def run_backtest(self, daily: pd.DataFrame, spec: ResearchSpec) -> BacktestResult:
raise NotImplementedError(_MSG)