{"id":13488431,"url":"https://github.com/refraction-ray/xalpha","last_synced_at":"2025-05-13T18:14:27.585Z","repository":{"id":43741622,"uuid":"143284193","full_name":"refraction-ray/xalpha","owner":"refraction-ray","description":"基金投资管理回测引擎","archived":false,"fork":false,"pushed_at":"2025-04-24T03:05:48.000Z","size":11554,"stargazers_count":2168,"open_issues_count":49,"forks_count":445,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-04-25T18:01:32.472Z","etag":null,"topics":["backtest","finance","investment","quantitative-trading"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/refraction-ray.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-02T11:12:10.000Z","updated_at":"2025-04-25T14:38:07.000Z","dependencies_parsed_at":"2023-12-04T05:24:01.885Z","dependency_job_id":"d2f97c15-cfbe-47b6-89cb-9eaf0316ef25","html_url":"https://github.com/refraction-ray/xalpha","commit_stats":{"total_commits":368,"total_committers":16,"mean_commits":23.0,"dds":0.08152173913043481,"last_synced_commit":"c7b6153f34c9561bbe4133f878326ea11d080a6e"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refraction-ray%2Fxalpha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refraction-ray%2Fxalpha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refraction-ray%2Fxalpha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refraction-ray%2Fxalpha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refraction-ray","download_url":"https://codeload.github.com/refraction-ray/xalpha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000885,"owners_count":21997443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtest","finance","investment","quantitative-trading"],"created_at":"2024-07-31T18:01:15.551Z","updated_at":"2025-05-13T18:14:27.556Z","avatar_url":"https://github.com/refraction-ray.png","language":"Python","readme":"# xalpha\n\n[![version](https://img.shields.io/pypi/v/xalpha.svg)](https://pypi.org/project/xalpha/)\n[![doc](https://readthedocs.org/projects/xalpha/badge/?style=flat)](https://xalpha.readthedocs.io/)\n[![codecov](https://codecov.io/gh/refraction-ray/xalpha/branch/master/graph/badge.svg)](https://codecov.io/gh/refraction-ray/xalpha)\n[![license](https://img.shields.io/:license-mit-blue.svg)](https://badges.mit-license.org/)\n\n**基金投资的全流程管理**\n\n场外基金的信息与净值获取，精确到分的投资账户记录整合分析与丰富可视化，简单的策略回测以及根据预设策略的定时投资提醒。尤其适合资金反复进出的定投型和网格型投资的概览与管理分析。\n\n🎉 0.3 版本起支持通用日线和实时数据获取器，统一接口一行可以获得几乎任何市场上存在产品的价格数据，进行分析。\n\n🍭 0.9 版本起支持持仓基金组合的底层持仓配置和股票细节透视，掌握底层持仓和跟踪机构股票池与买卖特点，从未如此简单。\n\n一行拿到基金信息：\n\n```python\nnfyy = xa.fundinfo(\"501018\")\n```\n\n一行根据账单进行基金组合全模拟，和实盘完全相符:\n\n```python\njiaoyidan = xa.record(path) # 额外一行先读入 path 处的 csv 账单\nshipan = xa.mul(status=jiaoyidan) # Let's rock\nshipan.summary() # 看所有基金总结效果\nshipan.get_stock_holdings() # 查看底层等效股票持仓\n```\n\n一行获取各种金融产品的历史日线数据或实时数据\n\n```python\nxa.get_daily(\"SH518880\") # 沪深市场历史数据\nxa.get_daily(\"USD/CNY\") # 人民币中间价历史数据\nxa.get_rt(\"commodities/crude-oil\") # 原油期货实时数据\nxa.get_rt(\"HK00700\", double_check=True) # 双重验证高稳定性支持的实时数据\n```\n\n一行拿到指数，行业，基金和个股的历史估值和即时估值分析（指数部分需要聚宽数据，本地试用申请或直接在聚宽云平台运行）\n\n```python\nxa.PEBHistory(\"SH000990\").summary()\nxa.PEBHistory(\"F100032\").v()\n```\n\n一行定价可转债\n\n```python\nxa.CBCalculator(\"SH113577\").analyse()\n```\n\n一行估算基金净值 (QDII 基金需自己提供持仓字典)\n\n```python\nxa.QDIIPredict(\"SH501018\", positions=True).get_t0_rate()\n```\n\nxalpha 不止如此，更多特性，欢迎探索。不只是数据，更是工具！\n\n## 文档\n\n在线文档地址： https://xalpha.readthedocs.io/\n\n或者通过以下命令，在本地`doc/build/html`内阅读文档。\n\n```bash\n$ cd doc\n$ make html\n```\n\n## 安装\n\n```bash\npip install xalpha\n```\n\n目前仅支持 python 3 。\n\n若想要尝试最新版，\n\n```bash\n$ git clone https://github.com/refraction-ray/xalpha.git\n$ cd xalpha \u0026\u0026 pip3 install .\n```\n\n## 用法\n\n### 本地使用\n\n由于丰富的可视化支持，建议配合 Jupyter Notebook 使用。可以参照[这里](https://xalpha.readthedocs.io/en/latest/demo.html)给出的示例连接，快速掌握大部分功能。\n\n部分效果如下：\n\n\u003cimg src=\"doc/source/kline.png\" width=\"90%\"\u003e\n\n\u003cimg src=\"doc/source/tradecost.png\" width=\"90%\"\u003e\n\n\u003cimg src=\"doc/source/positions.png\" width=\"80%\"\u003e\n\n### 在量化平台使用\n\n这里以聚宽为例，打开聚宽研究环境的 jupyter notebook，运行以下命令：\n\n```\n\u003e\u003e\u003e !pip3 install xalpha --user\n\u003e\u003e\u003e import sys\n\u003e\u003e\u003e sys.path.insert(0, \"/home/jquser/.local/lib/python3.6/site-packages\")\n\u003e\u003e\u003e import xalpha as xa\n```\n\n即可在量化云平台正常使用 xalpha，并和云平台提供数据无缝结合。\n\n如果想在云平台研究环境尝试最新开发版 xalpha，所需配置如下。\n\n```\n\u003e\u003e\u003e !git clone https://github.com/refraction-ray/xalpha.git\n\u003e\u003e\u003e !cd xalpha \u0026\u0026 python3 setup.py develop --user\n\u003e\u003e\u003e import sys\n\u003e\u003e\u003e sys.path.insert(0, \"/home/jquser/.local/lib/python3.6/site-packages\")\n\u003e\u003e\u003e import xalpha as xa\n```\n\n由于 xalpha 整合了部分聚宽数据源的 API，在云端直接 `xa.provider.set_jq_data(debug=True)` 即可激活聚宽数据源。\n\n## 致谢\n\n感谢[集思录](https://www.jisilu.cn)对本项目的支持和赞助，可以在[这里](https://www.jisilu.cn/data/qdii/#qdiie)查看基于 xalpha 引擎构建的 QDII 基金净值预测。\n\n## 博客\n\n- [xalpha 诞生记](https://re-ra.xyz/xalpha-%E8%AF%9E%E7%94%9F%E8%AE%B0/)\n\n- [xalpha 设计哲学及其他](https://re-ra.xyz/xalpha-%E8%AE%BE%E8%AE%A1%E5%93%B2%E5%AD%A6%E5%8F%8A%E5%85%B6%E4%BB%96/)\n","funding_links":[],"categories":["Python","Python (1887)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefraction-ray%2Fxalpha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefraction-ray%2Fxalpha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefraction-ray%2Fxalpha/lists"}