本文整理汇总了Python中pytdx.hq.TdxHq_API.to_df方法的典型用法代码示例。如果您正苦于以下问题:Python TdxHq_API.to_df方法的具体用法?Python TdxHq_API.to_df怎么用?Python TdxHq_API.to_df使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytdx.hq.TdxHq_API
的用法示例。
在下文中一共展示了TdxHq_API.to_df方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QA_fetch_get_stock_block
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_block(ip=None, port=None):
'板块数据'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
with api.connect(ip, port):
data = pd.concat([api.to_df(api.get_and_parse_block_info("block_gn.dat")).assign(type='gn'),
api.to_df(api.get_and_parse_block_info(
"block.dat")).assign(type='yb'),
api.to_df(api.get_and_parse_block_info(
"block_zs.dat")).assign(type='zs'),
api.to_df(api.get_and_parse_block_info("block_fg.dat")).assign(type='fg')])
if len(data) > 10:
return data.assign(source='tdx').drop(['block_type', 'code_index'], axis=1).set_index('code', drop=False, inplace=False).drop_duplicates()
else:
QA_util_log_info('Wrong with fetch block ')
示例2: QA_fetch_get_index_min
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_index_min(code, start, end, level='1min', ip=best_ip, port=7709):
api = TdxHq_API()
type_ = ''
if str(level) in ['5', '5m', '5min', 'five']:
level, type_ = 0, '5min'
elif str(level) in ['1', '1m', '1min', 'one']:
level, type_ = 8, '1min'
elif str(level) in ['15', '15m', '15min', 'fifteen']:
level, type_ = 1, '15min'
elif str(level) in ['30', '30m', '30min', 'half']:
level, type_ = 2, '30min'
elif str(level) in ['60', '60m', '60min', '1h']:
level, type_ = 3, '60min'
with api.connect(ip, port):
if str(code)[0] in ['5', '1']: # ETF
data = pd.concat([api.to_df(api.get_security_bars(
level, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (25 - i) * 800, 800)) for i in range(26)], axis=0)
else:
data = pd.concat([api.to_df(api.get_index_bars(
level, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (25 - i) * 800, 800)) for i in range(26)], axis=0)
data = data\
.assign(datetime=pd.to_datetime(data['datetime']), code=str(code))\
.drop(['year', 'month', 'day', 'hour', 'minute'], axis=1, inplace=False)\
.assign(date=data['datetime'].apply(lambda x: str(x)[0:10]))\
.assign(date_stamp=data['datetime'].apply(lambda x: QA_util_date_stamp(x)))\
.assign(time_stamp=data['datetime'].apply(lambda x: QA_util_time_stamp(x)))\
.assign(type=type_).set_index('datetime', drop=False, inplace=False)[start:end]
# data
return data.assign(datetime=data['datetime'].apply(lambda x: str(x)))
示例3: QA_fetch_get_index_day
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_index_day(code, start_date, end_date, level='day', ip=best_ip, port=7709):
'指数日线'
api = TdxHq_API()
if level in ['day', 'd', 'D', 'DAY', 'Day']:
level = 9
elif level in ['w', 'W', 'Week', 'week']:
level = 5
elif level in ['month', 'M', 'm', 'Month']:
level = 6
elif level in ['Q', 'Quarter', 'q']:
level = 10
elif level in ['y', 'Y', 'year', 'Year']:
level = 11
with api.connect(ip, port):
if str(code)[0] in ['5', '1']: # ETF
data = pd.concat([api.to_df(api.get_security_bars(
level, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (25 - i) * 800, 800)) for i in range(26)], axis=0)
else:
data = pd.concat([api.to_df(api.get_index_bars(
level, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (25 - i) * 800, 800)) for i in range(26)], axis=0)
data = data.assign(date=data['datetime'].apply(lambda x: str(x[0:10]))).assign(code=str(code))\
.assign(date_stamp=data['datetime'].apply(lambda x: QA_util_date_stamp(str(x)[0:10])))\
.set_index('date', drop=False, inplace=False)\
.drop(['year', 'month', 'day', 'hour',
'minute', 'datetime'], axis=1)[start_date:end_date]
return data.assign(date=data['date'].apply(lambda x: str(x)[0:10]))
示例4: QA_fetch_get_index_min
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_index_min(code, start, end, frequence='1min', ip=None, port=None):
'指数分钟线'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
type_ = ''
start_date = str(start)[0:10]
today_ = datetime.date.today()
lens = QA_util_get_trade_gap(start_date, today_)
if str(frequence) in ['5', '5m', '5min', 'five']:
frequence, type_ = 0, '5min'
lens = 48 * lens
elif str(frequence) in ['1', '1m', '1min', 'one']:
frequence, type_ = 8, '1min'
lens = 240 * lens
elif str(frequence) in ['15', '15m', '15min', 'fifteen']:
frequence, type_ = 1, '15min'
lens = 16 * lens
elif str(frequence) in ['30', '30m', '30min', 'half']:
frequence, type_ = 2, '30min'
lens = 8 * lens
elif str(frequence) in ['60', '60m', '60min', '1h']:
frequence, type_ = 3, '60min'
lens = 4 * lens
if lens > 20800:
lens = 20800
with api.connect(ip, port):
if str(code)[0] in ['5', '1']: # ETF
data = pd.concat([api.to_df(api.get_security_bars(
frequence, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (int(lens / 800) - i) * 800, 800)) for i in range(int(lens / 800) + 1)], axis=0)
else:
data = pd.concat([api.to_df(api.get_index_bars(
frequence, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (int(lens / 800) - i) * 800, 800)) for i in range(int(lens / 800) + 1)], axis=0)
data = data\
.assign(datetime=pd.to_datetime(data['datetime']), code=str(code))\
.drop(['year', 'month', 'day', 'hour', 'minute'], axis=1, inplace=False)\
.assign(code=code)\
.assign(date=data['datetime'].apply(lambda x: str(x)[0:10]))\
.assign(date_stamp=data['datetime'].apply(lambda x: QA_util_date_stamp(x)))\
.assign(time_stamp=data['datetime'].apply(lambda x: QA_util_time_stamp(x)))\
.assign(type=type_).set_index('datetime', drop=False, inplace=False)[start:end]
# data
return data.assign(datetime=data['datetime'].apply(lambda x: str(x)))
示例5: QA_fetch_get_stock_info
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_info(code, ip=None, port=None):
'股票基本信息'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
market_code = _select_market_code(code)
with api.connect(ip, port):
return api.to_df(api.get_finance_info(market_code, code))
示例6: QA_fetch_get_stock_transaction_realtime
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_transaction_realtime(code, ip=None, port=None):
'实时分笔成交 包含集合竞价 buyorsell 1--sell 0--buy 2--盘前'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
try:
with api.connect(ip, port):
data = pd.DataFrame()
data = pd.concat([api.to_df(api.get_transaction_data(
_select_market_code(str(code)), code, (2 - i) * 2000, 2000)) for i in range(3)], axis=0)
if 'value' in data.columns:
data = data.drop(['value'], axis=1)
data = data.dropna()
day = datetime.date.today()
return data.assign(date=str(day)).assign(datetime=pd.to_datetime(data['time'].apply(lambda x: str(day) + ' ' + str(x))))\
.assign(code=str(code)).assign(order=range(len(data.index))).set_index('datetime', drop=False, inplace=False)
except:
return None
示例7: QA_fetch_get_stock_xdxr
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_xdxr(code, ip=None, port=None):
'除权除息'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
market_code = _select_market_code(code)
with api.connect(ip, port):
category = {
'1': '除权除息', '2': '送配股上市', '3': '非流通股上市', '4': '未知股本变动', '5': '股本变化',
'6': '增发新股', '7': '股份回购', '8': '增发新股上市', '9': '转配股上市', '10': '可转债上市',
'11': '扩缩股', '12': '非流通股缩股', '13': '送认购权证', '14': '送认沽权证'}
data = api.to_df(api.get_xdxr_info(market_code, code))
if len(data) >= 1:
data = data\
.assign(date=pd.to_datetime(data[['year', 'month', 'day']]))\
.drop(['year', 'month', 'day'], axis=1)\
.assign(category_meaning=data['category'].apply(lambda x: category[str(x)]))\
.assign(code=str(code))\
.rename(index=str, columns={'panhouliutong': 'liquidity_after',
'panqianliutong': 'liquidity_before', 'houzongguben': 'shares_after',
'qianzongguben': 'shares_before'})\
.set_index('date', drop=False, inplace=False)
return data.assign(date=data['date'].apply(lambda x: str(x)[0:10]))
else:
return None
示例8: QA_fetch_get_index_day
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_index_day(code, start_date, end_date, frequence='day', ip=None, port=None):
'指数日线'
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
if frequence in ['day', 'd', 'D', 'DAY', 'Day']:
frequence = 9
elif frequence in ['w', 'W', 'Week', 'week']:
frequence = 5
elif frequence in ['month', 'M', 'm', 'Month']:
frequence = 6
elif frequence in ['Q', 'Quarter', 'q']:
frequence = 10
elif frequence in ['y', 'Y', 'year', 'Year']:
frequence = 11
with api.connect(ip, port):
start_date = str(start_date)[0:10]
today_ = datetime.date.today()
lens = QA_util_get_trade_gap(start_date, today_)
if str(code)[0] in ['5', '1']: # ETF
data = pd.concat([api.to_df(api.get_security_bars(
frequence, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (int(lens / 800) - i) * 800, 800)) for i in range(int(lens / 800) + 1)], axis=0)
else:
data = pd.concat([api.to_df(api.get_index_bars(
frequence, 1 if str(code)[0] in ['0', '8', '9', '5'] else 0, code, (int(lens / 800) - i) * 800, 800)) for i in range(int(lens / 800) + 1)], axis=0)
data = data.assign(date=data['datetime'].apply(lambda x: str(x[0:10]))).assign(code=str(code))\
.assign(date_stamp=data['datetime'].apply(lambda x: QA_util_date_stamp(str(x)[0:10])))\
.set_index('date', drop=False, inplace=False)\
.assign(code=code)\
.drop(['year', 'month', 'day', 'hour',
'minute', 'datetime'], axis=1)[start_date:end_date]
return data.assign(date=data['date'].apply(lambda x: str(x)[0:10]))
示例9: QA_fetch_get_stock_realtime
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_realtime(code=['000001', '000002'], ip=best_ip, port=7709):
api = TdxHq_API()
__data = pd.DataFrame()
with api.connect(ip, port):
code = [code] if type(code) is str else code
for id_ in range(int(len(code) / 80) + 1):
__data = __data.append(api.to_df(api.get_security_quotes(
[(__select_market_code(x), x) for x in code[80 * id_:80 * (id_ + 1)]])))
__data['datetime'] = datetime.datetime.now()
data = __data[['datetime', 'code', 'open', 'high', 'low', 'price']]
return data.set_index('code', drop=False, inplace=False)
示例10: QA_fetch_get_stock_latest
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_latest(code, ip=best_ip, port=7709):
code = [code] if isinstance(code, str) else code
api = TdxHq_API(multithread=True)
with api.connect(ip, port):
data = pd.concat([api.to_df(api.get_security_bars(
9, __select_market_code(item), item, 0, 1)).assign(code=item) for item in code], axis=0)
return data\
.assign(date=pd.to_datetime(data['datetime']
.apply(lambda x: x[0:10])), date_stamp=data['datetime']
.apply(lambda x: QA_util_date_stamp(str(x[0:10]))))\
.set_index('date', drop=False)\
.drop(['year', 'month', 'day', 'hour', 'minute', 'datetime'], axis=1)
示例11: QA_fetch_get_stock_list
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_list(type_='stock', ip=best_ip, port=7709):
api = TdxHq_API()
with api.connect(ip, port):
data = pd.concat([pd.concat([api.to_df(api.get_security_list(j, i * 1000)).assign(sse='sz' if j == 0 else 'sh').set_index(
['code', 'sse'], drop=False) for i in range(int(api.get_security_count(j) / 1000) + 1)], axis=0) for j in range(2)], axis=0)
if type_ in ['stock', 'gp']:
return pd.concat([data[data['sse'] == 'sz'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 10000 <= 30][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 100000 != 2],
data[data['sse'] == 'sh'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 100000 == 6]]).assign(code=data['code'].apply(lambda x: str(x)))
elif type_ in ['index', 'zs']:
return pd.concat([data[data['sse'] == 'sz'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 1000 >= 399],
data[data['sse'] == 'sh'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 1000 == 0]]).sort_index().assign(code=data['code'].apply(lambda x: str(x)))
elif type_ in ['etf', 'ETF']:
return pd.concat([data[data['sse'] == 'sz'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 10000 == 15],
data[data['sse'] == 'sh'][data.assign(code=data['code'].apply(lambda x: int(x)))['code'] // 10000 == 51]]).sort_index().assign(code=data['code'].apply(lambda x: str(x)))
else:
return data.assign(code=data['code'].apply(lambda x: str(x)))
示例12: QA_fetch_get_security_bars
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_security_bars(code, _type, lens, ip=None, port=None):
"""按bar长度推算数据
Arguments:
code {[type]} -- [description]
_type {[type]} -- [description]
lens {[type]} -- [description]
Keyword Arguments:
ip {[type]} -- [description] (default: {best_ip})
port {[type]} -- [description] (default: {7709})
Returns:
[type] -- [description]
"""
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
with api.connect(ip, port):
data = pd.concat([api.to_df(api.get_security_bars(_select_type(_type), _select_market_code(
code), code, (i - 1) * 800, 800)) for i in range(1, int(lens / 800) + 2)], axis=0)
data = data\
.assign(datetime=pd.to_datetime(data['datetime']), code=str(code))\
.drop(['year', 'month', 'day', 'hour', 'minute'], axis=1, inplace=False)\
.assign(date=data['datetime'].apply(lambda x: str(x)[0:10]))\
.assign(date_stamp=data['datetime'].apply(lambda x: QA_util_date_stamp(x)))\
.assign(time_stamp=data['datetime'].apply(lambda x: QA_util_time_stamp(x)))\
.assign(type=_type).set_index('datetime', drop=False, inplace=False).tail(lens)
if data is not None:
return data
else:
return None
示例13: QA_fetch_get_stock_latest
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_latest(code, ip=None, port=None):
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
code = [code] if isinstance(code, str) else code
api = TdxHq_API(multithread=True)
with api.connect(ip, port):
data = pd.concat([api.to_df(api.get_security_bars(
9, _select_market_code(item), item, 0, 1)).assign(code=item) for item in code], axis=0)
return data\
.assign(date=pd.to_datetime(data['datetime']
.apply(lambda x: x[0:10])), date_stamp=data['datetime']
.apply(lambda x: QA_util_date_stamp(str(x[0:10]))))\
.set_index('date', drop=False)\
.drop(['year', 'month', 'day', 'hour', 'minute', 'datetime'], axis=1)
示例14: QA_fetch_depth_market_data
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_depth_market_data(code=['000001', '000002'], ip=None, port=None):
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
__data = pd.DataFrame()
with api.connect(ip, port):
code = [code] if type(code) is str else code
for id_ in range(int(len(code) / 80) + 1):
__data = __data.append(api.to_df(api.get_security_quotes(
[(_select_market_code(x), x) for x in code[80 * id_:80 * (id_ + 1)]])))
__data['datetime'] = datetime.datetime.now()
data = __data[['datetime', 'active1', 'active2', 'last_close', 'code', 'open', 'high', 'low', 'price', 'cur_vol',
's_vol', 'b_vol', 'vol', 'ask1', 'ask_vol1', 'bid1', 'bid_vol1', 'ask2', 'ask_vol2',
'bid2', 'bid_vol2', 'ask3', 'ask_vol3', 'bid3', 'bid_vol3', 'ask4',
'ask_vol4', 'bid4', 'bid_vol4', 'ask5', 'ask_vol5', 'bid5', 'bid_vol5']]
return data.set_index(['datetime', 'code'], drop=False, inplace=False)
示例15: QA_fetch_get_stock_list
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import to_df [as 别名]
def QA_fetch_get_stock_list(type_='stock', ip=None, port=None):
global best_ip
if ip is None and port is None and best_ip['stock']['ip'] is None and best_ip['stock']['port'] is None:
best_ip = select_best_ip()
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
elif ip is None and port is None and best_ip['stock']['ip'] is not None and best_ip['stock']['port'] is not None:
ip = best_ip['stock']['ip']
port = best_ip['stock']['port']
else:
pass
api = TdxHq_API()
with api.connect(ip, port):
data = pd.concat([pd.concat([api.to_df(api.get_security_list(j, i * 1000)).assign(sse='sz' if j == 0 else 'sh').set_index(
['code', 'sse'], drop=False) for i in range(int(api.get_security_count(j) / 1000) + 1)], axis=0) for j in range(2)], axis=0)
#data.code = data.code.apply(int)
sz = data.query('sse=="sz"')
sh = data.query('sse=="sh"')
sz = sz.assign(sec=sz.code.apply(for_sz))
sh = sh.assign(sec=sh.code.apply(for_sh))
if type_ in ['stock', 'gp']:
return pd.concat([sz, sh]).query('sec=="stock_cn"').sort_index().assign(name=data['name'].apply(lambda x: str(x)[0:6]))
elif type_ in ['index', 'zs']:
return pd.concat([sz, sh]).query('sec=="index_cn"').sort_index().assign(name=data['name'].apply(lambda x: str(x)[0:6]))
#.assign(szm=data['name'].apply(lambda x: ''.join([y[0] for y in lazy_pinyin(x)])))\
#.assign(quanpin=data['name'].apply(lambda x: ''.join(lazy_pinyin(x))))
elif type_ in ['etf', 'ETF']:
return pd.concat([sz, sh]).query('sec=="etf_cn"').sort_index().assign(name=data['name'].apply(lambda x: str(x)[0:6]))
else:
return data.assign(code=data['code'].apply(lambda x: str(x))).assign(name=data['name'].apply(lambda x: str(x)[0:6]))