- add : 客户端通过服务器来获得可加载的接口
This commit is contained in:
parent
cf7adb015a
commit
3cbf54cffa
@ -5,12 +5,13 @@
|
||||
"mongoHost": "localhost",
|
||||
"mongoPort": 27017,
|
||||
"mongoLogging": true,
|
||||
"automongodb": true,
|
||||
"automongodb": false,
|
||||
|
||||
"darkStyle": true,
|
||||
"language": "chinese",
|
||||
"CTP_connect": null,
|
||||
"autoctp": true,
|
||||
|
||||
"CTP_connect": "./gateway/ctpGateway/CTP_connect.json",
|
||||
"autoctp": false,
|
||||
|
||||
"autoshutdown": true
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import psutil
|
||||
|
||||
from gateway import GATEWAY_DICT
|
||||
# from gateway import GATEWAY_DICT
|
||||
from uiBasicWidget import *
|
||||
from ctaStrategy.uiCtaWidget import CtaEngineManager
|
||||
from dataRecorder.uiDrWidget import DrEngineManager
|
||||
@ -69,34 +69,54 @@ class MainWindow(QtGui.QMainWindow):
|
||||
# 设计为只显示存在的接口
|
||||
sysMenu = menubar.addMenu(vtText.SYSTEM)
|
||||
|
||||
for gatewayModule in GATEWAY_DICT.values():
|
||||
if gatewayModule.gatewayType == GATEWAYTYPE_FUTURES:
|
||||
self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
gatewayModule.gatewayDisplayName)
|
||||
|
||||
sysMenu.addSeparator()
|
||||
for gatewayModule in GATEWAY_DICT.values():
|
||||
if gatewayModule.gatewayType == GATEWAYTYPE_EQUITY:
|
||||
self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
gatewayModule.gatewayDisplayName)
|
||||
# 鉴于前后端分离,此处不应当直接检查本地的gateway接口可用情况,而是应当向服务端查询
|
||||
GATEWAY_TYPES = [
|
||||
GATEWAYTYPE_FUTURES,
|
||||
GATEWAYTYPE_EQUITY,
|
||||
GATEWAYTYPE_INTERNATIONAL,
|
||||
GATEWAYTYPE_BTC,
|
||||
GATEWAYTYPE_DATA,
|
||||
|
||||
sysMenu.addSeparator()
|
||||
for gatewayModule in GATEWAY_DICT.values():
|
||||
if gatewayModule.gatewayType == GATEWAYTYPE_INTERNATIONAL:
|
||||
self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
gatewayModule.gatewayDisplayName)
|
||||
|
||||
sysMenu.addSeparator()
|
||||
for gatewayModule in GATEWAY_DICT.values():
|
||||
if gatewayModule.gatewayType == GATEWAYTYPE_BTC:
|
||||
self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
gatewayModule.gatewayDisplayName)
|
||||
]
|
||||
|
||||
sysMenu.addSeparator()
|
||||
for gatewayModule in GATEWAY_DICT.values():
|
||||
if gatewayModule.gatewayType == GATEWAYTYPE_DATA:
|
||||
self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
gatewayModule.gatewayDisplayName)
|
||||
# 获取可链接的交易接口
|
||||
gateways = self.mainEngine.getGateway4sysMenu()
|
||||
|
||||
# 模拟一个GateWay 实例
|
||||
for g in gateways:
|
||||
sysMenu.addSeparator()
|
||||
if g['gatewayType'] in GATEWAY_TYPES:
|
||||
self.addConnectAction(sysMenu, g['gatewayName'],
|
||||
g['gatewayDisplayName'])
|
||||
|
||||
# for gatewayModule in GATEWAY_DICT.values():
|
||||
# if gatewayModule.gatewayType == GATEWAYTYPE_FUTURES:
|
||||
# self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
# gatewayModule.gatewayDisplayName)
|
||||
#
|
||||
# sysMenu.addSeparator()
|
||||
# for gatewayModule in GATEWAY_DICT.values():
|
||||
# if gatewayModule.gatewayType == GATEWAYTYPE_EQUITY:
|
||||
# self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
# gatewayModule.gatewayDisplayName)
|
||||
#
|
||||
# sysMenu.addSeparator()
|
||||
# for gatewayModule in GATEWAY_DICT.values():
|
||||
# if gatewayModule.gatewayType == GATEWAYTYPE_INTERNATIONAL:
|
||||
# self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
# gatewayModule.gatewayDisplayName)
|
||||
#
|
||||
# sysMenu.addSeparator()
|
||||
# for gatewayModule in GATEWAY_DICT.values():
|
||||
# if gatewayModule.gatewayType == GATEWAYTYPE_BTC:
|
||||
# self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
# gatewayModule.gatewayDisplayName)
|
||||
#
|
||||
# sysMenu.addSeparator()
|
||||
# for gatewayModule in GATEWAY_DICT.values():
|
||||
# if gatewayModule.gatewayType == GATEWAYTYPE_DATA:
|
||||
# self.addConnectAction(sysMenu, gatewayModule.gatewayName,
|
||||
# gatewayModule.gatewayDisplayName)
|
||||
|
||||
sysMenu.addSeparator()
|
||||
sysMenu.addAction(self.createAction(vtText.CONNECT_DATABASE, self.mainEngine.dbConnect))
|
||||
|
@ -152,6 +152,9 @@ class ClientEngine(object):
|
||||
"""查询所有的接口名称"""
|
||||
return self.client.getAllGatewayNames()
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
def getGateway4sysMenu(self):
|
||||
return self.client.getGateway4sysMenu()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def main():
|
||||
|
@ -246,8 +246,22 @@ class MainEngine(object):
|
||||
def getAllGatewayNames(self):
|
||||
"""查询引擎中所有可用接口的名称"""
|
||||
return self.gatewayDict.keys()
|
||||
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
def getGateway4sysMenu(self):
|
||||
"""
|
||||
|
||||
:return:
|
||||
"""
|
||||
|
||||
toDict = lambda g: {
|
||||
'gatewayType': g.gatewayType,
|
||||
'gatewayName': g.gatewayName,
|
||||
'gatewayDisplayName': g.gatewayDisplayName,
|
||||
}
|
||||
return [
|
||||
toDict(g) for g in GATEWAY_DICT.values() if hasattr(g, 'gatewayType')
|
||||
]
|
||||
|
||||
########################################################################
|
||||
class DataEngine(object):
|
||||
|
@ -43,7 +43,8 @@ class VtServer(RpcServer):
|
||||
self.register(self.engine.getOrder)
|
||||
self.register(self.engine.getAllWorkingOrders)
|
||||
self.register(self.engine.getAllGatewayNames)
|
||||
|
||||
self.register(self.engine.getGateway4sysMenu)
|
||||
|
||||
# 注册事件引擎发送的事件处理监听
|
||||
self.engine.eventEngine.registerGeneralHandler(self.eventHandler)
|
||||
|
||||
@ -87,7 +88,6 @@ def runServer():
|
||||
# 自动建立MongoDB数据库
|
||||
printLog(u'MongoDB connect... ')
|
||||
server.engine.dbConnect()
|
||||
printLog(u'MongoDB OK... ')
|
||||
|
||||
if VT_setting.get('autoctp'):
|
||||
# 自动建立CTP链接
|
||||
|
Loading…
Reference in New Issue
Block a user