Skip to content

Commit

Permalink
1. 补充ubuntu下boost版本相关信息
Browse files Browse the repository at this point in the history
2. 修复ctpGateway的持仓查询的数据推送问题
  • Loading branch information
chenxy123 committed Oct 31, 2016
1 parent 871190f commit 002b35a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vn.ctp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 14 additions & 5 deletions vn.trader/ctpGateway/ctpGateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def connect(self):
"""连接"""
# 载入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)
Expand Down Expand Up @@ -659,10 +658,15 @@ def onRspQryInvestorPosition(self, data, error, n, last):
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):
Expand Down Expand Up @@ -1441,6 +1445,11 @@ def updateBuffer(self, data, size):
self.pos.price = 0

return copy(self.pos)

#----------------------------------------------------------------------
def getPos(self):
"""获取当前的持仓数据"""
return copy(self.pos)


#----------------------------------------------------------------------
Expand Down

0 comments on commit 002b35a

Please sign in to comment.