From 47e8bb16c794976be97d4de92d0b8bfea35f066c Mon Sep 17 00:00:00 2001 From: msincenselee Date: Wed, 26 Jan 2022 10:07:59 +0800 Subject: [PATCH] =?UTF-8?q?[bug=20fix]=20=E5=A2=9E=E5=8A=A0=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/engine.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/engine.py b/vnpy/trader/engine.py index d0af5f6b..8247f982 100644 --- a/vnpy/trader/engine.py +++ b/vnpy/trader/engine.py @@ -145,14 +145,17 @@ class MainEngine: print(msg, file=sys.stderr) - def get_gateway(self, gateway_name: str) -> BaseGateway: """ Return gateway object by name. """ gateway = self.gateways.get(gateway_name, None) if not gateway: - self.write_error(f"找不到底层接口:{gateway_name}") + # 增加兼容得写法,如果没有输入gateway_name,但当前只有一个gateway时,就使用当前gateway + if len(self.gateways.keys()) == 1: + return self.gateways.values()[0] + + self.write_error(f"在{self.gateways.keys()}中找不到底层接口:{gateway_name}") return gateway def get_engine(self, engine_name: str) -> "BaseEngine":