This commit is contained in:
vn.py 2018-08-06 11:44:32 +08:00
parent 8137b6af14
commit 3431b9b15e
3 changed files with 18 additions and 4 deletions

View File

@ -9,6 +9,8 @@ from time import sleep
from datetime import datetime, time from datetime import datetime, time
from multiprocessing import Process from multiprocessing import Process
import webbrowser
from webServer import run as runWebServer from webServer import run as runWebServer
from tradingServer import main as runTradingServer from tradingServer import main as runTradingServer
from vnpy.trader.vtEngine import LogEngine from vnpy.trader.vtEngine import LogEngine
@ -28,6 +30,9 @@ if __name__ == '__main__':
pWeb = None pWeb = None
pTrading = None pTrading = None
import os
print(os.getpid())
while True: while True:
le.info('-'*30) le.info('-'*30)
@ -48,6 +53,8 @@ if __name__ == '__main__':
pWeb = Process(target=runWebServer) pWeb = Process(target=runWebServer)
pWeb.start() pWeb.start()
le.info(u'启动WEB服务器进程') le.info(u'启动WEB服务器进程')
webbrowser.open('http://127.0.0.1:5000')
else: else:
le.info(u'当前处于非交易时间段') le.info(u'当前处于非交易时间段')

View File

@ -50,8 +50,8 @@ with open("WEB_setting.json") as f:
# 创建Flask对象 # 创建Flask对象
from flask import Flask, send_file from flask import Flask, send_file
from flask.ext.restful import Api, Resource, reqparse from flask_restful import Api, Resource, reqparse
from flask.ext.socketio import SocketIO from flask_socketio import SocketIO
from flask_cors import * from flask_cors import *
app = Flask(__name__) app = Flask(__name__)
@ -510,6 +510,7 @@ class CtaStrategyStop(Resource):
engine.stopStrategy(name) engine.stopStrategy(name)
return {'result_code':'success','data':''} return {'result_code':'success','data':''}
######################################################################## ########################################################################
class CtaStrategyName(Resource): class CtaStrategyName(Resource):
"""»ñÈ¡²ßÂÔÃû""" """»ñÈ¡²ßÂÔÃû"""
@ -533,6 +534,7 @@ class CtaStrategyName(Resource):
l = engine.getStrategyNames() l = engine.getStrategyNames()
return {'result_code':'success','data':l} return {'result_code':'success','data':l}
######################################################################## ########################################################################
class CtaStrategyLoad(Resource): class CtaStrategyLoad(Resource):
"""加载策略""" """加载策略"""
@ -672,7 +674,11 @@ ee.register(EVENT_CTA_STRATEGY, handleEvent)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def run(): def run():
"""启动Web服务""" """启动Web服务"""
socketio.run(app,debug=True,host='0.0.0.0',port=5000) socketio.run(app,
debug=True,
host='0.0.0.0',
port=5000,
use_reloader=False)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -10,4 +10,5 @@ flask-socketio
flask-restful flask-restful
flask-cors flask-cors
gevent-websocket gevent-websocket
pyjwt pyjwt
webbrowser