Skip to content

Commit

Permalink
Merge branch 'dev' into ga——01
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy authored Apr 27, 2019
2 parents fc3e433 + a08b6be commit fbf59ab
Show file tree
Hide file tree
Showing 399 changed files with 79,323 additions and 747 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ dist
*.local

# vn.py
.vntrader
.vntrader

# Visual Studio intermediate files
*.exp
*.iobj
*.ipdb
*.pdb
105 changes: 44 additions & 61 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ language: python

dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)

cache: pip

git:
depth: 1

python:
- "3.7"

services:
- mongodb
- mysql
- postgresql

before_script:
- psql -d postgresql://postgres:${VNPY_TEST_POSTGRESQL_PASSWORD}@localhost -c "create database vnpy;"
- mysql -u root --password=${VNPY_TEST_MYSQL_PASSWORD} -e 'CREATE DATABASE vnpy;'

script:
# todo: use python unittest
- mkdir run; cd run; python ../tests/load_all.py
- cd tests; source travis_env.sh;
- python test_all.py

matrix:
include:
Expand All @@ -19,81 +33,36 @@ matrix:
script:
- flake8

- name: "pip install under Windows"
os: "windows"
# language : cpp is necessary for windows
language: "cpp"
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
before_install:
- choco install python3 --version 3.7.2
install:
- python -m pip install --upgrade pip wheel setuptools
- pip install https://pip.vnpy.com/colletion/TA_Lib-0.4.17-cp37-cp37m-win_amd64.whl
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- pip install -r requirements.txt
- pip install .

- name: "pip install under Ubuntu: gcc-8"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-8
before_install:
# C++17
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -y
install:
# C++17
- sudo apt-get install -y gcc-8 g++-8
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-8 90
install:
# update pip & setuptools
- python -m pip install --upgrade pip wheel setuptools
# Linux install script
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- bash ./install.sh

- name: "pip install under Ubuntu: gcc-7"
- name: "sdist install under Ubuntu: gcc-7"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
before_install:
# C++17
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -y
install:
# C++17
- sudo apt-get install -y gcc-7 g++-7
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-7 90
- sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-7 90
# update pip & setuptools
- python -m pip install --upgrade pip wheel setuptools
# Linux install script
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- bash ./install.sh

- name: "sdist install under Windows"
os: "windows"
# language : cpp is necessary for windows
language: "cpp"
env:
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
before_install:
- choco install python3 --version 3.7.2
install:
- python -m pip install --upgrade pip wheel setuptools
- python setup.py sdist
- pip install https://pip.vnpy.com/colletion/TA_Lib-0.4.17-cp37-cp37m-win_amd64.whl
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- pip install dist/`ls dist`

- name: "sdist install under Ubuntu: gcc-8"
before_install:
# C++17
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -y
install:
# C++17
- sudo apt-get install -y gcc-8 g++-8
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-8 90
- sudo update-alternatives --install /usr/bin/gcc cc /usr/bin/gcc-8 90
# Linux install script
- python -m pip install --upgrade pip wheel setuptools
- pushd /tmp
Expand All @@ -105,6 +74,20 @@ matrix:
- sudo make install
- popd
- pip install numpy
- pip install --pre --extra-index-url https://rquser:[email protected]/simple/ rqdatac
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- python setup.py sdist
- pip install dist/`ls dist`

- name: "pip install under osx"
os: osx
language: shell # osx supports only shell
services: []
before_install: []
install:
- pip3 install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- bash ./install_osx.sh
before_script: []
script:
- cd tests; source travis_env.sh;
- VNPY_TEST_ONLY_SQLITE=1 python3 test_all.py
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ vn.py是一套基于Python的开源量化交易系统开发框架,于2015年1

* BitMEX (bitmex):数字货币期货、期权、永续合约

* OKEX (okex):数字货币现货

* HUOBI(huobi):数字货币现货

* Bitfinex(bitfinex):数字货币现货

* 1Token(onetoken):数字货币券商(现货、期货)


3. 开箱即用的各类量化策略交易应用(vnpy.app):

