How to use the hikyuu.indicator.CVAL function in hikyuu

To help you get started, we’ve selected a few hikyuu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
sg = SG_Single(cama, filter_n = filter_n, filter_p = filter_p)
        sg.plot(axes = ax1, kdata = kdata)

    else:
        print("sg_type only in ('CORSS', 'SINGLE')")
 
    cer = PRICELIST(cama, 1)
    label = "ER(%s)" % cer[-1]
    cer.plot(axes=ax2, color='b', marker='o', label=label, 
             legend_on=False, text_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(0,0,len(kdata))
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
sg = SG_Single(cama, filter_n = filter_n, filter_p = filter_p)
        sg.plot(axes = ax1, kdata = kdata)

    else:
        print("sg_type only in ('CORSS', 'SINGLE')")
        
    a = POS(block, query, SG_Flex(AMA(n = 3), 6))
    a.name = "POS(3)"
    a.plot(axes=ax2, color='b', marker='.', legend_on=True)
    a = POS(block, query, SG_Flex(AMA(n = 30), 60))
    a.name = "POS(30)"
    a.plot(axes=ax2, color='g', marker='.', legend_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0.2, total).plot(axes=ax2,color='r',linestyle='--')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(0.2,0,len(kdata),color='r',linestyle='--')
    
    if ama1.name == "AMA":
        cer = PRICELIST(cama, 1)
        label = "ER(%s)" % cer[-1]
        cer.plot(axes=ax3, color='b', marker='.', label=label, 
                 legend_on=False, text_on=True)
        CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
        #ax3.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
        #ax3.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(0,0,len(kdata))
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
ind.plot(axes = ax1, color = 'm', legend_on = True)
                 
    elif sg_type == 'SINGLE':
        sg = SG_Single(cama, filter_n = filter_n, filter_p = filter_p)
        sg.plot(axes = ax1, kdata = kdata)

    else:
        print("sg_type only in ('CORSS', 'SINGLE')")
 
    cer = PRICELIST(cama, 1)
    label = "ER(%s)" % cer[-1]
    cer.plot(axes=ax2, color='b', marker='o', label=label, 
             legend_on=False, text_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(0,0,len(kdata))
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / tools / hikyuu / interactive / elder.py View on Github external
#ax1.legend(loc='upper left')
    
    ax_draw_macd2(ax2, ema, kdata)
    
    vigor.plot(axes=ax3, marker='.', color='r', zero_on=True, 
               legend_on=False, text_on=True)
    u = [i for i in vigor if i > 0 and i != constant.null_price]
    l = [i for i in vigor if i < 0]
    umean = mean(u)
    umax = max(u)
    lmean = mean(l)
    lmin = min(l)
    up = int(umax / umean)
    lp = int(lmin / lmean)
    for i in range(up):
        CVAL(umean * (i + 1), len(kdata)).plot(axes=ax3, color='r', linestyle='--')
        #ax3.hlines(umean * (i + 1),0,len(kdata),color='r',linestyle='--')
        
    for i in range(lp):
        CVAL(lmean * (i + 1), len(kdata)).plot(axes=ax3, color='g', linestyle='--')
        #ax3.hlines(lmean * (i + 1),0,len(kdata),color='g',linestyle='--')    
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), kdata.getQuery().kType)
    adjust_axes_show([ax1, ax2, ax3])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0.2, total).plot(axes=ax2,color='r',linestyle='--')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(0.2,0,len(kdata),color='r',linestyle='--')
    
    if ama1.name == "AMA":
        cer = PRICELIST(cama, 1)
        label = "ER(%s)" % cer[-1]
        cer.plot(axes=ax3, color='b', marker='.', label=label, 
                 legend_on=False, text_on=True)
        CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
        #ax3.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
        #ax3.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(0,0,len(kdata))
    else:
        ax_draw_macd(ax2, kdata)
    #ax2.set_ylim(-1, 1)
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / volume.py View on Github external
y2 = [vol[i] for i in rg if kdata[i].closePrice <= kdata[i].openPrice]
        ax2.bar(x1, y1, width=0.4, color='r', edgecolor='r')
        ax2.bar(x2, y2, width=0.4, color='g', edgecolor='g')
    
    elif engine == 'echarts':
        vol.bar(axes=ax2, color='r')
    else:
        pass
    
    vma1 = MA(vol, vma1_n)
    vma2 = MA(vol, vma2_n)
    vma1.plot(axes=ax2, legend_on=True)
    vma2.plot(axes=ax2, legend_on=True)
    
    if query.kType == Query.WEEK and stock.market == 'SH' and stock.code=='000001':
        CVAL(0.16e+009, total, color='b',linestyle='--')
        #ax2.hlines(0.16e+009,0,len(kdata),color='b',linestyle='--')

    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), kdata.getQuery().kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
