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
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
golden_qlib_alpha-0.0.4.tar.gz
(19.2 kB
view details)
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.4.tar.gz.
File metadata
- Download URL: golden_qlib_alpha-0.0.4.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
badf6124bebb94d4e122696f9f534981c87bee0d54583dd608cb99f7de5e00a4
|
|
| MD5 |
7f10132c621a7b87e8bd0dd4a1b77803
|
|
| BLAKE2b-256 |
79ace8862ae760e63fd6bd2d461314a9731b4cba900a7dbfc8f0d076a720009b
|
File details
Details for the file golden_qlib_alpha-0.0.4-py3-none-any.whl.
File metadata
- Download URL: golden_qlib_alpha-0.0.4-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 |
65edf6692b6fed8aca9788e7ad0af3f0a0e7abb533eb3e04c8e37d225845f262
|
|
| MD5 |
15f2d4b3ba758cf4724db89f7b456cfd
|
|
| BLAKE2b-256 |
37c6aa23b3167bb7b9e6bc76e1d6e2d9a9116a0efa333f9e0e904e42826e676f
|