* cta_strategy:CTA策略引擎模块,在保持易用性的同时,允许用户针对CTA类策略运行过程中委托的报撤行为进行细粒度控制(降低交易滑点、实现高频策略)

* cta_backtester:CTA策略回测模块,无需使用Jupyter Notebook,直接使用图形界面直接进行策略回测分析、参数优化等相关工作

* algo_trading:算法交易模块,提供多种常用的智能交易算法:TWAP、Sniper、Iceberg、BestLimit等等,支持常用算法配置保存

* csv_loader:CSV历史数据加载器,用于加载CSV格式文件中的历史数据到平台数据库中,用于策略的回测研究以及实盘初始化等功能,支持自定义数据表头格式

4. Python交易API接口封装(vnpy.api),提供上述交易接口的底层对接实现。
Expand Down
64 changes: 64 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
clone_depth: 1

cache:
- '%LOCALAPPDATA%\pip\Cache'

configuration:
- pip
- sdist

image:
- Visual Studio 2017

services:
- mysql
- mongodb
- postgresql

environment:
PATH: C:\Python37-x64;C:\Python37-x64\Scripts;C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
VNPY_TEST_MYSQL_DATABASE: vnpy
VNPY_TEST_MYSQL_HOST: localhost
VNPY_TEST_MYSQL_PORT: 3306
VNPY_TEST_MYSQL_USER: root
VNPY_TEST_MYSQL_PASSWORD: Password12!

VNPY_TEST_POSTGRESQL_DATABASE: vnpy
VNPY_TEST_POSTGRESQL_HOST: localhost
VNPY_TEST_POSTGRESQL_PORT: 5432
VNPY_TEST_POSTGRESQL_USER: postgres
VNPY_TEST_POSTGRESQL_PASSWORD: Password12!

VNPY_TEST_MONGODB_DATABASE: vnpy
VNPY_TEST_MONGODB_HOST: localhost
VNPY_TEST_MONGODB_PORT: 27017

MYSQL_PWD: Password12!

install:
- python -m pip install --upgrade pip wheel setuptools
before_build:
- ps: psql -d "postgresql://${ENV:VNPY_TEST_POSTGRESQL_USER}:${ENV:VNPY_TEST_POSTGRESQL_PASSWORD}@localhost" -c "create database vnpy;"
- ps: . "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql" -u $ENV:VNPY_TEST_MYSQL_USER -e 'CREATE DATABASE vnpy;'

for:
- matrix:
only:
- configuration: pip
build_script:
- call install.bat

- matrix:
only:
- configuration: sdist
build_script:
- python setup.py sdist
- pip install --pre --extra-index-url https://rquser:[email protected]/simple/ rqdatac
- pip install https://pip.vnpy.com/colletion/TA_Lib-0.4.17-cp37-cp37m-win_amd64.whl
- pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl
- ps: $name=(ls dist).name; pip install "dist/$name"

test_script:
- cd tests
- python test_all.py

72 changes: 68 additions & 4 deletions docs/contribution.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,74 @@
# 代码贡献说明
# 贡献代码

## Linter智能提示
---
## 创建PR
我们欢迎任何人贡献代码到vn.py。
如果希望贡献代码请使用github的PR(Pull Request)的流程。

PR流程大致如下:

## 代码检查
---
1. [创建 Issue][CreateIssue] - 对于较大的改动(如新功能,大型重构等)最好先开issue讨论一下, 较小的improvement(如文档改进,bugfix等)直接发PR即可

