Skip to main content


Project description

quant vnpy

一、 简介

1. 功能简介


  1. quant_vnpy 目录包含各种增强函数及类库
  2. strategies 为策略库

2. 版本历史

2021-01-22 v0.6.0

feat: add track performance feature.

2021-01-19 v0.5.12

fix: TargetPosAndPriceTemplate current_pos -> target_pos by one step fix: strategy_class_name wrong

2021-01-15 v0.5.5

fix: add exception handle and logger on TradeDataCollector fix: TargetPosAndPriceTemplate current_pos -> target_pos by one step

2021-01-14 v0.5.1

feat: record backtest stats
feat: add default rate for backtest
fix: DCE夜盘交易日期为下一交易日,将会被重写为当前系统日期 fix: 修复跨日报表统计错误
fix: cross_limit_method param missing for file_name_func function
fix: 主力合约、次主力合约数据复权整理 bug

2021-01-08 v0.5.0

refactor: merge portfolio run_backtest and cta run_backtest

2021-01-07 v0.4.13

feat: set_strategy_status(StrategyStatusEnum.Stopped)
feat: monitor add setting

2021-01-05 v0.4.11

refactor: longer interval of
feat: backtest: output param file if it's available

2021-01-04 v0.4.10

fix: MACDSignal

2021-01-04 v0.4.9

fix: check not strategy_status_monitor.is_alive()

2020-12-27 v0.4.8

feat: backtest: reset_index on result_df
fix: portfolio template, last_order_dt -> dict
feat: add new TargetPosAndPriceTemplate, MACrossSignal

2020-12-27 v0.4.7

feat: backtest: default rate
feat: backtest: available filter for return_drawdown_ratio < 2 and np.round for some stats items

2020-12-25 v0.4.6

feat: backtest: auto search symbol size
fix: report gl calc wrong in some cases

2020-12-23 v0.4.4

fix: report holding pos status calc wrong
fix: stop_opening_pos on templates

2020-12-22 v0.4.2

fix: order_data_collector error on portfolio_strategy.template

2020-12-21 v0.4.1

fix: open_price -> last_price

2020-12-18 v0.4.0

feat: support user_name, broker_id
feat: add last_order_dt on template

2020-12-18 v0.3.9

fix: orm close connection
feat: position daily stat.

2020-12-16 v0.3.7

feat: add CrossLimitMethod.fix_price for backtest
feat: add quant_vnpy.backtest.cta_strategy.template.CtaTemplate
feat: backtest cross price method

2020-12-14 v0.3.2

add position monitor

2020-12-11 v0.2.16

feat: on_tick active on_bar by bg on
feat: add OrderDataCollector, TradeDataCollector class
feat: add stop_if_pos_2_0 on cta template
fix: bug fix of on_tick and report error

2020-12-04 v0.2.8

feat: more readable log

2020-11-30 v0.2.7

feat: orm add symbols

2020-11-27 v0.2.3

fix: bug fix on log format

2020-11-25 v0.2.2

fix: bug fix on on_stop of portfolio template

2020-11-25 v0.2.1

feat: add strategy status monitor

2020-11-24 v0.1.10

feat: add bar_count

2020-11-20 v0.1.8

bug fix on portfolio's template

2020-11-17 v0.1.7

feat: 对 cta 及 portfolio 增加 template 模板类
feat: signal 增加 0 判断 当 0 时,默认为 default 值
feat: add current_bar for cta, portfolio's template classes
fix: template bugs

2020-11-15 v0.1.2

feat: 最新依赖版本 IBATS_Common>=0.20.8,最新支持道 vnpy 2.1.7 版本

2020-11-10 v0.1.0

feat: 基于vnpy 2.1.6进行的功能增强。此前版本不支持。

二、 环境设置及组件安装(首次运行前需要)

1. 系统环境包含 Anaconda 或 Miniconda(python 3.7 版本)

2. 安装 vnpy 2.1.6或以上版本 \

3. 运行安装相关组件

pip isntall -r requirement.txt
conda install -c plotly plotly-orca
conda install -c plotly python-kaleido


  1. 通用组件

    pip install -r requirement.txt
  2. orca 组件 orca 组件为回测功能中保存回测视图结果的组件,windows系统性需要单独安装,才可保证功能正常使用

    1. 安装组件包

      conda install -c plotly plotly-orca
    2. 下载并安装 orca 应用


    安装后设置话就环境变了 Path 加入相应路径,默认情况下window10操作系统 orca 组件将被安装在如下路径:


    1. 批量关闭 orca 进程方法
    ps -ef | grep orca | grep -v grep | awk '{print $2}' | xargs kill -9
  3. MD文件转word文档工具
    pandoc官网下载对应的软件并安装后即可运行 Scripts\md_2_docx.bat 脚本

三、 常用命令

1. 切换远程仓库地址方法

>git remote
>git remote get-url --all origin
>git remote set-url origin
>git pull
remote: Enumerating objects: 8, done.
remote: Counting objects:  25% (2/8)
remote: Counting objects: 100% (8/8), done.
remote: Total 72 (delta 8), reused 8 (delta 8), pack-reused 64
Unpacking objects:   
6% (5/72)Unpacking objects:  
34% (25/72)Unpacking objects:  
Unpacking objects: 100% (72/72), 17.93 KiB | 23.00 KiB/s, done.
   cb6c014..1afe166  master     -> origin/master
Updating cb6c014..1afe166
Fast-forward                                          |   7 +
 8 files changed, 404 insertions(+), 106 deletions(-)

2. 数据库 dump 数据


"c:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump.exe" -u mg -p --databases vnpy dbbardata --where="symbol in ('rb9999', 'hc9999', 'i9999') and `interval`='1m'" > dbbardata_dump.sql


"c:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump.exe" -u mg -p vnpy dbbardata --where="(symbol like'%9999' or symbol like'%8888') and `interval`='1m'" > dbbardata_dump.sql

3. 压缩命令

zip -r0q /media/mg/Data/ output

4. 独立启动交易界面

d:\ide\vnstudio\python.exe -m vnstation runtrader "{'gateway': {'CTP': true}, 'app': {'CtaStrategy': true, 'PortfolioStrategy': true, 'PortfolioManager': true}, 'path': 'D:\\TradeTools\\vnpy\\jianxin_11859077'}"

四、 各个版本常见错误


  1. 错误提示框太长,无法看到错误信息

    python.exe -m vnstation
  2. 错误提示:

    ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject 解决方法:

    Scripts\pip.exe install numpy==1.16.1 --user
  3. 穿透式测试通不过,采集不到CPU、硬盘、BIOS信息 修改环境变量 增加目录


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

quant_vnpy-0.6.0-py3-none-any.whl (78.7 kB view hashes)

Uploaded py3

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