From 2125bc6a2739fc79246821794e41e0cf56da9e30 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Tue, 2 Jul 2019 23:32:36 +0800 Subject: [PATCH] [Mod] change cta strategy manager ui to use fixed height, closes #1890 --- examples/vn_trader/run.py | 8 ++++---- vnpy/app/cta_strategy/engine.py | 5 ++++- vnpy/app/cta_strategy/ui/widget.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/vn_trader/run.py b/examples/vn_trader/run.py index 43b0adcd..f2a58c8e 100644 --- a/examples/vn_trader/run.py +++ b/examples/vn_trader/run.py @@ -8,11 +8,11 @@ from vnpy.trader.ui import MainWindow, create_qapp # from vnpy.gateway.bitmex import BitmexGateway # from vnpy.gateway.futu import FutuGateway # from vnpy.gateway.ib import IbGateway -# from vnpy.gateway.ctp import CtpGateway +from vnpy.gateway.ctp import CtpGateway # from vnpy.gateway.ctptest import CtptestGateway # from vnpy.gateway.femas import FemasGateway # from vnpy.gateway.tiger import TigerGateway -from vnpy.gateway.oes import OesGateway +# from vnpy.gateway.oes import OesGateway # from vnpy.gateway.okex import OkexGateway # from vnpy.gateway.huobi import HuobiGateway # from vnpy.gateway.bitfinex import BitfinexGateway @@ -43,14 +43,14 @@ def main(): main_engine = MainEngine(event_engine) # main_engine.add_gateway(BinanceGateway) - # main_engine.add_gateway(CtpGateway) + main_engine.add_gateway(CtpGateway) # main_engine.add_gateway(CtptestGateway) # main_engine.add_gateway(FemasGateway) # main_engine.add_gateway(IbGateway) # main_engine.add_gateway(FutuGateway) # main_engine.add_gateway(BitmexGateway) # main_engine.add_gateway(TigerGateway) - main_engine.add_gateway(OesGateway) + # main_engine.add_gateway(OesGateway) # main_engine.add_gateway(OkexGateway) # main_engine.add_gateway(HuobiGateway) # main_engine.add_gateway(BitfinexGateway) diff --git a/vnpy/app/cta_strategy/engine.py b/vnpy/app/cta_strategy/engine.py index 4e94ac2f..bcaf2e6a 100644 --- a/vnpy/app/cta_strategy/engine.py +++ b/vnpy/app/cta_strategy/engine.py @@ -581,7 +581,10 @@ class CtaEngine(BaseEngine): self.write_log(f"创建策略失败,存在重名{strategy_name}") return - strategy_class = self.classes[class_name] + strategy_class = self.classes.get(class_name, None) + if not strategy_class: + self.write_log(f"创建策略失败,找不到策略类{class_name}") + return strategy = strategy_class(self, strategy_name, vt_symbol, setting) self.strategies[strategy_name] = strategy diff --git a/vnpy/app/cta_strategy/ui/widget.py b/vnpy/app/cta_strategy/ui/widget.py index 12354487..7e553015 100644 --- a/vnpy/app/cta_strategy/ui/widget.py +++ b/vnpy/app/cta_strategy/ui/widget.py @@ -179,7 +179,7 @@ class StrategyManager(QtWidgets.QFrame): def init_ui(self): """""" - self.setMaximumHeight(300) + self.setFixedHeight(300) self.setFrameShape(self.Box) self.setLineWidth(1)