commit
198796d7be
57
README.md
57
README.md
@ -9,13 +9,19 @@ vn.py是一套基于Python的开源量化交易程序开发框架,起源于国
|
||||
---
|
||||
### 环境准备
|
||||
|
||||
**Windows**
|
||||
|
||||
1. 支持的操作系统:Windows 7/8/10/Server 2008
|
||||
2. 安装[MongoDB](https://www.mongodb.org/downloads#production),并[将MongoDB配置为系统服务](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#configure-a-windows-service-for-mongodb-community-edition)
|
||||
3. 安装[Anaconda](http://www.continuum.io/downloads),**注意必须是Python 2.7 32位版本**
|
||||
4. 安装[Visual C++ Redistributable Packages for VS2013 x86版本](https://support.microsoft.com/en-us/help/3138367/update-for-visual-c-2013-and-visual-c-redistributable-package)
|
||||
|
||||
**Ubuntu**
|
||||
|
||||
请参考项目wiki中的[教程](https://github.com/vnpy/vnpy/wiki/Ubuntu%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85)。
|
||||
|
||||
---
|
||||
### 安装
|
||||
### 项目安装
|
||||
|
||||
**方法1**
|
||||
|
||||
@ -61,6 +67,10 @@ import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
# 判断操作系统
|
||||
import platform
|
||||
system = platform.system()
|
||||
|
||||
# vn.trader模块
|
||||
from vnpy.event import EventEngine
|
||||
from vnpy.trader.vtEngine import MainEngine
|
||||
@ -68,10 +78,15 @@ from vnpy.trader.uiQt import createQApp
|
||||
from vnpy.trader.uiMainWindow import MainWindow
|
||||
|
||||
# 加载底层接口
|
||||
from vnpy.trader.gateway import ctpGateway
|
||||
from vnpy.trader.gateway import (ctpGateway, oandaGateway, ibGateway,
|
||||
huobiGateway, okcoinGateway)
|
||||
|
||||
if system == 'Windows':
|
||||
from vnpy.trader.gateway import (femasGateway, xspeedGateway,
|
||||
sgitGateway, shzdGateway)
|
||||
|
||||
# 加载上层应用
|
||||
from vnpy.trader.app import riskManager, ctaStrategy
|
||||
from vnpy.trader.app import (riskManager, ctaStrategy, spreadTrading)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -88,10 +103,21 @@ def main():
|
||||
|
||||
# 添加交易接口
|
||||
me.addGateway(ctpGateway)
|
||||
me.addGateway(oandaGateway)
|
||||
me.addGateway(ibGateway)
|
||||
me.addGateway(huobiGateway)
|
||||
me.addGateway(okcoinGateway)
|
||||
|
||||
if system == 'Windows':
|
||||
me.addGateway(femasGateway)
|
||||
me.addGateway(xspeedGateway)
|
||||
me.addGateway(sgitGateway)
|
||||
me.addGateway(shzdGateway)
|
||||
|
||||
# 添加上层应用
|
||||
me.addApp(riskManager)
|
||||
me.addApp(ctaStrategy)
|
||||
me.addApp(spreadTrading)
|
||||
|
||||
# 创建主窗口
|
||||
mw = MainWindow(me, ee)
|
||||
@ -105,13 +131,15 @@ if __name__ == '__main__':
|
||||
main()
|
||||
```
|
||||
|
||||
更多使用方法方法请参考examples下的目录。
|
||||
以上run.py脚本位于examples\VnTrader目录下,更多使用方法方法请参考examples下的其他目录。
|
||||
|
||||
---
|
||||
|
||||
### 用户文档
|
||||
[https://github.com/vnpy/vnpy/wiki](https://github.com/vnpy/vnpy/wiki)
|
||||
|
||||
项目的最新文档请查看[Github Wiki](https://github.com/vnpy/vnpy/wiki),知乎专栏和官网文档已经落后于项目开发版本,建议只作为额外的参考资料。
|
||||
|
||||
---
|
||||
|
||||
### 开发工具推荐
|
||||
|
||||
@ -126,7 +154,6 @@ if __name__ == '__main__':
|
||||
* [Visual Studio 2013](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx):这个就不多说了(作者编译API封装用的是2013版本)
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
### 项目结构
|
||||
@ -179,6 +206,12 @@ if __name__ == '__main__':
|
||||
|
||||
* 实盘行情记录,支持Tick和K线数据的落地,用于策略开发回测以及实盘运行初始化
|
||||
|
||||
5. 数据相关的API接口(vnpy.data),用于构建和更新历史行情数据库,目前包括:
|
||||
|
||||
* 上海中期历史行情服务(shcifco)
|
||||
|
||||
* 通联数据API下载服务(datayes)
|
||||
|
||||
5. 关于vn.py项目的应用演示(examples),对于新手而言可以从这里开始学习vn.py项目的使用方式
|
||||
|
||||
5. 关于项目在实盘交易中的一些使用指南(tutorial)
|
||||
@ -197,18 +230,18 @@ vn.py使用github托管其源代码,如果希望贡献代码请使用github的
|
||||
|
||||
1. [创建 Issue](https://github.com/vnpy/vnpy/issues/new) - 对于较大的改动(如新功能,大型重构等)最好先开issue讨论一下,较小的improvement(如文档改进,bugfix等)直接发PR即可
|
||||
|
||||
1. Fork [vn.py](https://github.com/vnpy/vnpy) - 点击右上角**Fork**按钮
|
||||
2. Fork [vn.py](https://github.com/vnpy/vnpy) - 点击右上角**Fork**按钮
|
||||
|
||||
1. Clone你自己的fork: ```git clone https://github.com/$userid/vnpy.git```
|
||||
3. Clone你自己的fork: ```git clone https://github.com/$userid/vnpy.git```
|
||||
* 如果你的fork已经过时,需要手动sync:[https://help.github.com/articles/syncing-a-fork/](https://help.github.com/articles/syncing-a-fork/)
|
||||
|
||||
1. 从**dev**创建你自己的feature branch: ```git checkout -b $my_feature_branch dev```
|
||||
4. 从**dev**创建你自己的feature branch: ```git checkout -b $my_feature_branch dev```
|
||||
|
||||
1. 在$my_feature_branch上修改并将修改push到你的fork上
|
||||
5. 在$my_feature_branch上修改并将修改push到你的fork上
|
||||
|
||||
1. 创建从你的fork的$my_feature_branch分支到主项目的**dev**分支的[Pull Request] - [在此](https://github.com/vnpy/vnpy/compare?expand=1)点击**compare across forks**,选择需要的fork和branch创建PR
|
||||
6. 创建从你的fork的$my_feature_branch分支到主项目的**dev**分支的[Pull Request] - [在此](https://github.com/vnpy/vnpy/compare?expand=1)点击**compare across forks**,选择需要的fork和branch创建PR
|
||||
|
||||
1. 等待review, 需要继续改进,或者被Merge!
|
||||
7. 等待review, 需要继续改进,或者被Merge!
|
||||
|
||||
---
|
||||
### 项目捐赠
|
||||
|
@ -4,7 +4,8 @@
|
||||
本文件中包含了CTA模块中用到的一些基础设置、类和常量等。
|
||||
'''
|
||||
|
||||
from __future__ import division
|
||||
# CTA引擎中涉及的数据类定义
|
||||
from vnpy.trader.vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT
|
||||
|
||||
# 常量定义
|
||||
# CTA引擎中涉及到的交易方向类型
|
||||
@ -37,9 +38,6 @@ ENGINETYPE_TRADING = 'trading' # 实盘
|
||||
EVENT_CTA_LOG = 'eCtaLog' # CTA相关的日志事件
|
||||
EVENT_CTA_STRATEGY = 'eCtaStrategy.' # CTA策略状态变化事件
|
||||
|
||||
# CTA引擎中涉及的数据类定义
|
||||
from vnpy.trader.vtConstant import EMPTY_UNICODE, EMPTY_STRING, EMPTY_FLOAT, EMPTY_INT
|
||||
|
||||
|
||||
########################################################################
|
||||
class StopOrder(object):
|
||||
@ -57,4 +55,4 @@ class StopOrder(object):
|
||||
|
||||
self.strategy = None # 下停止单的策略对象
|
||||
self.stopOrderID = EMPTY_STRING # 停止单的本地编号
|
||||
self.status = EMPTY_STRING # 停止单状态
|
||||
self.status = EMPTY_STRING # 停止单状态
|
Loading…
Reference in New Issue
Block a user