[Add]增加WebTrader的主页路由

This commit is contained in:
vn.py 2018-02-13 17:22:42 +08:00
parent 67f7b8be3b
commit 2f9af196a8
3 changed files with 26 additions and 9 deletions

View File

@ -56,7 +56,6 @@ api = Api(app)
socketio = SocketIO(app) socketio = SocketIO(app)
# 创建资源 # 创建资源
######################################################################## ########################################################################
class Token(Resource): class Token(Resource):
"""登录验证""" """登录验证"""
@ -204,16 +203,33 @@ class Order(Resource):
vtOrderID = args['vtOrderID'] vtOrderID = args['vtOrderID']
# 撤单某一委托
if vtOrderID:
order = me.getOrder(vtOrderID) order = me.getOrder(vtOrderID)
if not order: if not order:
return {'result_code':'error','message':'vtOrderID error'} return {'result_code':'error','message':'vtOrderID error'}
self.cancel(order)
# 全撤
else:
l = me.getAllWorkingOrders()
for order in l:
self.cancel(order)
return {'result_code':'success','data':""}
#----------------------------------------------------------------------
def cancel(self, order):
"""撤单"""
req = VtCancelOrderReq() req = VtCancelOrderReq()
req.orderID = order.orderID req.orderID = order.orderID
req.exchange = order.exchange req.exchange = order.exchange
req.symbol = order.symbol req.symbol = order.symbol
req.frontID = order.frontID
req.sessionID = order.sessionID
me.cancelOrder(req, order.gatewayName) me.cancelOrder(req, order.gatewayName)
return {'result_code':'success','data':""}
######################################################################## ########################################################################
class Trade(Resource): class Trade(Resource):
@ -598,7 +614,8 @@ class CtaStrategyVar(Resource):
@app.route('/') @app.route('/')
def index_html(): def index_html():
"""首页""" """首页"""
return send_file( os.path.abspath('.') + '/web/index.html' ) return send_file('./templates/index.html')
# 注册资源 # 注册资源
api.add_resource(Token, '/token') api.add_resource(Token, '/token')

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<script src="https://cdn.bootcss.com/socket.io/2.0.4/socket.io.slim.js"></script> <script src="https://cdn.bootcss.com/socket.io/2.0.4/socket.io.slim.js"></script>
<link href="https://cdn.bootcss.com/element-ui/2.0.11/theme-chalk/index.css" rel="stylesheet"> <link href="https://cdn.bootcss.com/element-ui/2.0.11/theme-chalk/index.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" href="/static/css/style.css">
</head> </head>
<body> <body>