Ejemplo n.º 1
0
def drawBuyA(row, col, symbols, start, end):
    fig = plt.figure(figsize=(16, 16))
    i = 0
    for symbol in symbols:
        print(symbol)
        i += 1
        data = TushareStore.get_a_daily_data_ind(table='a_daily',
                                                 symbol=symbol,
                                                 start_date=start,
                                                 end_date=end,
                                                 append_ind=True)
        close, pdi, wr, wr_89, bias = data['close'], data['pdi'], data[
            'willr'], data['willr_89'], data['bias']
        ax = fig.add_subplot(row, col, i)
        ax.plot(close, c='grey')
        # buy = close[ind.LESS_THAN(bias.shift(1), -13) & ind.BOTTOM(bias)]
        buy = close[ind.LESS_THAN(wr.shift(1), -88) & ind.BOTTOM(wr)]
        # print buy
        ax.scatter(buy.index, buy, s=20, c='green')
        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_ylabel(symbol)
    plt.legend()
    plt.subplots_adjust(hspace=1)
    plt.show()
Ejemplo n.º 2
0
def show_buy(ax, data, type):
    close, low, high = data['close'], data['low'], data['high']
    ma3, ma5, ma20, ma60 = data['sma_3'], data['sma_5'], data['sma_20'], data[
        'sma_60']
    diff, dea = data['dif'], data['dea']
    close, willr, willr_34, willr_89, = data['close'], data['willr'], data[
        'willr_34'], data['willr_89']
    bias, pdi = data['bias'], data['pdi']
    buy = ind.LESS_THAN(willr, -88)
    # & ind.LESS_THAN(willr_34, -88)
    # ind.GREAT_THAN(bias, 3)
    # & ind.GREAT_THAN(willr_89, -28)
    # & ind.LESS_THAN(willr, -70)

    # ind.LESS_THAN(bias.shift(1), -3) & ind.BOTTOM(bias) &
    # & ind.GREAT_THAN(willr, -40)
    # & ind.LESS_THAN(bias.shift(), 3)
    # & ind.BOTTOM(willr)
    # & ind.LESS_THAN(willr_34.shift(1), -88)
    # & ind.BOTTOM(willr_34)
    # & ind.LESS_THAN(willr_89.shift(1), -88)
    # & ind.BOTTOM(willr_89)

    buy = ind.TOUCH(close, ma20) & ind.TOUCH(diff, dea, 0.3)

    # diff,dea 死叉 close>ma20 会上涨 close<ma20 会下跌
    # 上升趋势 diff,dea,close,ma20 同时死叉 最佳买点 会涨
    # 下跌趋势 diff,dea,close,ma20 同时金叉 反弹最高点,会跌

    # 上升趋势 diff,dea,close,ma20 同时金叉 最佳买点 会涨
    buy = ind.DEAD_CROSS(diff, dea)

    # diff,dea 金叉,close>ma20 会震荡回调 close<ma20 会补涨
    # 上升趋势 diff,dea,close,ma20 同时金叉 最佳买点 会涨
    # 下跌趋势 diff,dea,close,ma20 同时金叉 反弹最高点,会跌
    # buy = ind.GOLDEN_CROSS(diff, dea) | ind.DEAD_CROSS(diff, dea)

    k_golden_cross = ind.GOLDEN_CROSS(close, ma20) | ind.GOLDEN_CROSS(
        close, ma60)
    k_dead_cross = ind.DEAD_CROSS(close, ma20) | ind.DEAD_CROSS(close, ma60)
    macd_golden_cross = ind.GOLDEN_CROSS(diff, dea) | ind.UP_CROSS(diff, 0)
    macd_dead_cross = ind.DEAD_CROSS(diff, dea) | ind.DOWN_CROSS(diff, 0)
    if type == 'k':
        # ax.scatter(close[k_golden_cross].index, close[k_golden_cross], s=20, c='darkgoldenrod', zorder=200)
        # ax.scatter(close[k_dead_cross].index, close[k_dead_cross], s=20, c='black', zorder=200)
        ax.scatter(close[macd_golden_cross].index,
                   close[macd_golden_cross],
                   s=20,
                   c='darkgoldenrod',
                   zorder=200)
        # ax.scatter(close[macd_dead_cross].index, close[macd_dead_cross], s=20, c='black', zorder=200)
    else:
        # ax.scatter(diff[k_golden_cross].index, diff[k_golden_cross], s=20, c='darkgoldenrod', zorder=200)
        # ax.scatter(diff[k_dead_cross].index, diff[k_dead_cross], s=20, c='black', zorder=200)
        ax.scatter(diff[macd_golden_cross].index,
                   diff[macd_golden_cross],
                   s=20,
                   c='darkgoldenrod',
                   zorder=200)
Ejemplo n.º 3
0
def drawBuy(row, col, sector, symbols, start, end):
    fig = plt.figure(figsize=(16, 8))
    i = 0
    for symbol in symbols:
        i += 1
        data = TushareStore.get_usa_daily_data_ind(sector=sector,
                                                   symbol=symbol,
                                                   start_date=start,
                                                   end_date=end,
                                                   append_ind=True)
        # data = store.get_chart_data_from_db("600%d.SH" % code, '20180101')
        # data = get_chart_data_from_web(code, '1/1/2018', '1/30/2019')
        close, pdi, wr, wr_89, bias = data['close'], data['pdi'], data[
            'willr'], data['willr_89'], data['bias']
        ax = fig.add_subplot(row, col, i)
        ax.plot(close, c='grey')
        # buy = close[(wr <= -98)]
        # ax.scatter(buy.index, buy, c='red')
        # buy = close[(wr <= -93) & (wr > -98)]
        # ax.scatter(buy.index, buy, c='orange')
        # buy = close[(wr <= -88) & (wr > -93)]

        # ax.scatter(buy.index, buy, c='yellow')
        # buy = close[(wr <= -83) & (wr > -88)]
        # ax.scatter(buy.index, buy, c='green')

        # buy = close[(pdi <= 10) & (wr < -88)]
        # ax.scatter(buy.index, buy, c='red')
        # buy = close[(pdi <= 12) & (pdi > 10) & (wr < -88)]
        # ax.scatter(buy.index, buy, c='orange')
        # buy = close[(pdi <= 16) & (pdi > 12) & (wr < -88)]
        # ax.scatter(buy.index, buy, c='yellow')
        # buy = close[(pdi <= 20) & (pdi > 16) & (wr < -88)]
        # ax.scatter(buy.index, buy, c='green')

        # buy = close[ind.UP_CROSS(wr_89, -83.5) & ind.LESS_THAN(wr, -50)]
        # buy = close[ind.LESS_THAN(wr_89, -97)  & ind.BOTTOM(wr_89)]
        # buy = close[ind.LESS_THAN(bias, -12) & ind.BOTTOM(bias) & ind.LESS_THAN(wr_89, -83.5)]
        buy = close[ind.LESS_THAN(bias.shift(1), -13) & ind.BOTTOM(bias)]
        ax.scatter(buy.index, buy, s=20, c='green')
        # ax = plt.twinx()
        # ax.plot(bias)
        # ax.plot(wr)
        # drawHline(ax, [-12])
        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_ylabel(symbol)

    plt.legend()
    plt.subplots_adjust(hspace=0.1)
    plt.show()