From 002b35ab98444851be0d27f3b6aafa76ad627439 Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Mon, 31 Oct 2016 23:09:25 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=A1=A5=E5=85=85ubuntu=E4=B8=8Bboost?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF=202.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DctpGateway=E7=9A=84=E6=8C=81=E4=BB=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9A=84=E6=95=B0=E6=8D=AE=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.ctp/readme.md | 2 +- vn.trader/ctpGateway/ctpGateway.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/vn.ctp/readme.md b/vn.ctp/readme.md index 02e21d99..fa7c4b4f 100644 --- a/vn.ctp/readme.md +++ b/vn.ctp/readme.md @@ -46,7 +46,7 @@ CTP * 参考[这里](http://www.continuum.io/downloads)的教程下载并安装Anaconda的Linux 64位版本 -* 使用apt-get安装编译相关的工具: +* 使用apt-get安装编译相关的工具,注意某些老的Ubuntu必须指定使用boost 1.58.0版本: - apt-get install build-essential diff --git a/vn.trader/ctpGateway/ctpGateway.py b/vn.trader/ctpGateway/ctpGateway.py index ff1ba72f..a765c0ca 100644 --- a/vn.trader/ctpGateway/ctpGateway.py +++ b/vn.trader/ctpGateway/ctpGateway.py @@ -87,8 +87,7 @@ class CtpGateway(VtGateway): """杩炴帴""" # 杞藉叆json鏂囦欢 fileName = self.gatewayName + '_connect.json' - path = os.path.abspath(os.path.dirname(__file__)) - fileName = os.path.join(path, fileName) + fileName = os.getcwd() + '/ctpGateway/' + fileName try: f = file(fileName) @@ -659,10 +658,15 @@ class CtpTdApi(TdApi): exchange = self.symbolExchangeDict.get(data['InstrumentID'], EXCHANGE_UNKNOWN) size = self.symbolSizeDict.get(data['InstrumentID'], 1) if exchange == EXCHANGE_SHFE: - pos = posBuffer.updateShfeBuffer(data, size) + posBuffer.updateShfeBuffer(data, size) else: - pos = posBuffer.updateBuffer(data, size) - self.gateway.onPosition(pos) + posBuffer.updateBuffer(data, size) + + # 鎵鏈夋寔浠撴暟鎹兘鏇存柊鍚庯紝鍐嶅皢缂撳瓨涓殑鎸佷粨鎯呭喌鍙戦佸埌浜嬩欢寮曟搸涓 + if last: + for buf in self.posBufferDict.values(): + pos = buf.getPos() + self.gateway.onPosition(pos) #---------------------------------------------------------------------- def onRspQryTradingAccount(self, data, error, n, last): @@ -1441,6 +1445,11 @@ class PositionBuffer(object): self.pos.price = 0 return copy(self.pos) + + #---------------------------------------------------------------------- + def getPos(self): + """鑾峰彇褰撳墠鐨勬寔浠撴暟鎹""" + return copy(self.pos) #----------------------------------------------------------------------