[improvement]改良下拆解vt_symbol得方法

This commit is contained in:
msincenselee 2020-04-15 20:19:04 +08:00
parent 7ffc096943
commit 59acdfdf08

View File

@ -166,12 +166,19 @@ def get_trading_date(dt: datetime = None):
else: else:
return dt.strftime('%Y-%m-%d') return dt.strftime('%Y-%m-%d')
def extract_vt_symbol(vt_symbol: str) -> Tuple[str, Exchange]: def extract_vt_symbol(vt_symbol: str) -> Tuple[str, Exchange]:
""" """
:return: (symbol, 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) return symbol, Exchange(exchange_str)