From 59acdfdf088501b3048bce1f508f04bd8331b8f3 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Wed, 15 Apr 2020 20:19:04 +0800 Subject: [PATCH] =?UTF-8?q?[improvement]=E6=94=B9=E8=89=AF=E4=B8=8B?= =?UTF-8?q?=E6=8B=86=E8=A7=A3vt=5Fsymbol=E5=BE=97=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/utility.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index 22d2775d..4691f5df 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -166,12 +166,19 @@ def get_trading_date(dt: datetime = None): else: return dt.strftime('%Y-%m-%d') - def extract_vt_symbol(vt_symbol: str) -> Tuple[str, Exchange]: """ :return: (symbol, exchange) """ - symbol, exchange_str = vt_symbol.split(".") + if '.' in vt_symbol: + symbol, exchange_str = vt_symbol.split('.') + elif vt_symbol.isdigit(): + symbol = vt_symbol + exchange_str = get_stock_exchange(code=symbol) + else: + symbol = vt_symbol + exchange_str = Exchange.LOCAL.value + return symbol, Exchange(exchange_str)