Separate the qlib factor calculation for independent use and simplify its usage.
Project description
项目用途
参考ailabx和qlib,优化了一些代码,将qlib因子计算独立出来使用。并简化使用方法。
用法设计
数据
使用内置的下载数据工具或使用自有数据源,会默认下载几个ETF数据,data_update可用传入codes列表。
from golden_qlib_alpha.data.data_update import data_update
def test():
data_update()
if __name__ == '__main__':
test()
计算因子
from golden_qlib_alpha.datafeed.dataloader import Dataloader
def test2():
code = '510300.SH'
fields = []
names = []
fields += ["Ref($close, 1)/$close"]
names += ["ROC5"]
fields += ["RSRS($high,$low,18)"]
names += ['RSRS']
fields +=["Slope($close,20)"]
names +=['Ret20']
fields+=['$close/Ref($close,20)-1']
names += ['Return20']
df=Dataloader().load([code],'2021-01-01','2022-10-01',names,fields)
print(df)
if __name__ == '__main__':
test2()
用户可以将因子写在用户指定的csv中:
因子名,因子表达式
feature1,$close/Ref($close,20)-1
label设置:
label0,Ref($close, -5)/Ref($close, -1) - 1
读取csv文件,并对指定的数据开展这些表达式的计算。
因子分析
注意: alphalens要安装alphalens-reloaded版本
pip install alphalens-reloaded
因子分析使用方法见tests目录的"test-alphalens.ipynb"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 golden_qlib_alpha-0.0.5.tar.gz.
File metadata
- Download URL: golden_qlib_alpha-0.0.5.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d73665dbeadc784068680ca945f742965b9903e81953cc7b4681de3274f49063
|
|
| MD5 |
5a235cd7a7b9921e628132cd157cfce5
|
|
| BLAKE2b-256 |
ec4c4043d6a31aa777cf186419c8a381e210d92e616af561490701fed3c85ca4
|
File details
Details for the file golden_qlib_alpha-0.0.5-py3-none-any.whl.
File metadata
- Download URL: golden_qlib_alpha-0.0.5-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce08963d999acaf6b16f781c8c7e566b971c9b00ff76af429884fe571411d490
|
|
| MD5 |
241bee65cfcf89427589d0ff0ba3a1f8
|
|
| BLAKE2b-256 |
34d0c867f5f408e15fe7dd4e1d81fcaed55de2bd114d03366564328b020d7541
|