saqds · 序衍量化核心工具库
面向量化投研的一站式底层工具集:A 股 / 美股 / 港股行情(SAOIDC 密钥鉴权 + 直连 ClickHouse)、 因子运行与测评、数学 / 统计指标、公式可视化绘图、CLI 工具。
序衍量化专有软件,未经书面许可禁止外部分发、商用。
安装
pip install saqds
需要 Python >= 3.10。
快速上手
行情数据
import saqds
# 配置 SAOIDC Access Key(二选一:代码内初始化,或设置环境变量 SAQDS_ACCESS_KEY)
saqds.init(key="saoidc_你的Key")
# A 股日线(纯数字代码,不带 .SH / .SZ)
df = saqds.get_stock_hist("600519", "20260101", "20260716")
# 批量 A 股 / 指数全成分 / 美股 / ETF
df = saqds.get_stock_hist_batch(["600519", "000001"], "20260101", "20260716")
df = saqds.get_index_hist("hs300", "20260101", "20260716")
df = saqds.get_us_stock_hist("AAPL", "20260101", "20260716")
df = saqds.get_etf_hist("510300", "20260101", "20260716")
数值工具
import saqds
from saqds.stats import mean
saqds.sum_of_squares([1, 2, 3]) # 14.0
mean([2, 4, 6]) # 4.0
因子运行与测评
import saqds
# 运行因子脚本(safactor_factor_version 的 generate(df) 契约)
fv = saqds.compute_factor_value("ma_bias", "20260101", "20260716", codes=["600519"])
# 因子 IC / IR 测评
metrics = saqds.evaluate_factor("ma_bias", "20260101", "20260716", codes=["600519"])
公式绘图
from saqds.formula_plot import plot_custom_formula
img = plot_custom_formula("x**2 - 4*x", save_path="curve.png")
命令行
saqds 1 2 3 4 # Sum of squares: 30.0
saqds -- -1 2.5 # 负数需用 -- 分隔
主要模块
| 模块 | 说明 |
|---|---|
saqds.clickhouse_tool |
行情客户端(SAOIDC 鉴权 + 直连 ClickHouse):A 股 / 美股 / 港股 / ETF / 指数成分 / 行业 |
saqds.factor |
因子脚本加载与计算(generate(df) 契约) |
saqds.evaluate |
因子 IC / IR 测评、去极值 |
saqds.math / saqds.stats |
数学 / 统计指标 |
saqds.formula_plot |
服务端无 GUI 公式绘图 |
配置
用户侧仅需配置 SAOIDC Access Key,其余参数(鉴权中心地址、ClickHouse 连接等)由数据提供方维护:
export SAQDS_ACCESS_KEY=saoidc_你的Key
或代码内初始化:
saqds.init(key="saoidc_你的Key")
开发
uv sync --group dev # 安装开发依赖
uv run pytest # 单元测试(覆盖率门禁 80%)
uv run ruff check src tests --fix # 静态检查
uv run ty check src # 类型检查
版权
序衍量化 版权所有,未经书面许可禁止外部分发、商用。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saqds-0.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: saqds-0.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 462.8 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
257e265692010d14a012089c9217b6e0b79c8d2e589a5a4388fa624346e2df5f
|
|
| MD5 |
404eb852dcf646819eb17ea74c6367a9
|
|
| BLAKE2b-256 |
8e6f9b0c18cb09483bbeb29a9f961c5ee6f7038a7d7cf0c65422e02a275d1b3f
|