diff --git a/technical_analysis/momentum.py b/technical_analysis/momentum.py index 591e26b8bcd..22bd0225599 100644 --- a/technical_analysis/momentum.py +++ b/technical_analysis/momentum.py @@ -199,13 +199,63 @@ def rsi(l_args, s_ticker, s_interval, df_stock): if s_interval == "1440min": df_ta = ta.rsi(df_stock['5. adjusted close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar, drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna() - plot_stock_and_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "RSI") + + plt.subplot(211) + plt.plot(df_stock.index, df_stock['5. adjusted close'].values, 'k', lw=3) + plt.title(f"Relative Strength Index (RSI) on {s_ticker}") + plt.xlim(df_stock.index[0], df_stock.index[-1]) + plt.ylabel(f'Share Price ($)') + plt.grid(b=True, which='major', color='#666666', linestyle='-') + plt.minorticks_on() + plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2) + plt.subplot(212) + plt.plot(df_ta.index, df_ta.values, 'k', lw=2) + plt.xlim(df_stock.index[0], df_stock.index[-1]) + plt.axhspan(70, 100, facecolor='r', alpha=0.2) + plt.axhspan(0, 30, facecolor='g', alpha=0.2) + plt.axhline(70, linewidth=3, color='r', ls='--') + plt.axhline(30, linewidth=3, color='g', ls='--') + plt.xlabel('Time') + plt.grid(b=True, which='major', color='#666666', linestyle='-') + plt.minorticks_on() + plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2) + plt.ylim([0, 100]) + plt.gca().twinx() + plt.ylim(plt.gca().get_ylim()) + plt.yticks([.15, .85], ('OVERSOLD', 'OVERBOUGHT')) + plt.show() + # Intraday else: df_ta = ta.rsi(df_stock['4. close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar, drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna() - plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "RSI") + plt.subplot(211) + plt.plot(df_stock.index, df_stock['4. close'].values, 'k', lw=3) + plt.title(f"Relative Strength Index (RSI) on {s_ticker}") + plt.xlim(df_stock.index[0], df_stock.index[-1]) + plt.ylabel(f'Share Price ($)') + plt.grid(b=True, which='major', color='#666666', linestyle='-') + plt.minorticks_on() + plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2) + plt.subplot(212) + plt.plot(df_ta.index, df_ta.values, 'k', lw=2) + plt.xlim(df_stock.index[0], df_stock.index[-1]) + plt.axhspan(70, 100, facecolor='r', alpha=0.2) + plt.axhspan(0, 30, facecolor='g', alpha=0.2) + plt.axhline(70, linewidth=3, color='r', ls='--') + plt.axhline(30, linewidth=3, color='g', ls='--') + plt.xlabel('Time') + plt.grid(b=True, which='major', color='#666666', linestyle='-') + plt.minorticks_on() + plt.grid(b=True, which='minor', color='#999999', linestyle='-', alpha=0.2) + plt.ylim([0, 100]) + plt.gca().twinx() + plt.ylim(plt.gca().get_ylim()) + plt.yticks([.15, .85], ('OVERSOLD', 'OVERBOUGHT')) + plt.show() + + print("") except: print("")