From c7bd2164cf69e8d655f60a0e2c8daebce6ebee70 Mon Sep 17 00:00:00 2001 From: Pranjal Joshi Date: Wed, 27 Mar 2024 12:32:35 +0530 Subject: [PATCH] v2.22 - RSI Crossing with 9 SMA of RSI - Momentum Reversal screener added --- src/classes/Changelog.py | 5 ++++- src/classes/ParallelProcessing.py | 7 ++++++- src/classes/Screener.py | 17 +++++++++++++++++ src/classes/Utility.py | 6 +++++- src/release.md | 15 ++++++++------- src/streamlit_app.py | 3 ++- 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/classes/Changelog.py b/src/classes/Changelog.py index d89343ca..21ab5cdf 100644 --- a/src/classes/Changelog.py +++ b/src/classes/Changelog.py @@ -7,7 +7,7 @@ from classes.ColorText import colorText -VERSION = "2.21" +VERSION = "2.22" changelog = colorText.BOLD + '[ChangeLog]\n' + colorText.END + colorText.BLUE + ''' [1.00 - Beta] @@ -290,4 +290,7 @@ [2.21] 1. Dependency updated - `advanced-ta` lib for bugfixes and performance improvement in Lorentzian Classifier + +[2.22] +1. RSI and 9 SMA of RSI based reversal added - Momentum based execution strategy. ''' + colorText.END diff --git a/src/classes/ParallelProcessing.py b/src/classes/ParallelProcessing.py index 0d2f4877..038617b4 100644 --- a/src/classes/ParallelProcessing.py +++ b/src/classes/ParallelProcessing.py @@ -61,7 +61,7 @@ def run(self): sys.exit(0) def screenStocks(self, tickerOption, executeOption, reversalOption, maLength, daysForLowestVolume, minRSI, maxRSI, respChartPattern, insideBarToLookback, totalSymbols, - configManager, fetcher, screener, candlePatterns, stock, newlyListedOnly, downloadOnly, vectorSearch, isDevVersion, backtestDate, printCounter=False): + configManager, fetcher, screener:Screener.tools, candlePatterns, stock, newlyListedOnly, downloadOnly, vectorSearch, isDevVersion, backtestDate, printCounter=False): screenResults = pd.DataFrame(columns=[ 'Stock', 'Consolidating', 'Breaking-Out', 'MA-Signal', 'Volume', 'LTP', 'RSI', 'Trend', 'Pattern']) screeningDictionary = {'Stock': "", 'Consolidating': "", 'Breaking-Out': "", @@ -192,6 +192,8 @@ def screenStocks(self, tickerOption, executeOption, reversalOption, maLength, da isVSA = screener.validateVolumeSpreadAnalysis(processedData, screeningDictionary, saveDictionary) if maLength is not None and executeOption == 6 and reversalOption == 4: isMaSupport = screener.findReversalMA(fullData, screeningDictionary, saveDictionary, maLength) + if executeOption == 6 and reversalOption == 8: + isRsiReversal = screener.findRSICrossingMA(fullData, screeningDictionary, saveDictionary) isVCP = False if respChartPattern == 4: @@ -253,6 +255,9 @@ def screenStocks(self, tickerOption, executeOption, reversalOption, maLength, da elif reversalOption == 7 and isLorentzian: self.screenResultsCounter.value += 1 return screeningDictionary, saveDictionary + elif reversalOption == 8 and isRsiReversal: + self.screenResultsCounter.value += 1 + return screeningDictionary, saveDictionary if executeOption == 7 and isLtpValid: if respChartPattern < 3 and isInsideBar: self.screenResultsCounter.value += 1 diff --git a/src/classes/Screener.py b/src/classes/Screener.py index 6ec12597..e148f450 100644 --- a/src/classes/Screener.py +++ b/src/classes/Screener.py @@ -421,6 +421,23 @@ def findReversalMA(self, data, screenDict, saveDict, maLength, percentage=0.015) saveDict['MA-Signal'] = f'Reversal-{maLength}MA' return True return False + + # Find stock showing RSI crossing with RSI 9 SMA + def findRSICrossingMA(self, data, screenDict, saveDict, maLength=9): + data = data[::-1] + maRsi = ScreenerTA.MA(data['RSI'], timeperiod=maLength) + data.insert(10,'maRsi',maRsi) + data = data[::-1].head(3) + if data['maRsi'].iloc[0] <= data['RSI'].iloc[0] and data['maRsi'].iloc[1] > data['RSI'].iloc[1]: + screenDict['MA-Signal'] = colorText.BOLD + colorText.GREEN + f'RSI-MA-Buy' + colorText.END + saveDict['MA-Signal'] = f'RSI-MA-Buy' + return True + elif data['maRsi'].iloc[0] >= data['RSI'].iloc[0] and data['maRsi'].iloc[1] < data['RSI'].iloc[1]: + screenDict['MA-Signal'] = colorText.BOLD + colorText.GREEN + f'RSI-MA-Sell' + colorText.END + saveDict['MA-Signal'] = f'RSI-MA-Sell' + return True + return False + # Find IPO base def validateIpoBase(self, stock, data, screenDict, saveDict, percentage=0.3): diff --git a/src/classes/Utility.py b/src/classes/Utility.py index 0243f82d..968db1c8 100644 --- a/src/classes/Utility.py +++ b/src/classes/Utility.py @@ -236,9 +236,10 @@ def promptReversalScreening(): 5 > Screen for Volume Spread Analysis (Bullish VSA Reversal) 6 > Screen for Narrow Range (NRx) Reversal 7 > Screen for Reversal using Lorentzian Classifier (Machine Learning based indicator) + 8 > Screen for Reversal using RSI MA Crossing 0 > Cancel [+] Select option: """ + colorText.END)) - if resp >= 0 and resp <= 7: + if resp >= 0 and resp <= 8: if resp == 4: try: maLength = int(input(colorText.BOLD + colorText.WARN + @@ -262,6 +263,9 @@ def promptReversalScreening(): except ValueError: print(colorText.BOLD + colorText.FAIL + '\n[!] Invalid Input! Select valid Signal Type!\n' + colorText.END) raise ValueError + elif resp == 8: + maLength = 9 + return resp, maLength return resp, None raise ValueError except ValueError: diff --git a/src/release.md b/src/release.md index 6e9a481f..1333b9e8 100644 --- a/src/release.md +++ b/src/release.md @@ -7,13 +7,14 @@ Screeni-py is now on **YouTube** for additional help! - Thank You for your suppo ⚠️ **Executable files (.exe, .bin and .run) are now DEPRECATED! Please Switch to Docker** -1. **NSE Indices** added to find Sectoral opportunities - Try Index `16 > Sectoral Indices` -2. **Backtesting Reports** Added for Screening Patterns to Develope and Test Strategies! -3. **Position Size Calculator** tab added for Better and Quick Risk Management! -4. **Lorentzian Classification** (invented by Justin Dehorty) added for enhanced accuracy for your trades - - Try `Option > 6 > 7` 🤯 -5. **Artificial Intelligence v3 for Nifty 50 Prediction** - Predict Next day Gap-up/down using Nifty, Gold and Crude prices! - Try `Select Index for Screening > N` -6. **Search Similar Stocks** Added using Vector Similarity search - Try `Search Similar Stocks`. -7. New Screener **Buy at Trendline** added for Swing/Mid/Long term traders - Try `Option > 7 > 5`. +1. **RSI** based **Reversal** using *9 SMA* of RSI - Try `Option > 6 > 8` +2. **NSE Indices** added to find Sectoral opportunities - Try Index `16 > Sectoral Indices` +3. **Backtesting Reports** Added for Screening Patterns to Develope and Test Strategies! +4. **Position Size Calculator** tab added for Better and Quick Risk Management! +5. **Lorentzian Classification** (invented by Justin Dehorty) added for enhanced accuracy for your trades - - Try `Option > 6 > 7` 🤯 +6. **Artificial Intelligence v3 for Nifty 50 Prediction** - Predict Next day Gap-up/down using Nifty, Gold and Crude prices! - Try `Select Index for Screening > N` +7. **Search Similar Stocks** Added using Vector Similarity search - Try `Search Similar Stocks`. +8. New Screener **Buy at Trendline** added for Swing/Mid/Long term traders - Try `Option > 7 > 5`. ## Installation Guide diff --git a/src/streamlit_app.py b/src/streamlit_app.py index 8e700d16..be92cf21 100644 --- a/src/streamlit_app.py +++ b/src/streamlit_app.py @@ -225,7 +225,8 @@ def get_extra_inputs(tickerOption, executeOption, c_index=None, c_criteria=None, '4 > Reversal at Moving Average (Bullish Reversal)', '5 > Volume Spread Analysis (Bullish VSA Reversal)', '6 > Narrow Range (NRx) Reversal', - '7 > Lorentzian Classifier (Machine Learning based indicator)' + '7 > Lorentzian Classifier (Machine Learning based indicator)', + '8 > RSI Crossing with 9 SMA of RSI itself' ] ).split(' ')[0]) if select_reversal == 4: