Skip to main content

JoinQuant single factor analyzer

Project description

jqfactor_analyzer

聚宽单因子分析工具开源版


聚宽单因子分析工具开源版是提供给用户进行因子分析的工具,提供了包括计算因子IC值,因子收益,因子换手率等各种详细指标,用户可以按照自己的需求查看因子详情。

安装

pip install jqfactor_analyzer

升级

pip install -U jqfactor_analyzer

具体使用方法

analyze_factor: 因子分析函数

使用示例

  • 示例:5日平均换手率因子分析

# 载入函数库
import pandas as pd
import jqfactor_analyzer as ja

# 获取 jqdatasdk 授权,输入用户名、密码,申请地址:http://t.cn/EINDOxE
# 聚宽官网及金融终端,使用方法参见:http://t.cn/EINcS4j
import jqdatasdk
jqdatasdk.auth('username', 'password')

# 获取5日平均换手率因子2018-01-01到2018-12-31之间的数据(示例用从库中直接调取)
# 聚宽因子库数据获取方法在下方
from jqfactor_analyzer.sample import VOL5
factor_data = VOL5

# 对因子进行分析
far = ja.analyze_factor(
    factor_data,  # factor_data 为因子值的 pandas.DataFrame
    quantiles=10,
    periods=(1, 10),
    industry='jq_l1',
    weight_method='avg',
    max_loss=0.1
)

# 获取整理后的因子的IC值
far.ic

结果展示:

1

# 生成统计图表
far.create_full_tear_sheet(
    demeaned=False, group_adjust=False, by_group=False,
    turnover_periods=None, avgretplot=(5, 15), std_bar=False
)

结果展示:

2

获取聚宽因子库数据的方法

  1. 聚宽因子库包含数百个质量、情绪、风险等其他类目的因子

  2. 连接jqdatasdk获取数据包,数据接口需调用聚宽 jqdatasdk 接口获取金融数据(试用注册地址)

    # 获取因子数据:以5日平均换手率为例,该数据可以直接用于因子分析
    # 具体使用方法可以参照jqdatasdk的API文档
    import jqdatasdk
    jqdatasdk.auth('username', 'password')
    # 获取聚宽因子库中的VOL5数据
    factor_data=jqdatasdk.get_factor_values(
        securities=jqdatasdk.get_index_stocks('000300.XSHG'),
        factors=['VOL5'],
        start_date='2018-01-01',
        end_date='2018-12-31')['VOL5']
    
  3. 自己算好因子值需要转换成 pandas.DataFrame 格式的数据

    • index 为日期,格式为 pandas 日期通用的 DatetimeIndex

    • columns 为股票代码,格式要求符合聚宽的代码定义规则(如:平安银行的股票代码为 000001.XSHE)

      • 如果是深交所上市的股票,在股票代码后面需要加入.XSHE
      • 如果是上交所上市的股票,在股票代码后面需要加入.XSHG

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

jqfactor_analyzer-1.0.1.tar.gz (246.6 kB view details)

Uploaded Source

Built Distributions

jqfactor_analyzer-1.0.1-py3.6.egg (298.8 kB view details)

Uploaded Source

jqfactor_analyzer-1.0.1-py3-none-any.whl (252.8 kB view details)

Uploaded Python 3

File details

Details for the file jqfactor_analyzer-1.0.1.tar.gz.

File metadata

  • Download URL: jqfactor_analyzer-1.0.1.tar.gz
  • Upload date:
  • Size: 246.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for jqfactor_analyzer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 baf278f94dded33729b7cc8c49fd43231b23b532872d04e173ff3bc77279c294
MD5 2bd7d2e458bd8eecf3441e1aa195f65c
BLAKE2b-256 8ca3e966585b302eb0943b7d06e10e7a63237774fab5ff346f584dd6c79edf7f

See more details on using hashes here.

File details

Details for the file jqfactor_analyzer-1.0.1-py3.6.egg.

File metadata

  • Download URL: jqfactor_analyzer-1.0.1-py3.6.egg
  • Upload date:
  • Size: 298.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for jqfactor_analyzer-1.0.1-py3.6.egg
Algorithm Hash digest
SHA256 cdd61a8eb950e103eb92e789a1a335fedf6aec0c4198c610e0b1c91d20d11f7f
MD5 a51cd49d26700395658418cae327c462
BLAKE2b-256 f32a9c9158749dfd616a9677a77babe10bffc8d8eb660108ff85cc031bf8ea83

See more details on using hashes here.

File details

Details for the file jqfactor_analyzer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: jqfactor_analyzer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 252.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for jqfactor_analyzer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a65dacba946354b43e4ef5311f3c265f11b1df60a0ca7234c974473bda0f6f03
MD5 b2663bcc6b181ff163c2a95fd62214b7
BLAKE2b-256 5df9838461e507bb1e524ed4e1db0089c2f11632ebdf2c99a4137e6770b63537

See more details on using hashes here.

Supported by

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