From a833576ebb26ec3ec539bb220588c93779a13aaa Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 10 Jun 2019 14:15:08 +0800 Subject: [PATCH] [Mod] update gateway document for using ConId as contract symbol at IB Gateway --- docs/gateway.md | 37 +++++++++++++++++++---------------- tests/trader/run.py | 8 ++++---- vnpy/gateway/ib/ib_gateway.py | 3 +++ 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/gateway.md b/docs/gateway.md index 714ca42b..1f183ab5 100644 --- a/docs/gateway.md +++ b/docs/gateway.md @@ -71,23 +71,23 @@ def main(): ## 接口分类 -| 接口 |类型 | -| ------ | :------: | -| CTP | 期货 | -| FEMAS | 期货 | -| OES | 国内股票 | -| XTP | 国内股票、指数、基金、债券、期权、融资融券 | -| IB | 外盘股票、期货、期权 | -| TAP | 外盘股票、期货、期权 | -| FUTU | 国内股票、港股、美股 | -| TIGER | 国内股票、港股、美股 | -| BITFINEX | 数字货币 | -| BITMEX | 数字货币 | -| OKEX | 数字货币 | -| OKEXF | 数字货币 | -| HUOBI | 数字货币 | -| HBDM | 数字货币 | -| ONETOKEN | 数字货币 | +| 接口 | 类型 | +| -------- | :----------------------------------------: | +| CTP | 期货 | +| FEMAS | 期货 | +| OES | 国内股票 | +| XTP | 国内股票、指数、基金、债券、期权、融资融券 | +| IB | 外盘股票、期货、期权 | +| TAP | 外盘股票、期货、期权 | +| FUTU | 国内股票、港股、美股 | +| TIGER | 国内股票、港股、美股 | +| BITFINEX | 数字货币 | +| BITMEX | 数字货币 | +| OKEX | 数字货币 | +| OKEXF | 数字货币 | +| HUOBI | 数字货币 | +| HBDM | 数字货币 | +| ONETOKEN | 数字货币 | @@ -270,8 +270,11 @@ main_engine.add_gateway(IbGateway)   #### 其他特点 + 可交易品种几乎覆盖全球的股票、期权、期权;手续费相对较低。 +注意IB接口的合约代码较为特殊,请前往官网的产品查询板块查询,VN Trader中使用的是盈透证券对于每个合约在某一交易所的唯一标识符ConId来作为合约代码,而非Symbol或者LocalName。 +   diff --git a/tests/trader/run.py b/tests/trader/run.py index 099d7a55..26b48183 100644 --- a/tests/trader/run.py +++ b/tests/trader/run.py @@ -5,7 +5,7 @@ from vnpy.trader.ui import MainWindow, create_qapp # from vnpy.gateway.bitmex import BitmexGateway # from vnpy.gateway.futu import FutuGateway -# from vnpy.gateway.ib import IbGateway +from vnpy.gateway.ib import IbGateway # from vnpy.gateway.ctp import CtpGateway # # from vnpy.gateway.ctptest import CtptestGateway # from vnpy.gateway.femas import FemasGateway @@ -18,7 +18,7 @@ from vnpy.trader.ui import MainWindow, create_qapp # from vnpy.gateway.okexf import OkexfGateway # from vnpy.gateway.xtp import XtpGateway # from vnpy.gateway.hbdm import HbdmGateway -from vnpy.gateway.tap import TapGateway +# from vnpy.gateway.tap import TapGateway # from vnpy.app.cta_strategy import CtaStrategyApp # from vnpy.app.csv_loader import CsvLoaderApp @@ -39,7 +39,7 @@ def main(): # main_engine.add_gateway(CtpGateway) # # main_engine.add_gateway(CtptestGateway) # main_engine.add_gateway(FemasGateway) - # main_engine.add_gateway(IbGateway) + main_engine.add_gateway(IbGateway) # main_engine.add_gateway(FutuGateway) # main_engine.add_gateway(BitmexGateway) # main_engine.add_gateway(TigerGateway) @@ -50,7 +50,7 @@ def main(): # main_engine.add_gateway(OnetokenGateway) # main_engine.add_gateway(OkexfGateway) # main_engine.add_gateway(HbdmGateway) - main_engine.add_gateway(TapGateway) + # main_engine.add_gateway(TapGateway) # main_engine.add_app(CtaStrategyApp) # main_engine.add_app(CtaBacktesterApp) diff --git a/vnpy/gateway/ib/ib_gateway.py b/vnpy/gateway/ib/ib_gateway.py index 0a7d0fb8..19a84774 100644 --- a/vnpy/gateway/ib/ib_gateway.py +++ b/vnpy/gateway/ib/ib_gateway.py @@ -416,6 +416,9 @@ class IbApi(EWrapper): accountName, ) + if not contract.exchange: + return + ib_size = contract.multiplier if not ib_size: ib_size = 1