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