xalpha
基金投资的全流程管理
基金股票信息与净值获取,精确到分的投资账户记录整合分析与丰富可视化,简单的策略回测以及根据预设策略的定时投资提醒。尤其适合资金反复进出的定投型和网格型投资的概览与管理分析。AI agent 原生支持。
🎉 0.3 版本起支持通用日线和实时数据获取器,统一接口一行可以获得几乎任何市场上存在产品的价格数据,进行分析。
🍭 0.9 版本起支持持仓基金组合的底层持仓配置和股票细节透视,掌握底层持仓和跟踪机构股票池与买卖特点,从未如此简单。
一行拿到基金信息:
nfyy = xa.fundinfo("501018")
一行根据账单进行基金组合全模拟,和实盘完全相符:
jiaoyidan = xa.record(path) # 额外一行先读入 path 处的 csv 账单
shipan = xa.mul(status=jiaoyidan) # Let's rock
shipan.summary() # 看所有基金总结效果
shipan.get_stock_holdings() # 查看底层等效股票持仓
一行获取各种金融产品的历史日线数据或实时数据
xa.get_daily("SH518880") # 沪深市场历史数据
xa.get_daily("USD/CNY") # 人民币中间价历史数据
xa.get_rt("commodities/crude-oil") # 原油期货实时数据
xa.get_rt("HK00700", double_check=True) # 双重验证高稳定性支持的实时数据
一行拿到指数,行业,基金和个股的历史估值和即时估值分析(指数部分需要聚宽数据,本地试用申请或直接在聚宽云平台运行)
xa.PEBHistory("SH000990").summary()
xa.PEBHistory("F100032").v()
一行定价可转债
xa.CBCalculator("SH113577").analyse()
一行估算基金净值 (支持核心 QDII 基金 T-1 以及基于期货的 T-0 实时净值预测)
xa.QDIIPredict("SH501018", positions=True).get_t0_rate()
xalpha 不止如此,更多特性,欢迎探索。不只是数据,更是工具!
文档
在线文档地址: https://xalpha.readthedocs.io/
或者通过以下命令,在本地doc/build/html内阅读文档。
$ cd doc
$ make html
安装
pip install xalpha
目前仅支持 python 3 。
若想要尝试最新版,
$ git clone https://github.com/refraction-ray/xalpha.git
$ cd xalpha && pip3 install .
用法
本地使用
由于丰富的可视化支持,建议配合 Jupyter Notebook 使用。可以参照这里给出的示例连接,快速掌握大部分功能。
支持多市场指数与个股的 K 线及历史估值可视化分析:
基于底层数据的投资账户历史净值与各基金成本偏离度分析:
核心 QDII 基金的 T-1 净值预测及基于期货的 T-0 实时净值仪表盘:
自动穿透持仓,获取基金组合底层的等效股票集中度及行业分布:
在量化平台使用
这里以聚宽为例,打开聚宽研究环境的 jupyter notebook,运行以下命令:
>>> !pip3 install xalpha --user
>>> import sys
>>> sys.path.insert(0, "/home/jquser/.local/lib/python3.6/site-packages")
>>> import xalpha as xa
即可在量化云平台正常使用 xalpha,并和云平台提供数据无缝结合。
如果想在云平台研究环境尝试最新开发版 xalpha,所需配置如下。
>>> !git clone https://github.com/refraction-ray/xalpha.git
>>> !cd xalpha && python3 setup.py develop --user
>>> import sys
>>> sys.path.insert(0, "/home/jquser/.local/lib/python3.6/site-packages")
>>> import xalpha as xa
由于 xalpha 整合了部分聚宽数据源的 API,在云端直接 xa.provider.set_jq_data(debug=True) 即可激活聚宽数据源。
致谢
感谢集思录对本项目的支持和赞助,可以在这里查看基于 xalpha 引擎构建的 QDII 基金净值预测 (2026.3 合规原因下架)。
免责声明
本项目仅提供获取公开数据的示例代码,不提供任何数据存储和服务。 软件用户需自行遵守相关网站的使用条款及法律法规。
博客
Metadata
Release files for xalpha 0.12.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xalpha-0.12.4.tar.gz | 176.1 kB | Without provenance | Details for xalpha-0.12.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xalpha-0.12.4-py3-none-any.whl | Python 3 | none | any | Details for xalpha-0.12.4-py3-none-any.whl |
Total release size: 341.4 kB
Release files / xalpha-0.12.4.tar.gz
| Download URL | xalpha-0.12.4.tar.gz |
|---|---|
| Size | 176.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
821b20cbf9575eeb51c2dc1d2116cb83ffec7810d845e31e572fecadfef67052
|
|
BLAKE2b-256 checksum How to use checksums |
818f693a06e928a0c806289880287bc4eeb7773fb35280337a9f18bdb0f219aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / xalpha-0.12.4-py3-none-any.whl
| Download URL | xalpha-0.12.4-py3-none-any.whl |
|---|---|
| Size | 165.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4eb6113e86f1a52393ead74c2b9d110927c7ea6acff069fdfd28c0e687155e34
|
|
BLAKE2b-256 checksum How to use checksums |
b1ce9d1302ebfb6375bd4e4741d7d9b2e53c66c94842e78e0e25893eb82ac327
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for xalpha 0.12.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.