2. Fork [vn.py][#GithubVnpy] - 点击右上角**Fork**按钮

## 持续集成
3. Clone你自己的fork: ```git clone https://github.com/$userid/vnpy.git```
> 如果你的fork已经过时,需要手动[sync][GithubDocForSync]

4.**dev**创建你自己的branch: ```git checkout -b $my_feature_branch dev```

5. 在$my_feature_branch上修改并将修改push到你Fork之后的仓库上

6. 创建从你的fork的$my_feature_branch分支到主项目的**dev**分支的[Pull Request]:
[点开这里][CreatePR] ,再点击**compare across forks**,选择需要的fork和branch创建PR

---

创建完PR之后请耐心等待:我们一旦有空就会检查PR,一旦你的代码有用且[符合要求](#代码风格),就会被合并!


---
## 代码风格
在为vn.py写代码的时候,需要遵循一些基本的规则,否则你的代码可能无法被merge。
这些规则包括:
1. [命名规则](#命名规则)
2. [代码格式](#代码格式)
3. [代码质量检查](#代码质量检查)


### 命名规则
我们的代码的命名规则如下:

* 类属性、类方法、参数和变量使用小写加下划线的形式
* 类名使用驼峰式命名
* 常量使用大写加下划线的形式

例如:
```python
DEFAULT_PATH = "/tmp/vn.py/"
class ClassA:
def __init__(self, arg_one: int, arg_two: str):
if arg_two is None:
arg_two = DEFAULT_PATH
self.property_one = arg_one
variable_one = "some string"
```


### 代码格式
我们对代码格式没有特别严格的要求,但是至少要符合pep8标准,并且额外要在类和所有函数下面带上docstring(就是一段"""""")。

要让代码符合pep8标准,写完代码之后使用[autopep8](https://github.com/hhatto/autopep8)格式化你的代码就可以了:
```bash
autopep8 --in-place --recursive .
```

### 代码质量检查
使用[flake8](https://pypi.org/project/flake8/)检查你的代码,确保没有error和warning。
在项目根目录下运行```flake8```就可以检查出代码中书写不严谨的地方了。如果检查出error或者warning,说明你的代码需要进行一些修改以提升质量。

[GithubVnpy]:https://github.com/vnpy/vnpy
[GithubDocForSync]:https://help.github.com/articles/syncing-a-fork/
[CreateIssue]:https://github.com/vnpy/vnpy/issues/new
[CreatePR]:https://github.com/vnpy/vnpy/compare?expand=1

1 change: 1 addition & 0 deletions install.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
::Install talib and ibapi
pip install https://pip.vnpy.com/colletion/rqdatac-2.1.0.tar.gz
pip install https://pip.vnpy.com/colletion/TA_Lib-0.4.17-cp37-cp37m-win_amd64.whl
pip install https://pip.vnpy.com/colletion/ibapi-9.75.1-001-py3-none-any.whl

Expand Down
23 changes: 16 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
#!/usr/bin/env bash

python=$1
pip=$2
prefix=$3

[[ -z $python ]] && python=python
[[ -z $pip ]] && pip=pip
[[ -z $prefix ]] && prefix=/usr

# Get and build ta-lib
pushd /tmp
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
tar -xf ta-lib-0.4.0-src.tar.gz
cd ta-lib
./configure --prefix=/usr
make
./configure --prefix=$prefix
make -j
sudo make install
popd

# old versions of ta-lib imports numpy in setup.py
pip install numpy
$pip install numpy

# Install extra packages
pip install ta-lib
pip install https://vnpy-pip.oss-cn-shanghai.aliyuncs.com/colletion/ibapi-9.75.1-py3-none-any.whl
$pip install --pre --extra-index-url https://rquser:[email protected]/simple/ rqdatac
$pip install ta-lib
$pip install https://vnpy-pip.oss-cn-shanghai.aliyuncs.com/colletion/ibapi-9.75.1-py3-none-any.whl

# Install Python Modules
pip install -r requirements.txt
$pip install -r requirements.txt

# Install local Chinese language environment
sudo locale-gen zh_CN.GB18030

# Install vn.py
pip install .
$pip install .
3 changes: 3 additions & 0 deletions install_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

bash ./install.sh python3 pip3 /usr/local
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ qdarkstyle
requests
websocket-client
peewee
pymysql
psycopg2
mongoengine
numpy
pandas
matplotlib
seaborn
futu-api
tigeropen
rqdatac
ta-lib
ibapi
Loading

0 comments on commit fbf59ab

Please sign in to comment.