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) #----------------------------------------------------------------------