完善vn.trader中的sgitGateway
This commit is contained in:
parent
76cbeba72a
commit
9e789af8b8
@ -1259,6 +1259,10 @@ class CtpTdApi(TdApi):
|
|||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
self.createFtdcTraderApi(path)
|
self.createFtdcTraderApi(path)
|
||||||
|
|
||||||
|
# 设置数据同步模式为推送从今日开始所有数据
|
||||||
|
self.subscribePrivateTopic(0)
|
||||||
|
self.subscribePublicTopic(0)
|
||||||
|
|
||||||
# 注册服务器地址
|
# 注册服务器地址
|
||||||
self.registerFront(self.address)
|
self.registerFront(self.address)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"brokerID": "9999",
|
"brokerID": "9999",
|
||||||
"tdAddress": "tcp://180.168.146.187:10000",
|
"tdAddress": "tcp://140.206.81.6:37776",
|
||||||
"password": "simnow申请",
|
"password": "888888",
|
||||||
"mdAddress": "tcp://180.168.212.228:41213",
|
"mdAddress": "tcp://140.206.81.6:37777",
|
||||||
"userID": "simnow申请"
|
"userID": "0600035"
|
||||||
}
|
}
|
@ -46,7 +46,7 @@ exchangeMap[EXCHANGE_CFFEX] = 'CFFEX'
|
|||||||
exchangeMap[EXCHANGE_SHFE] = 'SHFE'
|
exchangeMap[EXCHANGE_SHFE] = 'SHFE'
|
||||||
exchangeMap[EXCHANGE_CZCE] = 'CZCE'
|
exchangeMap[EXCHANGE_CZCE] = 'CZCE'
|
||||||
exchangeMap[EXCHANGE_DCE] = 'DCE'
|
exchangeMap[EXCHANGE_DCE] = 'DCE'
|
||||||
exchangeMap[EXCHANGE_SSE] = 'SSE'
|
exchangeMap[EXCHANGE_SGE] = 'SGE'
|
||||||
exchangeMap[EXCHANGE_UNKNOWN] = ''
|
exchangeMap[EXCHANGE_UNKNOWN] = ''
|
||||||
exchangeMapReverse = {v:k for k,v in exchangeMap.items()}
|
exchangeMapReverse = {v:k for k,v in exchangeMap.items()}
|
||||||
|
|
||||||
@ -477,6 +477,10 @@ class SgitTdApi(TdApi):
|
|||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
self.createFtdcTraderApi(path)
|
self.createFtdcTraderApi(path)
|
||||||
|
|
||||||
|
# 设置数据同步模式为推送从今日开始所有数据
|
||||||
|
self.subscribePrivateTopic(0)
|
||||||
|
self.subscribePublicTopic(0)
|
||||||
|
|
||||||
# 注册服务器地址
|
# 注册服务器地址
|
||||||
self.registerFront(self.address)
|
self.registerFront(self.address)
|
||||||
|
|
||||||
@ -520,6 +524,7 @@ class SgitTdApi(TdApi):
|
|||||||
"""发单"""
|
"""发单"""
|
||||||
self.reqID += 1
|
self.reqID += 1
|
||||||
self.orderRef += 1
|
self.orderRef += 1
|
||||||
|
orderRef = str(self.orderRef).rjust(10, '0')
|
||||||
|
|
||||||
req = {}
|
req = {}
|
||||||
|
|
||||||
@ -532,7 +537,7 @@ class SgitTdApi(TdApi):
|
|||||||
req['Direction'] = directionMap.get(orderReq.direction, '')
|
req['Direction'] = directionMap.get(orderReq.direction, '')
|
||||||
req['CombOffsetFlag'] = offsetMap.get(orderReq.offset, '')
|
req['CombOffsetFlag'] = offsetMap.get(orderReq.offset, '')
|
||||||
|
|
||||||
req['OrderRef'] = str(self.orderRef)
|
req['OrderRef'] = orderRef
|
||||||
req['InvestorID'] = self.userID
|
req['InvestorID'] = self.userID
|
||||||
req['UserID'] = self.userID
|
req['UserID'] = self.userID
|
||||||
req['BrokerID'] = self.brokerID
|
req['BrokerID'] = self.brokerID
|
||||||
@ -558,7 +563,8 @@ class SgitTdApi(TdApi):
|
|||||||
self.reqOrderInsert(req, self.reqID)
|
self.reqOrderInsert(req, self.reqID)
|
||||||
|
|
||||||
# 返回订单号(字符串),便于某些算法进行动态管理
|
# 返回订单号(字符串),便于某些算法进行动态管理
|
||||||
vtOrderID = '.'.join([self.gatewayName, str(self.orderRef)])
|
vtOrderID = '.'.join([self.gatewayName, orderRef])
|
||||||
|
|
||||||
return vtOrderID
|
return vtOrderID
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
@ -577,6 +583,7 @@ class SgitTdApi(TdApi):
|
|||||||
req['ActionFlag'] = defineDict['THOST_FTDC_AF_Delete']
|
req['ActionFlag'] = defineDict['THOST_FTDC_AF_Delete']
|
||||||
req['BrokerID'] = self.brokerID
|
req['BrokerID'] = self.brokerID
|
||||||
req['InvestorID'] = self.userID
|
req['InvestorID'] = self.userID
|
||||||
|
req['UserID'] = self.userID
|
||||||
|
|
||||||
self.reqOrderAction(req, self.reqID)
|
self.reqOrderAction(req, self.reqID)
|
||||||
|
|
||||||
@ -1033,7 +1040,7 @@ class SgitTdApi(TdApi):
|
|||||||
err.gatewayName = self.gatewayName
|
err.gatewayName = self.gatewayName
|
||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnOrder(self, data):
|
def onRtnOrder(self, data):
|
||||||
@ -1115,7 +1122,7 @@ class SgitTdApi(TdApi):
|
|||||||
err.gatewayName = self.gatewayName
|
err.gatewayName = self.gatewayName
|
||||||
err.errorID = error['ErrorID']
|
err.errorID = error['ErrorID']
|
||||||
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
err.errorMsg = error['ErrorMsg'].decode('gbk')
|
||||||
self.gateway.onError(err)
|
self.gateway.onError(err)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def onRtnInstrumentStatus(self, data):
|
def onRtnInstrumentStatus(self, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user