杂项或辅助¶
函数¶
- hikyuu.select()¶
示例:
#选出涨停股 C = CLOSE() x = select(C / REF(C, 1) - 1 >= 0.0995))
- hikyuu.hku_save(var, filename)¶
序列化,将hikyuu内建类型的变量(如Stock、TradeManager等)保存在指定的文件中,格式为XML。
- 参数:
var – hikyuu内建类型的变量
filename (str) – 指定的文件名
- hikyuu.hku_load(var, filename)¶
将通过 hku_save 保存的变量,读取到var中。
- 参数:
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.getDateRange(start, end)¶
获取指定 [start, end) 日期时间范围的自然日日历日期列表,仅支持到日
- 参数:
- 返回类型:
- hikyuu.toPriceList(arg)¶
将Python的可迭代对象如 list、tuple 转化为 PriceList
- 参数:
arg – 待转化的Python序列
- 返回类型:
- 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