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()
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()