From 86b1d8f4ee6c572f9f462d48380483aa2bf6d552 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Thu, 6 Jun 2019 09:26:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=9Atdx=E9=87=8D?= =?UTF-8?q?=E8=BF=9E=E6=97=B6=EF=BC=8C=E4=B8=8D=E8=83=BD=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=9C=80=E4=BC=98=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8Dbug=EF=BC=9A=E8=8E=B7=E5=8F=96=E6=8C=81?= =?UTF-8?q?=E4=BB=93=E6=97=B6=EF=BC=8Cposition=E4=B8=BAzero=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/gateway/ctpGateway/ctpGateway.py | 3 ++- vnpy/trader/gateway/ctpseGateway/ctpseGateway.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/gateway/ctpGateway/ctpGateway.py b/vnpy/trader/gateway/ctpGateway/ctpGateway.py index 413eb1a1..31c5ee3e 100644 --- a/vnpy/trader/gateway/ctpGateway/ctpGateway.py +++ b/vnpy/trader/gateway/ctpGateway/ctpGateway.py @@ -1069,7 +1069,7 @@ class CtpTdApi(TdApi): pre_settlement_price = data['PreSettlementPrice'] # 当前一笔的开仓均价 - open_cost_price = data['OpenCost'] / (data['Position'] * size) + open_cost_price = (data['OpenCost'] / (data['Position'] * size)) if data['Position'] > 0 else 0.0 pre_profit = 0 # 上-交易日收益 = (上一交易日结算价 - 开仓价)* 昨仓持仓数量 * 杠杆 @@ -2004,6 +2004,7 @@ class TdxMdApi(): except Exception as ex: self.writeError(u'连接服务器tdx[{}]异常:{},{}'.format(i,str(ex),traceback.format_exc())) + self.best_ip = {'ip': None, 'port': None} return # 更新 symbol_exchange_dict , symbol_market_dict diff --git a/vnpy/trader/gateway/ctpseGateway/ctpseGateway.py b/vnpy/trader/gateway/ctpseGateway/ctpseGateway.py index fb26c0db..1bb21950 100644 --- a/vnpy/trader/gateway/ctpseGateway/ctpseGateway.py +++ b/vnpy/trader/gateway/ctpseGateway/ctpseGateway.py @@ -1085,7 +1085,7 @@ class CtpTdApi(TdApi): pre_settlement_price = data['PreSettlementPrice'] # 当前一笔的开仓均价 - open_cost_price = data['OpenCost'] / (data['Position'] * size) + open_cost_price = (data['OpenCost'] / (data['Position'] * size)) if data['Position'] > 0 else 0.0 pre_profit = 0 # 上-交易日收益 = (上一交易日结算价 - 开仓价)* 昨仓持仓数量 * 杠杆 @@ -2025,6 +2025,7 @@ class TdxMdApi(): except Exception as ex: self.writeError(u'连接服务器tdx[{}]异常:{},{}'.format(i,str(ex),traceback.format_exc())) + self.best_ip = {'ip': None, 'port': None} return # 更新 symbol_exchange_dict , symbol_market_dict