Skip to content

Commit

Permalink
Merge branch 'docs' of https://github.com/noranhe/vnpy into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
noranhe committed Mar 14, 2024
2 parents e02a062 + 0ccea13 commit 1f20342
Show file tree
Hide file tree
Showing 82 changed files with 6,225 additions and 743 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Python
*.pyc
*.pyo
*.pyd
*.egg-info/

# Jupyter
Expand Down Expand Up @@ -34,4 +35,5 @@ _static
_templates

# Misc
.DS_Store
.DS_Store
*.mo
71 changes: 70 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
# 3.9.0版本

## 新增

1. 迅投研数据服务vnpy_xt,支持股票、期货、期权、债券、基金历史数据获取
2. vnpy_ib增加对CBOE和CBOT交易所的支持、对指数期权的支持
3. vnpy_rqdata增加对于88A2连续次主力合约的支持
4. vnpy_wind增加广期所和上期能源交易所的数据支持

## 调整

1. vnpy_sopt升级3.7.0版本API
2. vnpy_portfoliostrategy回测引擎支持交易日参数annual_days
3. K线合成器(BarGenerator)移除对于Tick时间戳的检查过滤逻辑,交由用户层负责控制过滤
4. vnpy_ib收到期权合约数据后,自动查询其切片行情数据
5. vnpy_paperaccount实现对于IB接口合约的特殊路由处理
6. 接口封装升级更新pybind11到2.11.1版本:vnpy_ctp、vnpy_sopt、vnpy_tora
7. vnpy_ctp过滤不支持的委托状态推送
8. vnpy_mysql兼容无数据库写入权限情况下的数据表初始化
9. vnpy_chartwizard支持关闭单个图表标签页
10. vnpy_portfoliostrategy移除策略后同时清除对应的策略状态缓存数据
11. vnpy_portfoliostrategy调整每日盈亏清算对象开盘持仓数据的初始化方式
12. 策略模块遗传优化函数增加ngen_size和max_workers参数


## 修复

1. 修复vnpy_tora接口中的委托部分撤单状态映射缺失
2. 修复vnpy_wind查询日线历史数据时数值存在NaN的问题
3. 修复vnpy_mongodb的Tick汇总数据的条数统计错误
4. 修复vnpy_chartwizard对于升级后的vnpy_spreadtrading价差行情显示问题
5. 修复vnpy_ctastrategy回测成交记录为空时的报错
6. 修复vnpy_ctastrategy策略初始化时,历史数据重复推送调用on_bar的问题


# 3.8.0版本

## 新增

1. K线合成器(BarGenerator)增加对日K线的合成支持
2. 基于华鑫奇点柜台的C++ API重构vnpy_tora,实现VeighNa Station加载支持
3. 新增vnpy_ib对于期权合约查询、波动率和希腊值等扩展行情数据的支持

## 调整

1. vnpy_rest/vnpy_websocket限制在Windows上改为必须使用Selector事件循环
2. vnpy_rest/vnpy_websocket客户端关闭时确保所有会话结束,并等待有异步任务完成后安全退出
3. vnpy_ctp升级6.6.9版本API
4. vnpy_ctp支持大商所的1毫秒级别行情时间戳
5. vnpy_tqsdk过滤不支持的K线频率查询并输出日志
6. vnpy_datamanager增加数据频率下按交易所显示支持,优化数据加载显示速度
7. vnpy_ctabacktester如果加载的历史数据为空,则不执行后续回测
8. vnpy_spreadtrading采用轻量级数据结构,优化图形界面更新机制
9. vnpy_spreadtrading价差子引擎之间的事件推送,不再经过事件引擎,降低延迟水平
10. vnpy_rpcservice增加对下单返回委托号的gateway_name替换处理
11. vnpy_portfoliostrategy策略模板增加引擎类型查询函数get_engine_type
12. vnpy_sec更新行情API至1.6.45.0版本,更新交易API版本至1.6.88.18版本
13. vnpy_ib更新10.19.1版本的API,恢复对于数字格式代码(ConId)的支持
14. 没有配置数据服务或者加载模块失败的情况下,使用BaseDatafeed作为数据服务
15. 遗传优化算法运行时,子进程指定使用spawn方式启动,避免数据库连接对象异常
16. 合约管理控件,增加对于期权合约的特有数据字段显示

## 修复

1. 修复vnpy_datarecorder对于新版本vnpy_spreadtrading价差数据的录制支持
2. 修复vnpy_algotrading条件委托算法StopAlgo全部成交后状态更新可能缺失的问题
3. 修复vnpy_ctastrategy策略初始化时,历史数据重复推送调用on_bar的问题
4. 修复vnpy_wind查询日线历史数据时,数值存在NaN的问题


# 3.7.0版本

## 新增
Expand All @@ -19,7 +89,6 @@
9. vnpy_portfoliostrategy策略模板增加合约乘数查询函数get_size
10. vnpy_portfoliostrategy回测加载日线和小时线数据时,不使用分段加载


## 修复

