Metadata-Version: 2.1
Name: quant-vnpy
Version: 0.4.10
Summary: 基于VNPY进行功能增强
Home-page: http://192.168.0.103/quant/quant_vnpy
Author: MG
Author-email: mmmaaaggg@163.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Topic :: Software Development
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: IBATS-Common (>=0.20.8)
Requires-Dist: psutil (>=5.7.2)
Requires-Dist: kaleido (>=0.0.3)
Requires-Dist: openpyxl (>=3.0.5)
Requires-Dist: xlwt (>=1.3.0)
Requires-Dist: tqdm (>=4.51.0)
Requires-Dist: peewee (>=3.13.3)
Requires-Dist: mysql-connector-python (>=8.0.22)

# quant vnpy

## 一、 简介
### 1. 功能简介
本工具包是基于vnpy的回测库的一些增强函数

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

### 2. 版本历史

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
> backtest: reset_index on result_df
> fix: portfolio template, last_order_dt -> dict
> feat: add new TargetPosAndPriceTemplate, MACrossSignal

2020-12-27 v0.4.7
> backtest: default rate
> backtest: available filter for return_drawdown_ratio < 2 and np.round for some stats items

2020-12-25 v0.4.6
> 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
> support user_name, broker_id
> 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
> add CrossLimitMethod.fix_price for backtest
> add quant_vnpy.backtest.cta_strategy.template.CtaTemplate
> backtest cross price method

2020-12-14 v0.3.2
> add position monitor

2020-12-11 v0.2.16
> on_tick active on_bar by bg on template.py
> add OrderDataCollector, TradeDataCollector class
> add stop_if_pos_2_0 on cta template
> bug fix of on_tick and report error

2020-12-04 v0.2.8
> more readable log

2020-11-30 v0.2.7
> orm add symbols

2020-11-27 v0.2.3
> bug fix on log format

2020-11-25 v0.2.2
> bug fix on on_stop of portfolio template
>
2020-11-25 v0.2.1
> add strategy status monitor

2020-11-24 v0.1.10
> add bar_count

2020-11-20 v0.1.8
> bug fix on portfolio's template

2020-11-17 v0.1.7
> 对 cta 及 portfolio 增加 template 模板类
> signal 增加  0 判断 当 0 时，默认为 default 值
> add current_bar for cta, portfolio's template classes
> fix template bugs

2020-11-15 v0.1.2
> 最新依赖版本 IBATS_Common>=0.20.8，最新支持道 vnpy 2.1.7 版本
调整 INSTRUMENT_TRADE_TIME_PAIR_DIC 道 constants.py

2020-11-10 v0.1.0
> 基于vnpy 2.1.6进行的功能增强。此前版本不支持。

## 二、 环境设置及组件安装（首次运行前需要）
### 1. 系统环境包含 [Anaconda](https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86_64.exe) 或 Miniconda（python 3.7 版本）
### 2. 安装 [vnpy 2.1.6或以上版本](https://download.vnpy.com/vnstudio-2.1.7.exe) \
### 3. 运行按照相关组件 
```cmd
pip isntall -r requirement.txt
conda install -c plotly plotly-orca
conda install -c plotly python-kaleido
```

如果执行遇到问题可分别执行如下：
1. 通用组件
    ```cmd
    pip install -r requirement.txt
    ```

2. orca 组件
    orca 组件为回测功能中保存回测视图结果的组件，windows系统性需要单独安装，才可保证功能正常使用 \
    安装步骤如下： 
    1. 安装组件包

        ```cmd
        conda install -c plotly plotly-orca
        ```

    2. 下载并安装 orca 应用

    组件下载地址：[orca组件](https://github-production-release-asset-2e65be.s3.amazonaws.com/99037241/8ebe1c00-6f72-11ea-8c70-1021f91c27bc?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201028%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201028T052839Z&X-Amz-Expires=300&X-Amz-Signature=2a9e44c0ac740c2335a130a8c1cb9734994f4bd01a7a55c6c12fe5330a487dbf&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dwindows-release.zip&response-content-type=application%2Foctet-stream)

    安装后设置话就环境变了 Path 加入相应路径，默认情况下window10操作系统 orca 组件将被安装在如下路径：
    > C:\Users\mmmaaaggg\AppData\Local\Programs\orca

    3. 批量关闭 orca 进程方法
    ```shell script
    ps -ef | grep orca | grep -v grep | awk '{print $2}' | xargs kill -9
    ```

 3. MD文件转word文档工具 \
    到[pandoc官网](https://pandoc.org/installing.html)下载对应的软件并安装后即可运行 Scripts\md_2_docx.bat 脚本

 ## 三、 常用命令

 1. 切换远程仓库地址方法
    ```cmd
    >git remote
    origin
    >git remote get-url --all origin
    git@192.168.10.117:quant/quant_vnpy.git
    >git remote set-url origin http://209386rt46.51vip.biz:23987/quant/quant_vnpy.git
    >git pull
    Username for 'http://209386rt46.51vip.biz:23987':
    Username for 'http://209386rt46.51vip.biz:23987': maguo
    Password for 'http://maguo@209386rt46.51vip.biz:23987':
    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:  18% (13/72)Unpacking objects:  23% (17/72)Unpacking objects:  29% (21/72)Unpacking objects:  34% (25/72)Unpacking objects:  38% (28/72)Unpacking objects:  41% (30/72)Unpacking objects:  43% (31/72)Unpacking objects:  44% (32/72)Unpacking objects:  47% (34/72)Unpacking objects:  50% (36/72)Unpacking objects:  56% (41/72)Unpacking objects:  59% (43/72)Unpacking objects:  62% (45/72)Unpacking objects:  70% (51/72)Unpacking objects:  76% (55/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  80% (58/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  84% (61/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  88% (64/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  90% (65/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  94% (68/72), 13.34 KiB | 26.00 KiB/sUnpacking objects:  97% (70/72), 13.34 KiB | 26.00 KiB/sUnpacking objects: 100% (72/72), 17.93 KiB | 23.00 KiB/s, done.
    From http://209386rt46.51vip.biz:23987/quant/From http://209386rt46.51vip.biz:23987/quant/quant_vnpy
       cb6c014..1afe166  master     -> origin/master
    Updating cb6c014..1afe166
    Fast-forward
     README.md                                          |   7 +
     ...
     8 files changed, 404 insertions(+), 106 deletions(-)
    ``` 

 2. 数据库 dump 数据

    备份主力合约

     ```cmd
    "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
    ```

    备份主力，次主力合约

    ```cmd
    "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. 压缩命令

    ```bash
    zip -r0q /media/mg/Data/output_20201220.zip output
    ```

