From ad38cd22153f1a3d3c98df5bc4f6734672af0fa0 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 30 Sep 2019 11:46:35 +0800 Subject: [PATCH] [Fix] add ssl support for ctp_gateway/ctptest_gateway, close #1997 --- vnpy/gateway/ctp/ctp_gateway.py | 11 +++++++++-- vnpy/gateway/ctptest/ctptest_gateway.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/vnpy/gateway/ctp/ctp_gateway.py b/vnpy/gateway/ctp/ctp_gateway.py index ab7919bf..32959767 100644 --- a/vnpy/gateway/ctp/ctp_gateway.py +++ b/vnpy/gateway/ctp/ctp_gateway.py @@ -155,9 +155,16 @@ class CtpGateway(BaseGateway): auth_code = setting["授权编码"] product_info = setting["产品信息"] - if not td_address.startswith("tcp://"): + if ( + (not td_address.startswith("tcp://")) and + (not td_address.startswith("ssl://")) + ): td_address = "tcp://" + td_address - if not md_address.startswith("tcp://"): + + if ( + (not md_address.startswith("tcp://")) and + (not md_address.startswith("ssl://")) + ): md_address = "tcp://" + md_address self.td_api.connect(td_address, userid, password, brokerid, auth_code, appid, product_info) diff --git a/vnpy/gateway/ctptest/ctptest_gateway.py b/vnpy/gateway/ctptest/ctptest_gateway.py index e22ef0a6..1d109eae 100644 --- a/vnpy/gateway/ctptest/ctptest_gateway.py +++ b/vnpy/gateway/ctptest/ctptest_gateway.py @@ -155,9 +155,16 @@ class CtptestGateway(BaseGateway): auth_code = setting["授权编码"] product_info = setting["产品信息"] - if not td_address.startswith("tcp://"): + if ( + (not td_address.startswith("tcp://")) and + (not td_address.startswith("ssl://")) + ): td_address = "tcp://" + td_address - if not md_address.startswith("tcp://"): + + if ( + (not md_address.startswith("tcp://")) and + (not md_address.startswith("ssl://")) + ): md_address = "tcp://" + md_address self.td_api.connect(td_address, userid, password, brokerid, auth_code, appid, product_info)