修改风控模块,增加持仓比例控制。如超过90%就不开仓

修改gateway,与dev同步,修复持仓问题。
This commit is contained in:
msincenselee 2016-08-02 15:38:04 +08:00
parent e361478a4e
commit fc85f03d88
4 changed files with 6 additions and 2 deletions

View File

@ -789,6 +789,7 @@ class CtpTdApi(TdApi):
self.gateway.onContract(contract)
if last:
#print self.symbolSizeDict
log = VtLogData()
log.gatewayName = self.gatewayName
log.logContent = u'交易合约信息获取完成'
@ -965,6 +966,7 @@ class CtpTdApi(TdApi):
order.totalVolume = data['VolumeTotalOriginal']
order.tradedVolume = data['VolumeTraded']
order.orderTime = data['InsertTime']
order.updateTime = data['UpdateTime']
order.cancelTime = data['CancelTime']
order.frontID = data['FrontID']
order.sessionID = data['SessionID']
@ -1405,7 +1407,7 @@ class PositionBuffer(object):
self.pos.position = data['Position']
self.pos.ydPosition = 0
if data['Position']:
if data['Position'] != 0 and size!=0:
self.pos.price = data['PositionCost'] / (data['Position'] * size)
else:
self.pos.price = 0

View File

@ -190,7 +190,7 @@ class RmEngine(object):
%(workingOrderCount, self.workingOrderLimit))
return False
self.writeRiskLog(u'DEBUG:Offset:{0},percent:{1},Limit:{2}'.format(orderReq.offset, self.percent, self.percentLimit))
#self.writeRiskLog(u'DEBUG:Offset:{0},percent:{1},Limit:{2}'.format(orderReq.offset, self.percent, self.percentLimit))
# 检查仓位 add by Incense 20160728
if orderReq.offset == OFFSET_OPEN:

View File

@ -522,6 +522,7 @@ class OrderMonitor(BasicMonitor):
d['orderTime'] = {'chinese':u'委托时间', 'cellType':BasicCell}
d['totalVolume'] = {'chinese':u'委托数量', 'cellType':BasicCell}
d['tradedVolume'] = {'chinese':u'成交数量', 'cellType':BasicCell}
#d['updateTime'] = {'chinese':u'更新时间', 'cellType':BasicCell}
d['cancelTime'] = {'chinese':u'撤销时间', 'cellType':BasicCell}
d['frontID'] = {'chinese':u'前置编号', 'cellType':BasicCell}
d['sessionID'] = {'chinese':u'会话编号', 'cellType':BasicCell}

View File

@ -276,6 +276,7 @@ class VtOrderData(VtBaseData):
self.status = EMPTY_UNICODE # 报单状态
self.orderTime = EMPTY_STRING # 发单时间
self.updateTime = EMPTY_STRING # 最后更新时间
self.cancelTime = EMPTY_STRING # 撤单时间
# CTP/LTS相关