elif sg_type == 'SINGLE':
        sg = SG_Single(cama, filter_n = filter_n, filter_p = filter_p)
        sg.plot(axes = ax1, kdata = kdata)

    else:
        print("sg_type only in ('CORSS', 'SINGLE')")
 
    cer = PRICELIST(cama, 1)
    label = "ER(%s)" % cer[-1]
    cer.plot(axes=ax2, color='b', marker='o', label=label, 
             legend_on=False, text_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
    #ax2.hlines(0,0,len(kdata))
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
a.plot(axes=ax2, color='g', marker='.', legend_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0.2, total).plot(axes=ax2,color='r',linestyle='--')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(0.2,0,len(kdata),color='r',linestyle='--')
    
    if ama1.name == "AMA":
        cer = PRICELIST(cama, 1)
        label = "ER(%s)" % cer[-1]
        cer.plot(axes=ax3, color='b', marker='.', label=label, 
                 legend_on=False, text_on=True)
        CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
        #ax3.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
        #ax3.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(0,0,len(kdata))
    else:
        ax_draw_macd(ax2, kdata)
    #ax2.set_ylim(-1, 1)
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / tools / hikyuu / interactive / volume.py View on Github external
y2 = [vol[i] for i in rg if kdata[i].closePrice <= kdata[i].openPrice]
        ax2.bar(x1, y1, width=0.4, color='r', edgecolor='r')
        ax2.bar(x2, y2, width=0.4, color='g', edgecolor='g')
    
    elif engine == 'echarts':
        vol.bar(axes=ax2, color='r')
    else:
        pass
    
    vma1 = MA(vol, vma1_n)
    vma2 = MA(vol, vma2_n)
    vma1.plot(axes=ax2, legend_on=True)
    vma2.plot(axes=ax2, legend_on=True)
    
    if query.kType == Query.WEEK and stock.market == 'SH' and stock.code=='000001':
        CVAL(0.16e+009, total, color='b',linestyle='--')
        #ax2.hlines(0.16e+009,0,len(kdata),color='b',linestyle='--')

    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), kdata.getQuery().kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()
github fasiondog / hikyuu / hikyuu / interactive / kaufman.py View on Github external
a = POS(block, query, SG_Flex(AMA(n = 30), 60))
    a.name = "POS(30)"
    a.plot(axes=ax2, color='g', marker='.', legend_on=True)
    
    total = len(kdata)
    CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
    CVAL(0.2, total).plot(axes=ax2,color='r',linestyle='--')
    #ax2.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
    #ax2.hlines(0.2,0,len(kdata),color='r',linestyle='--')
    
    if ama1.name == "AMA":
        cer = PRICELIST(cama, 1)
        label = "ER(%s)" % cer[-1]
        cer.plot(axes=ax3, color='b', marker='.', label=label, 
                 legend_on=False, text_on=True)
        CVAL(0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.6, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(-0.8, total).plot(axes=ax2,color='r',linestyle='--')
        CVAL(0, total).plot(axes=ax2,color='k',linestyle='-')
        #ax3.hlines(0.8,0,len(kdata),color='r',linestyle='--')    
        #ax3.hlines(-0.6,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(-0.8,0,len(kdata),color='r',linestyle='--')
        #ax3.hlines(0,0,len(kdata))
    else:
        ax_draw_macd(ax2, kdata)
    #ax2.set_ylim(-1, 1)
    
    ax1.set_xlim((0, len(kdata)))
    ax_set_locator_formatter(ax1, kdata.getDatetimeList(), query.kType)
    adjust_axes_show([ax1, ax2])
    return show_gcf()