1. 修复vnpy_rpcservice中,RPC接口对于推送数据的vt前缀相关字段错误问题
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include vnpy *.ico *.ini *.dll *.so *.pyd *.h *.hpp *.cpp *.a *.dat *.pfx
recursive-include vnpy *.ico *.po *.mo
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
💬 Want to read this in **english** ? Go [**here**](README_ENG.md)

<p align="center">
<img src ="https://img.shields.io/badge/version-3.7.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/version-3.9.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/badge/python-3.8|3.9|3.10|3.11.|3.12-blue.svg" />
<img src ="https://img.shields.io/github/actions/workflow/status/vnpy/vnpy/pythonapp.yml?branch=master"/>
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>
Expand Down Expand Up @@ -76,8 +76,6 @@ VeighNa是一套基于Python的开源量化交易系统开发框架,在开源

* TTS([tts](https://www.github.com/vnpy/vnpy_tts)):国内期货(仿真)

* 火象([hx](https://www.github.com/vnpy/vnpy_hx)):国内期货(仿真)

* 海外市场

* Interactive Brokers([ib](https://www.github.com/vnpy/vnpy_ib)):海外证券、期货、期权、贵金属等
Expand Down Expand Up @@ -162,6 +160,8 @@ VeighNa是一套基于Python的开源量化交易系统开发框架,在开源

7. 对接下述各类数据服务的适配器接口(datafeed):

* 迅投研([xt](https://www.github.com/vnpy/vnpy_xt)):股票、期货、期权、基金、债券

* 米筐RQData([rqdata](https://www.github.com/vnpy/vnpy_rqdata)):股票、期货、期权、基金、债券、黄金TD

* 恒生UData([udata](https://www.github.com/vnpy/vnpy_udata)):股票、期货、期权
Expand All @@ -188,7 +188,7 @@ VeighNa是一套基于Python的开源量化交易系统开发框架,在开源

## 环境准备

* 推荐使用VeighNa团队为量化交易专门打造的Python发行版[VeighNa Studio-3.7.0](https://download.vnpy.com/veighna_studio-3.7.0.exe),集成内置了VeighNa框架以及VeighNa Station量化管理平台,无需手动安装
* 推荐使用VeighNa团队为量化交易专门打造的Python发行版[VeighNa Studio-3.9.0](https://download.vnpy.com/veighna_studio-3.9.0.exe),集成内置了VeighNa框架以及VeighNa Station量化管理平台,无需手动安装
* 支持的系统版本:Windows 10以上 / Windows Server 2016以上 / Ubuntu 20.04 LTS以上
* 支持的Python版本:Python 3.7/ 3.8 / 3.9 / 3.10 64位(**推荐使用Python 3.10**

Expand Down
4 changes: 2 additions & 2 deletions README_ENG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</p>

<p align="center">
<img src ="https://img.shields.io/badge/version-3.7.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/version-3.9.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.10-blue.svg" />
<img src ="https://img.shields.io/github/workflow/status/vnpy/vnpy/Python%20application/master"/>
<img src ="https://img.shields.io/github/actions/workflow/status/vnpy/vnpy/pythonapp.yml?branch=master"/>
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AlgoTrading是用于**算法委托执行交易**的模块,用户可以通过

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_algotrading import AlgoTradingApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ChartWizard是用于**实时K线图表展示**的功能模块,用户可以通

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_chartwizard import ChartWizardApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CtaBacktester是用于**CTA回测研究**的功能模块,用户可以通过其

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_ctabacktester import CtaBacktesterApp

Expand Down
30 changes: 15 additions & 15 deletions docs/cta_strategy.md → docs/community/app/cta_strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CtaStrategy是用于**CTA自动交易**的功能模块,用户可以通过其UI

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_ctastrategy import CtaStrategyApp

Expand Down Expand Up @@ -382,7 +382,7 @@ CTA策略模板提供了信号生成和委托管理功能,用户可以基于

在基于CTA策略模板编写策略逻辑之前,需要在策略文件的顶部载入需要用到的内部组件,如下方代码所示:

```python 3
```python3
from vnpy_ctastrategy import (
CtaTemplate,
StopOrder,
Expand All @@ -401,7 +401,7 @@ from vnpy_ctastrategy import (

在策略类的下方,可以设置策略的作者(author),参数(parameters)以及变量(variables),如下方代码所示:

```python 3
```python3

author = "用Python的交易员"

Expand Down Expand Up @@ -459,7 +459,7 @@ __init__函数是策略类的构造函数,需要与继承的CtaTemplate保持

在这个继承的策略类里,初始化一般分三步,如下方代码所示:

```python 3
```python3
def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
""""""
super().__init__(cta_engine, strategy_name, vt_symbol, setting)
Expand All @@ -474,7 +474,7 @@ __init__函数是策略类的构造函数,需要与继承的CtaTemplate保持

如果只基于on_bar进行交易,这里代码可以写成:

```python 3
```python3
self.bg = BarGenerator(self.on_bar)
```

Expand All @@ -486,13 +486,13 @@ BarGenerator默认的基于on_bar函数合成长周期K线的数据频率是分

文件顶部导入Interval:

```python 3
```python3
from vnpy.trader.constant import Interval
```

__init__函数创建bg实例时传入数据频率:

```python 3
```python3
self.bg = BarGenerator(self.on_bar, 2, self.on_2hour_bar, Interval.HOUR)
```

Expand All @@ -519,7 +519,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

初始化策略时on_init函数会被调用,默认写法是先调用write_log函数输出“策略初始化”日志,再调用load_bar函数加载历史数据,如下方代码所示:

```python 3
```python3
def on_init(self):
"""
Callback when strategy is inited.
Expand All @@ -540,7 +540,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

启动策略时on_start函数会被调用,默认写法是调用write_log函数输出“策略启动”日志,如下方代码所示:

```python 3
```python3
def on_start(self):
"""
Callback when strategy is started.
Expand All @@ -558,7 +558,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

停止策略时on_stop函数会被调用,默认写法是调用write_log函数输出“策略停止”日志,如下方代码所示:

```python 3
```python3
def on_stop(self):
"""
Callback when strategy is stopped.
Expand All @@ -580,7 +580,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

当策略收到最新的Tick数据的行情推送时,on_tick函数会被调用。默认写法是通过BarGenerator的update_tick函数把收到的Tick数据推进前面创建的bg实例中以便合成1分钟的K线,如下方代码所示:

```python 3
```python3
def on_tick(self, tick: TickData):
"""
Callback of new tick data update.
Expand All @@ -600,7 +600,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

2 . 如果策略需要基于on_bar推进来的K线数据通过BarGenerator合成更长时间周期的K线来交易,那么请在on_bar中调用BarGenerator的update_bar函数,把收到的这个bar推进前面创建的bg实例中即可,如下方代码所示:

```python 3
```python3
def on_bar(self, bar: BarData):
"""
Callback of new bar data update.
Expand All @@ -610,7 +610,7 @@ CtaTemplate中以on开头的函数称为回调函数,在编写策略的过程

示例策略类BollChannelStrategy是通过15分钟K线数据回报来生成CTA信号的。一共有三部分,如下方代码所示:

```python 3
```python3
def on_15min_bar(self, bar: BarData):
""""""
self.cancel_all()
Expand Down Expand Up @@ -712,7 +712,7 @@ buy/sell/short/cover都是策略内部的负责发单的交易请求类函数。

请注意,如果向上期所发出平仓委托,因为该交易所必须指定平今、平昨,底层会对其平仓指令自动进行转换。因为上期所部分品种有平今优惠,所以默认是以平今优先的方式发出委托的(如果交易的标的在上期所平昨更优惠的话,可以自行在vnpy.trader.converter的convert_order_request_shfe函数中做适当的修改)。

```python 3
```python3
def buy(self, price: float, volume: float, stop: bool = False, lock: bool = False, net: bool = False):
"""
Send buy order to open a long position.
Expand Down Expand Up @@ -790,7 +790,7 @@ cancel_order和cancel_all都是负责撤单的交易请求类函数。cancel_ord

如下方代码所示,调用load_bar函数时,默认加载的天数是10,频率是一分钟,对应也就是加载10天的1分钟K线数据。在回测时,10天指的是10个交易日,而在实盘时,10天则是指的是自然日,因此建议加载的天数宁可多一些也不要太少。use_database参数默认为False,会先依次尝试通过交易接口、数据服务、数据库获取历史数据,直到获取历史数据或返回空。当use_database设置为True后,会跳过通过交易接口和数据服务获取历史数据,直接去数据库查询。

```python 3
```python3
def load_bar(
self,
days: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DataManager是用于**历史数据管理**的功能模块,用户可以通过

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_datamanager import DataManagerApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DataRecorder是用于**实盘行情记录**的模块,用户可以利用该模

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_datarecorder import DataRecorderApp

Expand Down
2 changes: 1 addition & 1 deletion docs/excel_rtd.md → docs/community/app/excel_rtd.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pyxll install

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_excelrtd import ExcelRtdApp

Expand Down
23 changes: 23 additions & 0 deletions docs/community/app/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
策略应用
~~~~~~~~~

.. toctree::
:maxdepth: 2
:caption: Elite版

cta_strategy.md
cta_backtester.md
spread_trading.md
option_master.md
portfolio_strategy.md
algo_trading.md
script_trader.md
paper_account.md
data_recorder.md
data_manager.md
risk_manager.md
rpc_service.md
chart_wizard.md
portfolio_manager.md
excel_rtd.md
web_trader.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ OptionMaster是用于**期权波动率交易**的功能模块,用户可以通

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_optionmaster import OptionMasterApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PaperAccount是用于**本地仿真交易**的功能模块,用户可以通过

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_paperaccount import PaperAccountApp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PortfolioManager是用于**投资组合管理**的功能模块,用户可以在

在启动脚本中添加如下代码:

```python 3
```python3
# 写在顶部
from vnpy_portfoliomanager import PortfolioManagerApp

Expand Down
Loading

0 comments on commit 1f20342

Please sign in to comment.