From 31bf3a7124325287172f5953abc5961004674adc Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 26 Jul 2019 10:41:44 +0800 Subject: [PATCH 1/5] [Fix] convert position related str to float/int --- vnpy/gateway/okexf/okexf_gateway.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vnpy/gateway/okexf/okexf_gateway.py b/vnpy/gateway/okexf/okexf_gateway.py index 7a3eca7d..28138c41 100644 --- a/vnpy/gateway/okexf/okexf_gateway.py +++ b/vnpy/gateway/okexf/okexf_gateway.py @@ -387,28 +387,28 @@ class OkexfRestApi(RestClient): return for pos_data in data["holding"][0]: - if float(pos_data["long_qty"]) > 0: + if int(pos_data["long_qty"]) > 0: pos = PositionData( symbol=pos_data["instrument_id"].upper(), exchange=Exchange.OKEX, direction=Direction.LONG, - volume=pos_data["long_qty"], + volume=int(pos_data["long_qty"]), frozen=float(pos_data["long_qty"]) - float(pos_data["long_avail_qty"]), - price=pos_data["long_avg_cost"], - pnl=pos_data["realised_pnl"], + price=float(pos_data["long_avg_cost"]), + pnl=float(pos_data["realised_pnl"]), gateway_name=self.gateway_name, ) self.gateway.on_position(pos) - if float(pos_data["short_qty"]) > 0: + if int(pos_data["short_qty"]) > 0: pos = PositionData( symbol=pos_data["instrument_id"], exchange=Exchange.OKEX, direction=Direction.SHORT, - volume=pos_data["short_qty"], + volume=int(pos_data["short_qty"]), frozen=float(pos_data["short_qty"]) - float(pos_data["short_avail_qty"]), - price=pos_data["short_avg_cost"], - pnl=pos_data["realised_pnl"], + price=float(["short_avg_cost"]), + pnl=float(["realised_pnl"]), gateway_name=self.gateway_name, ) self.gateway.on_position(pos) From b755f9f1fa240c37857f66cca3151dcb722ca2a6 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 27 Jul 2019 08:47:12 +0800 Subject: [PATCH 2/5] [Mod] close #1969 --- vnpy/app/cta_strategy/engine.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vnpy/app/cta_strategy/engine.py b/vnpy/app/cta_strategy/engine.py index bcaf2e6a..abf1c565 100644 --- a/vnpy/app/cta_strategy/engine.py +++ b/vnpy/app/cta_strategy/engine.py @@ -323,6 +323,11 @@ class CtaEngine(BaseEngine): for req in req_list: vt_orderid = self.main_engine.send_order( req, contract.gateway_name) + + # Check if sending order successful + if not vt_orderid: + continue + vt_orderids.append(vt_orderid) self.offset_converter.update_order_request(req, vt_orderid) From 640150cdcb4cc80329fa5d4b5c10629b0c9a5cd6 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 29 Jul 2019 15:16:25 +0800 Subject: [PATCH 3/5] [Mod] use primaryExchange when exchange data not available --- vnpy/gateway/ib/ib_gateway.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vnpy/gateway/ib/ib_gateway.py b/vnpy/gateway/ib/ib_gateway.py index 930334a5..4b8996cf 100644 --- a/vnpy/gateway/ib/ib_gateway.py +++ b/vnpy/gateway/ib/ib_gateway.py @@ -434,7 +434,16 @@ class IbApi(EWrapper): accountName, ) - if not contract.exchange: + if contract.exchange: + exchange = EXCHANGE_IB2VT.get(contract.exchange, None) + elif contract.primaryExchange: + exchange = EXCHANGE_IB2VT.get(contract.primaryExchange, None) + else: + exchange = Exchange.SMART # Use smart routing for default + + if not exchange: + msg = f"存在不支持的交易所持仓{contract.conId} {contract.exchange} {contract.primaryExchange}" + self.gateway.write_log(msg) return ib_size = contract.multiplier @@ -444,7 +453,7 @@ class IbApi(EWrapper): pos = PositionData( symbol=contract.conId, - exchange=EXCHANGE_IB2VT.get(contract.exchange, contract.exchange), + exchange=exchange, direction=Direction.NET, volume=position, price=price, From 3f51e66fc3b05fed3bb3e06038ed94d97aca4321 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 29 Jul 2019 20:18:31 +0800 Subject: [PATCH 4/5] [Mod] update rpc_service.md --- docs/rpc_service.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/rpc_service.md b/docs/rpc_service.md index f309bffa..7365ebc6 100644 --- a/docs/rpc_service.md +++ b/docs/rpc_service.md @@ -1 +1,33 @@ -# RPC服务 \ No newline at end of file +# RPC服务 + +由于全局锁GIL的存在,单进程的Python程序只能利用CPU单核的算力,为了突破这一限制,解决方案就是多进程分布式的程序架构。但每个进程之间的数据,在操作系统内默认是独立隔离的,无法直接访问。RPC全称Remote-Procedure-Call,中文“远程过程调用”,是最常用的跨进程通讯方式之一。 + + + + +## RPC服务器 + +### 加载模块 + +### 启动运行 + + +## RPC客户端 + +### 加载接口 + +### 连接使用 + + +## 参考样例 + +位于examples/server_client目录下 + +### 服务器进程 + +GUI模式 + +无界面模式 + +### 客户端进程 + From ad060154aba9ca9d3dedbba6a9aade55aab0099e Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 30 Jul 2019 10:23:10 +0800 Subject: [PATCH 5/5] [Mod] update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f46f0d19..4ed0dc18 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,13 @@ vn.py是一套基于Python的开源量化交易系统开发框架,于2015年1月正式发布,在开源社区5年持续不断的贡献下一步步成长为全功能量化交易平台,目前国内外金融机构用户已经超过300家,包括:私募基金、证券自营和资管、期货资管和子公司、高校研究机构、自营交易公司、交易所、Token Fund等。 -使用过程中有任何疑问,请查看[**vn.py项目文档**](https://www.vnpy.com/docs/cn/index.html),如果无法解决请前往[**官方社区论坛**](https://www.vnpy.com/forum/)的【提问求助】板块寻求帮助,也欢迎在【经验分享】板块分享你的使用心得! +**傻瓜式入门教程**已经在官方微信公众号[**vnpy-community**]全新上线,新手使用过程中有任何疑问看这个解决是最快的,后续会不断增加进阶经验、发布公告、活动报名等功能,请扫描下方二维码关注: -官方微信公众号:**vnpy-community**,接下来将在公众号中陆续上线各种关于vn.py的使用教程,欢迎关注。 +

+ +

+ +在使用vn.py进行二次开发(策略、模块等)的过程中有任何疑问,请查看[**vn.py项目文档**](https://www.vnpy.com/docs/cn/index.html),如果无法解决请前往[**官方社区论坛**](https://www.vnpy.com/forum/)的【提问求助】板块寻求帮助,也欢迎在【经验分享】板块分享你的使用心得! 2.0版本基于Python 3.7全新重构开发,如需Python 2上的版本请点击:[长期支持版本v1.9.2 LTS](https://github.com/vnpy/vnpy/tree/v1.9.2-LTS)。