From 4691e0c1529d122501b3b30c4a16657dbbfcdbaf Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 9 Feb 2018 13:37:05 +0800 Subject: [PATCH] =?UTF-8?q?[Add]WebTrader=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=AD=96=E7=95=A5=E5=90=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/WebTrader/run.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/WebTrader/run.py b/examples/WebTrader/run.py index 9d6e7ff5..9ab6b124 100644 --- a/examples/WebTrader/run.py +++ b/examples/WebTrader/run.py @@ -494,6 +494,30 @@ class CtaStrategyStop(Resource): engine.stopStrategy(name) +######################################################################## +class CtaStrategyName(Resource): + """获取策略名""" + + #---------------------------------------------------------------------- + def __init__(self): + """初始化""" + self.parser = reqparse.RequestParser() + self.parser.add_argument('token') + super(CtaStrategyName, self).__init__() + + #---------------------------------------------------------------------- + def get(self): + """获取策略名""" + args = self.parser.parse_args() + token = args['token'] + if token != TOKEN: + return None + + engine = me.getApp('CtaStrategy') + l = engine.getStrategyNames() + return l + + ######################################################################## class CtaStrategyLoad(Resource): """加载策略""" @@ -589,6 +613,7 @@ api.add_resource(CtaStrategyStart, '/ctastrategy/start') api.add_resource(CtaStrategyStop, '/ctastrategy/stop') api.add_resource(CtaStrategyParam, '/ctastrategy/param') api.add_resource(CtaStrategyVar, '/ctastrategy/var') +api.add_resource(CtaStrategyName, '/ctastrategy/name') # SocketIO