How to use the hikyuu.indicator.CLOSE 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 / volume.py View on Github external
def draw(stock, query=Query(-130), ma1_n=5, ma2_n=10, ma3_n=20, ma4_n=60, 
         ma5_n=100, vma1_n=5, vma2_n=10):
    """绘制普通K线图 + 成交量(成交金额)"""
    kdata = stock.getKData(query)
    close = CLOSE(kdata,)
    ma1 = MA(close, ma1_n)
    ma2 = MA(close, ma2_n)
    ma3 = MA(close, ma3_n)
    ma4 = MA(close, ma4_n)
    ma5 = MA(close, ma5_n)

    ax1, ax2 = create_figure(2)
    kdata.plot(axes=ax1)
    ma1.plot(axes=ax1, legend_on=True)
    ma2.plot(axes=ax1, legend_on=True)
    ma3.plot(axes=ax1, legend_on=True)
    ma4.plot(axes=ax1, legend_on=True)
    ma5.plot(axes=ax1, legend_on=True)
    
    sg = SG_Cross(MA(n=ma1_n), MA(n=ma2_n))
    sg.setTO(kdata)
github fasiondog / hikyuu / hikyuu / interactive / elder.py View on Github external
def draw(stock, query=QueryByIndex(-130), ma_n=22, ma_w='auto', vigor_n=13):
    """绘制亚历山大.艾尔德交易系统图形"""
    kdata = stock.getKData(query)
    close = CLOSE(kdata)
    ema = EMA(close, ma_n)
    sf = SAFTYLOSS(close, 10, 3, 2.0)
    vigor = VIGOR(kdata, vigor_n)

    ax1, ax2, ax3 = create_figure(3)
    kdata.plot(axes=ax1)
    _draw_ema_pipe(ax1,kdata, ema, n=ma_n, w=ma_w)
    sf.plot(axes=ax1, color='y', legend_on=True)
    #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]
github fasiondog / hikyuu / hikyuu / interactive / elder.py View on Github external
def _draw_ema_pipe(axes, kdata, ema, n=22, w=0.10):
    emas = [i for i in ema]
    p = _find_ema_coefficient(list(CLOSE(kdata)), emas, number=66, percent=0.95) if w=='auto' else w
    emas_high = [i+i*p for i in emas]
    emas_low = [i-i*p for i in emas]
    emas_len = len(emas)
    
    PRICELIST(emas).plot(axes=axes, color='b', linestyle='-', label='%s(%s)  %.2f'%(ema.name, n, emas[-1]))
    PRICELIST(emas_high).plot(axes=axes, color='b', linestyle=':', label='U%s(%.2f%%) %.2f'%(ema.name, p*100, emas_high[-1]))
    PRICELIST(emas_low).plot(axes=axes, color='b', linestyle=':', label='L%s(%.2f%%) %.2f'%(ema.name, p*100, emas_low[-1]))
    #axes.plot(emas, '-b', label='%s(%s)  %.2f'%(ema.name, n, emas[-1]))
    #axes.plot(emas_high, ':b', label='U%s(%.2f%%) %.2f'%(ema.name, p*100, emas_high[-1]))
    #axes.plot(emas_low, ':b', label='L%s(%.2f%%) %.2f'%(ema.name, p*100, emas_low[-1]))
    fy1 = [ i for i in emas_low]
    fy2 = [ i for i in emas_high]
    axes.fill_between(range(emas_len),fy1,fy2,alpha=0.2, color='y' )
github fasiondog / hikyuu / hikyuu / examples / quick_crtsg.py View on Github external
def TurtleSG(self):
     n = self.getParam("n")
     k = self.getTO()
     c = CLOSE(k)
     h = REF(HHV(c, n), 1) #前n日高点
     L = REF(LLV(c, n), 1) #前n日低点
     for i in range(h.discard, len(k)):
         if (c[i] >= h[i]):
             self._addBuySignal(k[i].datetime)
         elif (c[i] <= L[i]):
             self._addSellSignal(k[i].datetime)
github fasiondog / hikyuu / tools / hikyuu / interactive / elder.py View on Github external
def _draw_ema_pipe(axes, kdata, ema, n=22, w=0.10):
    emas = [i for i in ema]
    p = _find_ema_coefficient(list(CLOSE(kdata)), emas, number=66, percent=0.95) if w=='auto' else w
    emas_high = [i+i*p for i in emas]
    emas_low = [i-i*p for i in emas]
    emas_len = len(emas)
    
    PRICELIST(emas).plot(axes=axes, color='b', linestyle='-', label='%s(%s)  %.2f'%(ema.name, n, emas[-1]))
    PRICELIST(emas_high).plot(axes=axes, color='b', linestyle=':', label='U%s(%.2f%%) %.2f'%(ema.name, p*100, emas_high[-1]))
    PRICELIST(emas_low).plot(axes=axes, color='b', linestyle=':', label='L%s(%.2f%%) %.2f'%(ema.name, p*100, emas_low[-1]))
    #axes.plot(emas, '-b', label='%s(%s)  %.2f'%(ema.name, n, emas[-1]))
    #axes.plot(emas_high, ':b', label='U%s(%.2f%%) %.2f'%(ema.name, p*100, emas_high[-1]))
    #axes.plot(emas_low, ':b', label='L%s(%.2f%%) %.2f'%(ema.name, p*100, emas_low[-1]))
    fy1 = [ i for i in emas_low]
    fy2 = [ i for i in emas_high]
    axes.fill_between(range(emas_len),fy1,fy2,alpha=0.2, color='y' )
github fasiondog / hikyuu / tools / hikyuu / interactive / volume.py View on Github external
def draw(stock, query=Query(-130), ma1_n=5, ma2_n=10, ma3_n=20, ma4_n=60, 
         ma5_n=100, ma_type="SMA", vma1_n=5, vma2_n=10):
    """绘制普通K线图 + 成交量(成交金额)"""
    kdata = stock.getKData(query)
    close = CLOSE(kdata,)
    ma1 = MA(close, ma1_n, ma_type)
    ma2 = MA(close, ma2_n, ma_type)
    ma3 = MA(close, ma3_n, ma_type)
    ma4 = MA(close, ma4_n, ma_type)
    ma5 = MA(close, ma5_n, ma_type)

    ax1, ax2 = create_figure(2)
    kdata.plot(axes=ax1)
    ma1.plot(axes=ax1, legend_on=True)
    ma2.plot(axes=ax1, legend_on=True)
    ma3.plot(axes=ax1, legend_on=True)
    ma4.plot(axes=ax1, legend_on=True)
    ma5.plot(axes=ax1, legend_on=True)
    
    sg = SG_Cross(OP(MA(n=ma1_n, type=ma_type)), OP(MA(n=ma2_n, type=ma_type)))
    sg.setTO(kdata)
github fasiondog / hikyuu / tools / hikyuu / examples / Turtle_SG.py View on Github external
def _calculate(self):
        n = self.getParam("n")
        k = self.getTO()
        c = CLOSE(k)
        h = REF(HHV(c, n), 1) #前n日高点
        L = REF(LLV(c, n), 1) #前n日低点
        for i in range(h.discard, len(k)):
            if (c[i] >= h[i]):
                self._addBuySignal(k[i].datetime)
            elif (c[i] <= L[i]):
                self._addSellSignal(k[i].datetime)