%matplotlib inline
%time from hikyuu.interactive import *
warning: can't import TA-Lib, will be ignored! You can fetch ta-lib from https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib std::cout are redirected to python::stdout std::cerr are redirected to python::stderr 2023-10-14 02:23:39.222 [HKU-I] - Using SQLITE3 BaseInfoDriver (BaseInfoDriver.cpp:58) 2023-10-14 02:23:39.223 [HKU-I] - Loading market information... (StockManager.cpp:499) 2023-10-14 02:23:39.223 [HKU-I] - Loading stock type information... (StockManager.cpp:512) 2023-10-14 02:23:39.223 [HKU-I] - Loading stock information... (StockManager.cpp:426) 2023-10-14 02:23:39.275 [HKU-I] - Loading stock weight... (StockManager.cpp:529) 2023-10-14 02:23:39.634 [HKU-I] - Loading KData... (StockManager.cpp:134) 2023-10-14 02:23:39.638 [HKU-I] - Preloading all day kdata to buffer! (StockManager.cpp:157) 2023-10-14 02:23:39.639 [HKU-I] - Preloading all week kdata to buffer! (StockManager.cpp:160) 2023-10-14 02:23:39.639 [HKU-I] - Preloading all month kdata to buffer! (StockManager.cpp:163) 2023-10-14 02:23:39.651 [HKU-I] - 0.02s Loaded Data. (StockManager.cpp:145) Wall time: 1.09 s
使用 create_figure 函数快速创建查看证券K线信息的常见组合窗口
help(create_figure)
Help on function create_figure in module hikyuu.draw.drawplot: create_figure(n=1, figsize=None) 生成含有指定坐标轴数量的窗口,最大只支持4个坐标轴。 :param int n: 坐标轴数量 :param figsize: (宽, 高) :return: (ax1, ax2, ...) 根据指定的坐标轴数量而定,超出[1,4]个坐标轴时,返回None
#不同坐标轴数量,其显示窗口布局
create_figure(figsize=(6,4))
create_figure(2, figsize=(6,4))
create_figure(3, figsize=(6,4))
create_figure(4, figsize=(6,4))
(<Axes: >, <Axes: >, <Axes: >, <Axes: >)
s = sm['sh000001']
k = s.get_kdata(Query(-200))
#创建两个显示坐标轴的窗口
ax1,ax2 = create_figure(2)
#在第一个坐标轴中绘制K线和EMA
k.plot(axes=ax1)
ma = EMA(CLOSE(k))
ma.plot(axes=ax1, legend_on=True)
#在第二个坐标轴中绘制艾尔德力度指标
v = VIGOR(k)
v.plot(axes=ax2, legend_on=True)
ax1,ax2, ax3 = create_figure(3)
k.plot(axes=ax1)
ma.plot(axes=ax1, legend_on=True)
ax_draw_macd(axes=ax2, kdata=k)
ax_draw_macd2(axes=ax3, ref=ma, kdata=k)
D:\workspace\hikyuu\hikyuu\draw\drawplot\matplotlib_draw.py:363: UserWarning: linestyle is redundantly defined by the 'linestyle' keyword argument and the fmt string "-" (-> linestyle='-'). The keyword argument will take precedence. axes.plot(py_indicatr, '-', label=label, *args, **kwargs)
el.draw(s)
vl.draw(s)
vl.draw2(s)
2023-10-14 02:23:43,032 [WARNING] No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument. [matplotlib.legend::_parse_legend_args]
kf.draw(s)
kf.draw2(blocka)