unlimited - - 判断查询日是否无涨跌停限制(1:该日无涨跌停限制;0:该日有涨跌停限制)(numpy.int64)(仅日线返回);
unlimited 是 PTrade 文档中的- 判断查询日是否无涨跌停限制(1:该日无涨跌停限制;0:该日有涨跌停限制)(numpy.int64)(仅日线返回);参考条目。
条目定义
类型: 对象属性与字段定义
官方名称: unlimited
本条目不是独立可调用函数,用于说明对象属性、数据字段、枚举、日志或平台约定。
释义
unlimited 是 PTrade 文档中的- 判断查询日是否无涨跌停限制(1:该日无涨跌停限制;0:该日有涨跌停限制)(numpy.int64)(仅日线返回);参考条目。
研究:官方目录未明确;回测:官方目录未明确;模拟:官方目录未明确;实盘:官方目录未明确。
参数
本条目没有独立函数参数。字段、取值或对象属性请查看下方官方详细说明。
返回值
本条目不是独立可调用函数,没有单独返回值。
示例
def initialize(context):
g.security = '600570.SS'
set_universe(g.security)
def handle_data(context, data):
# 获得600570.SS(恒生电子)的2015年01月的天数据,只获取open字段
price_open = get_price('600570.SS', start_date='20150101', end_date='20150131', frequency='1d')['open']
log.info(price_open)
# 获取指定结束日期前count天到结束日期的所有开盘数据
# price_open = get_price('600570.SS', end_date='20150131', frequency='daily', count=10)['open']
# log.info(price_open)
# 获取股票指定结束时间前count分钟到指定结束时间的所有数据
# stock_info = get_price('600570.SS', end_date='2015-01-31 10:00', frequency='1m', count=10)
# log.info(stock_info)
# 获取指定结束日期前count周到结束日期所在周的所有开盘数据
# week_open = get_price('600570.SS', end_date='20150131', frequency='1w', count=10)['open']
# log.info(week_open)
# 获取多只股票
# 获取沪深300的2015年1月的天数据,返回一个[pandas.DataFrame]
security_list = get_index_stocks('000300.XBHS', '20150101')
price = get_price(security_list, start_date='20150101', end_date='20150131')
log.info(price)
# 获取某股票开盘价,行索引是[datetime.datetime]对象,列索引是行情字段
price_open = price.query('code in [@security_list[0]]')['open']
log.info(price_open)
# 获取农业版块指定结束日期前count天到结束日期的数据
industry_info = get_price("A01000.XBHS", end_date="20210315", frequency="daily", count=10)
log.info(industry_info)
详细说明
fq:数据复权选项,支持包括,pre-前复权,post-后复权,dypre-动态前复权,None-不复权(str);
count:大于0,不能与start_date同时输入,获取end_date前count根的数据,不支持除天('daily'/'1d')、分钟('1m')、5分钟线('5m')、15分钟线('15m')、30分钟线('30m')、60分钟线('60m')、120分钟线('120m')、周('weekly'/'1w')、('monthly'/'mo')、('quarter'/'1q')和('yearly'/'1y')以外的其它频率(int);
is_dict:返回是否是字典(dict)格式{str: array()},True -是,False-不是;选填参数,默认为False;返回为字典格式取数速度相对较快,入参类型:bool;
返回值
dict类型
正常返回dict类型数据,异常时返回None(NoneType)。
OrderedDict([(股票代码(str), array([日期时间(numpy.int64), 开盘价(numpy.float64), 最高价(numpy.float64), 最低价(numpy.float64), 收盘价(numpy.float64), 成交量(numpy.float64), 成交额(numpy.float64), 最新价(numpy.float64)]]))])
OrderedDict([('600570.SS', array([(201706010931, 37.1, 37.14, 37.05, 37.09, 128200.0, 4756263.0, 37.09),...]))])
非dict类型
get_price对于多股票和多字段不同场景下获取返回数据的规则与get_history一致,如下:
(python3.5、python3.11版本均支持)第一种返回数据:
当获取单支股票(单只股票必须为字符串类型security='600570.SS',不能用security=['600570.SS'])和单个或多个字段的时候,返回的是pandas.DataFrame对象,行索引是datetime.datetime对象,列索引是行情字段,为str类型。
例如,输入为get_price(security='600570.SS',start_date='20170201',end_date='20170213',frequency='1d')时,将返回:
open high low close volume money price is_open preclose high_limit low_limit unlimited
2017-02-03 44.47 44.50 43.58 43.90 4418325.0 193895820.0 43.90 1 44.26 48.69 39.83 0
2017-02-06 43.91 44.30 43.66 44.10 4428487.0 194979290.0 44.10 1 43.90 48.29 39.51 0
2017-02-07 44.05 44.07 43.34 43.52 5649251.0 246776480.0 43.52 1 44.10 48.51 39.69 0
2017-02-08 43.59 44.78 43.53 44.59 12570233.0 557883600.0 44.59 1 43.52 47.87 39.17 0
2017-02-09 44.74 45.28 44.39 44.74 9240223.0 413875390.0 44.74 1 44.59 49.05 40.13 0
2017-02-10 44.80 44.98 44.41 44.62 8097465.0 361757300.0 44.62 1 44.74 49.21 40.27 0
2017-02-13 44.32 45.98 44.02 44.89 14931596.0 672360490.0 44.89 1 44.62 49.08 40.16 0
(仅python3.11版本支持)第二种返回数据:
当获取多支股票(多只股票必须为list类型,特殊情况:当list只有一个股票时仍然当做多股票处理,比如security=['600570.SS'])时候,返回的是pandas.DataFrame对象,行索引是datetime.datetime对象,列索引是股票代码code和取的字段,为str类型。
例如,输入为get_price(['600570.SS'], start_date='20170201', end_date='20170213', frequency='1d', fields='open')时,将返回:
code open
2017-02-03 600570.SS 44.47
2017-02-06 600570.SS 43.91
2017-02-07 600570.SS 44.05
2017-02-08 600570.SS 43.59
2017-02-09 600570.SS 44.74
2017-02-10 600570.SS 44.80
2017-02-13 600570.SS 44.32
例如,输入为get_price(['600570.SS','600571.SS'], start_date='20170201', end_date='20170213', frequency='1d', fields=['open','close'])[['code', 'open']]时,将返回:
code open
2017-02-03 600570.SS 44.47
2017-02-06 600570.SS 43.91
2017-02-07 600570.SS 44.05
2017-02-08 600570.SS 43.59
2017-02-09 600570.SS 44.74
2017-02-10 600570.SS 44.80
2017-02-13 600570.SS 44.32
2017-02-03 600571.SS 19.36
2017-02-06 600571.SS 19.00
2017-02-07 600571.SS 19.27
2017-02-08 600571.SS 19.10
2017-02-09 600571.SS 19.47
2017-02-10 600571.SS 19.57
2017-02-13 600571.SS 19.22
假如要对获取查询多只代码种某单只代码或多只代码的数据,可以通过x.query('code in ["xxxxxx.SS"]')的方法获取。
(仅python3.5版本支持)第三种返回数据:
当获取多支股票(多只股票必须为list类型,特殊情况:当list只有一个股票时仍然当做多股票处理,比如security=['600570.SS'])和单个字段的时候,返回的是pandas.DataFrame对象,行索引是datetime.datetime对象,列索引是股票代码的编号,为str类型。
例如,输入为get_price(['600570.SS'], start_date='20170201', end_date='20170213', frequency='1d', fields='open')时,将返回:
600570.SS
2017-02-03 44.47
2017-02-06 43.91
2017-02-07 44.05
2017-02-08 43.59
2017-02-09 44.74
2017-02-10 44.80
2017-02-13 44.32
(仅python3.5版本支持)第四种返回数据:
如果是获取多支股票(多只股票必须为list类型,特殊情况:当list只有一个股票时仍然当做多股票处理,比如security=['600570.SS'])和多个字段,则返回pandas.Panel对象,items索引是行情字段,为str类型(如'open'、'close'等),里面是很多pandas.DataFrame对象,每个pandas.DataFrame的行索引是datetime.datetime对象, 列索引是股票代码,为str类型。
例如,输入为get_price(['600570.SS','600571.SS'], start_date='20170201', end_date='20170213', frequency='1d', fields=['open','close'])['open']时,将返回:
600570.SS 600571.SS
2017-02-03 44.47 19.36
2017-02-06 43.91 19.00
2017-02-07 44.05 19.27
2017-02-08 43.59 19.10
2017-02-09 44.74 19.47
2017-02-10 44.80 19.57
2017-02-13 44.32 19.22
假如要对panel索引中的对象进行转换,比如将items索引由行情字段转换成股票代码,可以通过panel_info = panel_info.swapaxes("minor_axis", "items")的方法转换。