本文整理汇总了Python中pytdx.hq.TdxHq_API.get_xdxr_info方法的典型用法代码示例。如果您正苦于以下问题:Python TdxHq_API.get_xdxr_info方法的具体用法?Python TdxHq_API.get_xdxr_info怎么用?Python TdxHq_API.get_xdxr_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytdx.hq.TdxHq_API
的用法示例。
在下文中一共展示了TdxHq_API.get_xdxr_info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QA_fetch_get_stock_xdxr
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import get_xdxr_info [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
示例2: test_all_functions
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import get_xdxr_info [as 别名]
def test_all_functions(multithread, heartbeat, auto_retry, raise_exception):
api = TdxHq_API(multithread=multithread, heartbeat=heartbeat,
auto_retry=auto_retry, raise_exception=raise_exception)
with api.connect(time_out=30):
log.info("获取股票行情")
stocks = api.get_security_quotes([(0, "000001"), (1, "600300")])
assert stocks is not None
assert type(stocks) is list
# 方法2
stocks = api.get_security_quotes(0, "000001")
assert stocks is not None
assert type(stocks) is list
# 方法3
stocks = api.get_security_quotes((0, "000001"))
assert stocks is not None
assert type(stocks) is list
log.info("获取k线")
data = api.get_security_bars(9, 0, '000001', 4, 3)
assert data is not None
assert type(data) is list
assert len(data) == 3
log.info("获取 深市 股票数量")
assert api.get_security_count(0) > 0
log.info("获取股票列表")
stocks = api.get_security_list(1, 0)
assert stocks is not None
assert type(stocks) is list
assert len(stocks) > 0
log.info("获取指数k线")
data = api.get_index_bars(9, 1, '000001', 1, 2)
assert data is not None
assert type(data) is list
assert len(data) == 2
log.info("查询分时行情")
data = api.get_minute_time_data(TDXParams.MARKET_SH, '600300')
assert data is not None
log.info("查询历史分时行情")
data = api.get_history_minute_time_data(
TDXParams.MARKET_SH, '600300', 20161209)
assert data is not None
assert type(data) is list
assert len(data) > 0
log.info("查询分时成交")
data = api.get_transaction_data(TDXParams.MARKET_SZ, '000001', 0, 30)
assert data is not None
assert type(data) is list
log.info("查询历史分时成交")
data = api.get_history_transaction_data(
TDXParams.MARKET_SZ, '000001', 0, 10, 20170209)
assert data is not None
assert type(data) is list
assert len(data) == 10
log.info("查询公司信息目录")
data = api.get_company_info_category(TDXParams.MARKET_SZ, '000001')
assert data is not None
assert type(data) is list
assert len(data) > 0
start = data[0]['start']
length = data[0]['length']
log.info("读取公司信息-最新提示")
data = api.get_company_info_content(
0, '000001', '000001.txt', start, length)
assert data is not None
assert len(data) > 0
log.info("读取除权除息信息")
data = api.get_xdxr_info(1, '600300')
assert data is not None
assert type(data) is list
assert len(data) > 0
log.info("读取财务信息")
data = api.get_finance_info(0, '000001')
assert data is not None
assert type(data) is OrderedDict
assert len(data) > 0
log.info("日线级别k线获取函数")
data = api.get_k_data('000001', '2017-07-01', '2017-07-10')
assert type(data) is pd.DataFrame
assert len(data) == 6
log.info("获取板块信息")
data = api.get_and_parse_block_info(TDXParams.BLOCK_FG)
assert data is not None
assert type(data) is list
#.........这里部分代码省略.........
示例3: get_category_name
# 需要导入模块: from pytdx.hq import TdxHq_API [as 别名]
# 或者: from pytdx.hq.TdxHq_API import get_xdxr_info [as 别名]
)
rows.append(row)
return rows
def get_category_name(self, category_id):
if category_id in XDXR_CATEGORY_MAPPING:
return XDXR_CATEGORY_MAPPING[category_id]
else:
return str(category_id)
if __name__ == '__main__':
from pytdx.util.best_ip import select_best_ip
from pytdx.hq import TdxHq_API
api = TdxHq_API()
with api.connect():
# 11 扩缩股
print(api.to_df(api.get_xdxr_info(1, '600381')))
# 12 非流通股缩股
#print(api.to_df(api.get_xdxr_info(1, '600339')))
# 13 送认购权证
#print(api.to_df(api.get_xdxr_info(1, '600008')))
# 14 送认沽权证
#print(api.to_df(api.get_xdxr_info(0, '000932')))