Qlib学习笔记

相关链接

win10下安装Qlib

安装,参考: https://qlib.readthedocs.io/en/latest/start/installation.html

pip install pyqlib  -i https://pypi.tuna.tsinghua.edu.cn/simple

解决错误: error in cvxpy setup command: use_2to3 is invalid.

参考: https://exerror.com/error-in-mongoengine-setup-command- use_2to3-is-invalid/

pip install setuptools --upgrade

解决错误:tables版本冲突

ERROR: Cannot install pyqlib==0.7.1, pyqlib==0.7.2 and pyqlib==0.7.2.99 because these package versions have conflicting dependencies.

The conflict is caused by:
    pyqlib 0.7.2.99 depends on tables>=3.6.1
    pyqlib 0.7.2 depends on tables>=3.6.1
    pyqlib 0.7.1 depends on tables>=3.6.1

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

whl安装指定版本的tables

比较简单的方式,访问 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载whl文件,安装:

pip install path_to_/xxx.whl

编译安装 tables

pip install tables==3.6.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

解决错误 distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/: 按提示下载安装c++桌面开发

解决错误: warning C4013: “H5close”未定义;假设外部返回 int LINK : fatal error LNK1181: 无法打开输入文件“hdf5.lib”

参考: https://stackoverflow.com/questions/53643594/unable-to-install-library-due-to-error-with-hdf5

1.从 https://www.hdfgroup.org/downloads/ 下载安装HDF5

  1. 设置环境变量
HDF5_DIR=C:\Program Files\HDF_Group\HDF5\1.12.1\
LIB=C:\Program Files\HDF_Group\HDF5\1.12.1\lib

查看安装位置,版本:

 D:\>pip show pyqlib
Name: pyqlib
Version: 0.7.2.99
Summary: A Quantitative-research Platform
Home-page: https://github.com/microsoft/qlib
Author:
Author-email:
License: MIT Licence
Location: c:\miniconda3\lib\site-packages
Requires: cvxpy, dill, filelock, fire, hyperopt, joblib, lightgbm, loguru, matplotlib, mlflow, numpy, pandas, plotly, pymongo, python-redis-lock, python-socketio, pyyaml, redis, requests, ruamel.yaml, sacred, schedule, scikit-learn, scipy, statsmodels, tables, tornado, tqdm, xlrd
Required-by:

 D:\>python
Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:15:42) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import qlib
>>> qlib.__version__
'0.7.2.99'
>>>

获取数据

安装qlib后,并没有scripts文件夹,访问 https://github.com/microsoft/qlib 获取需要的文件。

参考:https://qlib.readthedocs.io/en/latest/component/data.html#data-preparation 准备数据

下载中国市场数据:

# daily data
python get_data.py qlib_data --target_dir ~/.qlib/qlib_data/cn_data --region cn

使用数据:

import qlib
from qlib.config import REG_CN
provider_uri = "~/.qlib/qlib_data/cn_data"  # target_dir
qlib.init(provider_uri=provider_uri, region=REG_CN)
© Licensed under CC BY-NC-SA 4.0

我从事投资时, 会观察一家公司的全貌; 而大多数投资人只盯着它的股价。——巴菲特

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!