杂项或辅助
函数
- hikyuu.select(cond, start=Datetime(201801010000), end=Datetime.now(), print_out=True)
示例:
#选出涨停股 C = CLOSE() x = select(C / REF(C, 1) - 1 >= 0.0995)
- hikyuu.select2(inds, start=Datetime(201801010000), end=Datetime.now(), stks=None)
导出最后时刻指定证券的所有指定指标值
- 如:
select2([CLOSE(), VOLUME()], stks=blocka)
- 返回一个DataFrame, 列名是指标名称, 行是证券代码和证券名称:
证券代码 证券名称 CLOSE VOLUME SH600000 浦发银行 14.09 1000 SH600001 中国平安 13.09 2000 SZ000001 平安银行 13.09 3000 ...
- hikyuu.hku_save(var, filename)
序列化,将hikyuu内建类型的变量(如Stock、TradeManager等)保存在指定的文件中,格式为XML。
- 参数:
var -- hikyuu内建类型的变量
filename (str) -- 指定的文件名
- hikyuu.hku_load(filename)
将通过 hku_save 保存的变量,读取到var中。
- 参数:
filename (str) -- 待载入的序列化文件。
- 返回:
之前被序列化保存的文件
- hikyuu.roundUp(arg1[, arg2=0])
向上截取,如10.1截取后为11
- 参数:
arg1 (float) -- 待处理数据
arg2 (int) -- 保留小数位数
- 返回:
处理过的数据
- hikyuu.roundDown(arg1[, arg2=0])
向下截取,如10.1截取后为10
- 参数:
arg1 (float) -- 待处理数据
arg2 (int) -- 保留小数位数
- 返回:
处理过的数据
- hikyuu.get_date_range(start, end)
获取指定 [start, end) 日期时间范围的自然日日历日期列表,仅支持到日
- 参数:
- 返回类型:
- hikyuu.toPriceList(arg)
将Python的可迭代对象如 list、tuple 转化为 PriceList(该函数实际已废弃,可以不再使用)
- 参数:
arg -- 待转化的Python序列
- 返回类型:
list
- hikyuu.set_global_context(stk, query)
设置全局的 context
类
- class hikyuu.Parameter
参数类
- get(self, name)
获取指定参数
- 参数:
name (str) -- 参数名称
- 返回:
参数值
- set(self, name, value)
设置参数
- 参数:
name (str) -- 参数名称
value -- 参数值(仅支持 int | float | str | bool 类型)
- class hikyuu.PriceList
价格序列,其中价格使用double表示,对应C++中的std::vector<double>。
- to_np(self)
仅在安装了numpy模块时生效,转换为numpy.array
- to_df(self)
仅在安装了pandas模块时生效,转换为pandas.DataFrame
- class hikyuu.DatetimeList
日期序列,对应C++中的std::vector<Datetime>
- to_np(self)
仅在安装了numpy模块时生效,转换为numpy.array
- to_df(self)
仅在安装了pandas模块时生效,转换为pandas.DataFrame
- class hikyuu.StringList
字符串列表,对应C++中的std::vector<String>
- class hikyuu.KRecordList
C++ std::vector<KRecord>包装
- to_np(self)
仅在安装了numpy模块时生效,转换为numpy.array
- to_df(self)
仅在安装了pandas模块时生效,转换为pandas.DataFrame
- class hikyuu.BlockList
C++ std::vector<Block>包装
- class hikyuu.OstreamRedirect
重定向C++ std::cout、std::cerr至python。在非命令行方式下,某些App无法显示C++ iostream的输出信息,如Jupyter notebook。默认构造时,只是指定是否需要重定向std::cout或std::cerr,必须使用open方法或with语法才会启用重定向。
使用with示例:
with OstreamRedirect(): your_function() #被封装的C++函数,其中使用了std::iostream输出
- init(self[, stdout=True, stderr=True])
- 参数:
stdout (bool) -- 是否重定向C++ std::cout
stderr (bool) -- 是否重定向C++ std::cerr
- open(self)
启用重定向
- close(self)
关闭重定向
枚举
- class hikyuu.LOG_LEVEL
DEBUG
TRACE
INFO
WARN
ERROR
FATAL
NO_PRINT