Skip to main content

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

golden_qlib_alpha-0.0.5.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

golden_qlib_alpha-0.0.5-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

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

Hashes for golden_qlib_alpha-0.0.5.tar.gz
Algorithm Hash digest
SHA256 d73665dbeadc784068680ca945f742965b9903e81953cc7b4681de3274f49063
MD5 5a235cd7a7b9921e628132cd157cfce5
BLAKE2b-256 ec4c4043d6a31aa777cf186419c8a381e210d92e616af561490701fed3c85ca4

See more details on using hashes here.

File details

Details for the file golden_qlib_alpha-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for golden_qlib_alpha-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ce08963d999acaf6b16f781c8c7e566b971c9b00ff76af429884fe571411d490
MD5 241bee65cfcf89427589d0ff0ba3a1f8
BLAKE2b-256 34d0c867f5f408e15fe7dd4e1d81fcaed55de2bd114d03366564328b020d7541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page