pkjmesra / PKScreener

A Python-based stock screener for NSE, India. PKScreener is an advanced free stock screener to find potential breakout stocks from NSE and show its possible breakout values. It also helps to find the stocks which are consolidating and may breakout, or the particular chart patterns that you're looking specifically to make your decisions.
https://github.com/pkjmesra/PKScreener
MIT License
67 stars 32 forks source link
alerts algorithmic-trading algotrading backtesting breakouts free-stock-screener indian-markets nasdaq nse portfolio-analysis scanners stock-screener stocks-trading telegram-bot

Title

PKScreener

MADE-IN-INDIA GitHub release (latest by date) Downloads latest download Docker Pulls
Platforms Windows Linux Mac OS Docker Status
Package / Docs Documentation PyPI is wheel github license
Tests CodeFactor Coverage Status codecov After Market

What is PKScreener?

Telegram Alerts Nifty AI Prediction Scheduling Cron Jobs On-Demand Telegram Bot Backtesting / Growth of 10k
Nifty screening Volume scanners Breakout detection Consolidating stocks Reversal Signals
Chart Patterns CCI scanners 2% scanners Short-term bulls NR4 / NR7 Daily Releases
Fair Value Mutual funds, FII data TTM Squeeze Golden Crossover Death Crossover
RSI screening MACD scanners IPO Stocks Momentum Gainers Watchlist screening
Stock Performance 52Wk-H/L Breakouts 10 days low breakouts Aroon Crossover Next Day Bullish Stocks
Today's Breakouts Breaking out now Popular stocks by Mutual Funds / FIIs Higher Highs Lower Lows
F&O Stocks screening Live 5-EMA Index Scan Logging Telegram Channel Early Breakouts
ATR Cross ATR Trailing Stops Intraday Bid/Ask Build-up Quick Backtest Morning vs Day-close profit analysis
Multiple period/duration support Daily OHLCV Intraday OHLCV Auomated Software Updates NASDAQ Index Support
Nifty 50 Nifty Next 50 Nifty 100 Nifty 200 Nifty 500
Nifty Smallcap 50 Nifty Smallcap 250 Nifty Midcap 50 Nifty Midcap 100 Nifty Midcap 150
Nifty All 2000 Nifty Newly Listed (IPOs in last 2 Year) Nifty F&O Stocks View Stock Performance High Momentum(RSI,MFI,CCI)
Intraday Monitor Scanner pinning Stock list Pinning VCP (Volatility Contraction Pattern) VCP (Mark Minervini)
Moving Average Signals Candle-stick Patterns Trendline Support Stocks Bullish/Bearish Inside Bar Volume Spread Analysis
Narrow Range (NRx) Reversal Lorentzian Classifier PSAR and RSI reversal Rising RSI RSI MA Reversal
Upcoming CA stocks High Dividend Stocks Fair Value Buy Opportunities Shareholding by number of Mutual Funds/FIIs Bullish for next day

A Python-based stock screener for NSE, India.

pkscreener is an advanced stock screener to find potential breakout stocks from NSE and tell it's possible breakout values. It also helps to find the stocks which are consolidating and may breakout, or the particular chart patterns that you're looking specifically to make your decisions. pkscreener is totally customizable and it can screen stocks with the settings that you have provided.

You can get daily scan results/alerts at scheduled times by subscribing to the following Telegram channel: Purpose Description/link QR Code
Alerts Channel https://t.me/PKScreener > You wil receive all the major alerts on this telegram channel. These alerts are sent for all major strategy scans daily around 9:30am-10:15am and then around 4pm. You will also receive the next day's market predictions. Telegram Channel

telegram

Receiving Scheduled Scan results

If you would like to receive the scan results, please join the telegram channel and group above. You may receive the following scan results:

  1. 1. Next day Nifty/Market AI prediction by 4pm IST, Monday - Friday
  2. For all Nifty stocks at/by 9:45-10:15am and by 4pm IST, Monday - Friday

    • Certain selected but configurable alerts for specific scan types

Receiving On-Demand Scan results

You can now run the pkscreenerbot on your local machine or if it's running on the GitHub server under a GitHub Actions workflow, you can use the pkscreener Bot(@nse_pkscreener_bot on Telegram) to get on-demand scan results.

bot

Scanners

Screening options to choose from:

     X > Scanners
     M > Monitor Intraday
     S > Strategies
     B > Backtests
     G > Growth of 10k
     C > Analyse morning vs close outcomes

     P > Piped Scanners

     T > Toggle between long-term (Default) [Current (1y, 1d)] and Intraday user configuration

     D > Download Daily OHLC Data for the Past Year
     I > Download Intraday OHLC Data for the Last Trading Day

     E > Edit user configuration
     Y > View your user configuration

     U > Check for software update

     L > Collect Logs for Debugging
     H > Help / About Developer

Multiple Indices to choose from:

     W > Screen stocks from my own Watchlist
     N > Nifty Prediction using Artifical Intelligence (Use for Gap-Up/Gap-Down/BTST/STBT)
     E > Live Index Scan : 5 EMA for Intraday

     0 > Screen stocks/index by the stock/index names (NSE Stock Code, e.g. SBIN,BANKINDIA or Yahoo Finance index symbol, e.g. ^NSEI, ^NSEBANK, ^BSESN)
     1 > Nifty 50           2 > Nifty Next 50       3 > Nifty 100         
     4 > Nifty 200          5 > Nifty 500           6 > Nifty Smallcap 50 
     7 > Nifty Smallcap 100 8 > Nifty Smallcap 250  9 > Nifty Midcap 50   
    10 > Nifty Midcap 100   11 > Nifty Midcap 150   12 > Nifty (All Stocks)
    13 > Newly Listed (IPOs in last 2 Year)             14 > F&O Stocks Only

     15 > NASDAQ

Followin scanners are already implemented.

     0 > Full Screening (Shows Technical Parameters without any criterion)
     1 > Probable Breakouts/Breakdowns      2 > Today's Breakouts/Breakdowns
     3 > Consolidating stocks               4 > Lowest Volume in last N-days (Early Breakout Detection)
     5 > RSI screening                      6 > Reversal Signals
     7 > Stocks making Chart Patterns       8 > CCI outside of the given range
     9 > Volume gainers                     10 > Closing at least 2% up since last 3 days
    11 > Short term bullish (Ichimoku)      12 > N-Minute Price & Volume breakout(Intraday)
    13 > Bullish RSI & MACD                 14 > NR4 Daily Today
    15 > 52 week low breakout(today)(Sell)  16 > 10 days low breakout(Sell)
    17 > 52 week high breakout(today)       18 > Bullish Aroon(14) Crossover
    19 > MACD Histogram x below 0 (Sell)    20 > Bullish for next day
    21 > MF/FIIs Popular Stocks             22 > View Stock Performance         
    23 > Breaking out now                   24 > Higher Highs,Lows & Close (SuperTrend)
    25 > Lower Highs,Lows (Watch for Rev.)  26 > Stocks with stock-split/bonus/dividends
    27 > ATR Cross                          28 > Bullish Higher Opens           
    29 > Intraday Bid/Ask Build-up          30 > ATR Trailing Stops(Swing Paper Trading)
    31 > High Momentum(RSI,MFI,CCI)     

Running Piped Scanners

https://github.com/pkjmesra/PKScreener/assets/1358101/9e579371-1035-400a-9f65-139d8407f6c7

Multiple pre-defined piped scanners

     1 > Volume Scanners | High Momentum | Breaking Out Now | ATR Cross         2 > Volume Scanners | High Momentum | ATR Cross
     3 > Volume Scanners | High Momentum                                        4 > Volume Scanners | ATR Cross
     5 > Volume Scanners | High Bid/Ask Build Up                                6 > Volume Scanners | ATR Cross | ATR Trailing Stops
     7 > Volume Scanners | ATR Trailing Stops                                   8 > High Momentum | ATR Cross
     9 > High Momentum | ATR Trailing Stop                                      10 > ATR Cross | ATR Trailing Stop
    11 > TTM Sqeeze Buy | Intraday RSI b/w 0 to 54                              12 > Volume Scanners | High Momentum | Breaking Out Now | ATR Cross | Intraday RSI b/w 0 to 54
    13 > Volume Scanners | ATR Cross | Intraday RSI b/w 0 to 54                 14 > VCP (Mark Minervini) | Chart Patterns | MA Support
    15 > VCP | Chart Patterns | MA Support                                      16 > Already Breaking out | VCP (Minervini) | Chart Patterns | MA Support
    17 > ATR Trailing Stops | VCP (Minervini)                                   18 > VCP | ATR Trailing Stops
    19 > Nifty 50,Nifty Bank | VCP | ATR Trailing Stops                     

How to use on your own local Windows/Linux/Macbook laptop?

Using docker, running within docker container

Special notes on vulnerabilities shown in the docker image/container

Please keep in mind that only because the container/image shows a vulnerability, it does not mean that it exists in this particular image.

  1. If you see a critical vulnerability being shown for git, it's ONLY IF we use git with v2.13 or below AND we use git submodule. In case of PKScreener, both are false. We use git >= 2.45 and we DO NOT use git submodules. See https://nvd.nist.gov/vuln/detail/CVE-2024-32002
  2. If you see high severity vulnerability for pip, it's ONLY IF we use a private indexed repository. In our case, we only use PyPi - a public python library repository. See https://nvd.nist.gov/vuln/detail/CVE-2018-20225.
  3. If you see high severity vulnerability for usage of library Pillow, it's ONLY IF we try to generate an image containing text that can uncontrollably lengthy. In PKScreener, the image is NEVER generated locally on your laptop or docker container. It is generated only when running in telegram-bot for morning/afternoon analysis alerts. Additionally, there are checks to ensure we never go beyond the maximum size of the number of columns in the analysis tables. To conclude, the image generation module never gets activated on docker/locally on your laptop. See https://nvd.nist.gov/vuln/detail/CVE-2023-44271

The story is similar for other low severity vulnerabilities that docker might show. If you're genuinely concerned, you can search with the respective CVE # in the NIST database to understand more or create an issue https://github.com/pkjmesra/PKScreener/issues . We keep reviewing all vulnerabilties regularly and fix those immediately if at all they are likely to impact us or our users.

Installing the latest version from PyPi.

For example:

For Windows: See https://github.com/pkjmesra/PKScreener/blob/c1e94ba3137915cb781161fa2d5fb69129940fd3/.github/workflows/w1-workflow-build-matrix.yml#L91-L101

For Mac: Run brew install ta-lib assuming you have homebrew installed.

For Ubuntu/Linux: See https://github.com/pkjmesra/PKScreener/blob/main/.github/workflows/w1-workflow-build-matrix.yml#L121-L132

Building from source repo

Running the executables

config

screening

Results :

results

It also shows you how the chosen scan option has fared in the past. 1-Pd, 2-Pd means 1 day, 2 days from the date of scan in the past when those stocks came into the results of the chosen scan option.

results

Growth of 10k

You can see the performance of your stocks and/or at portfolio level using "Growth of 10k".

G10k

It also summarises the Growth of 10k at portfolio level for the last quarter so that you know which filters worked best in the past:

G10k_Sum

Backtests

You can now use the Backtests menu to backtest any of the selected strategies. See https://pkjmesra.github.io/PKScreener/BacktestReports.html

backtest

Scanning as a scheduled job once or at regular intervals

Understanding the Result Table:

The Result table contains a lot of different parameters which can be pretty overwhelming to the new users, so here's the description and significance of each parameter.

Sr Parameter Description Example
1 Stock This is a NSE scrip symbol. If your OS/Terminal supports unicode, You can directly open TradingView charts by pressing Ctrl+Click on the stock name. TATAMOTORS
2 Consolidating It gives the price range in which stock is trading since last N days. N is configurable and can be modified by executing Edit User Configuration option. If stock is trading between price 100-120 in last 30 days, Output will be Range:20.0 %
3 Breakout (N Days) This is pure magic! The BO is Breakout level in last N days while R is the next resistance level if available. Investor should consider both BO & R level to decide entry/exits in their trades. B:302, R:313(Breakout level is 100 & Next resistance is 102)
4 LTP LTP is the Last Traded Price of an asset traded on NSE. 298.7 (Stock is trading at this price)
5 Volume Volume shows the relative volume of the recent candle with respect to 20 period MA of Volume. It could be Unknown for newly listed stocks. if 20MA(Volume) is 1M and todays Volume is 2.8M, then Volume = 2.8x
6 MA-Signal It describes the price trend of an asset by analysing various 50-200 MA/EMA crossover strategies. 200MA-Support,BullCross-50MA etc
7 RSI For the momentum traders, it describes 14-period RSI for quick decision making about their trading plans 0 to 100
8 Trend By using advance algorithms, the average trendlines are computed for N days and their strenght is displayed depending on steepness of trendlines. (This does NOT show any trendline on chart, it is calculated internally) Strong Up, Weak Down etc.
9 Pattern If the chart or the candle itself forming any important pattern in the recent timeframe or as per the selected screening option, various important patterns will be indicated here. Momentum Gainer, Inside Bar (N),Bullish Engulfing etc.

Hack it your way:

Feel free to Edit the parameters in the pkscreener.ini file which will be generated by the application.

[config]
period = 1y
daystolookback = 22
duration = 1d
minprice = 20.0
maxprice = 50000.0
volumeratio = 2.5
consolidationpercentage = 10.0
shuffle = y
cachestockdata = y
onlystagetwostocks = y
useema = n
showunknowntrends = y
logsenabled = n
generaltimeout = 2.0
longtimeout = 4.0
maxnetworkretrycount = 10
backtestperiod = 60
minimumvolume = 10000

Try to tweak this parameters as per your trading styles. For example, If you're comfortable with weekly charts, make duration=5d and so on. For intraday, you can set period=1d and duration=5m if you would like to calculate with 5minute candles. Set the duration to 15m or whatever value you desire, but keep the period to 1d. This tool, however, works best for short/mid term instead of intraday, but some scans like momentum/volume/NR4 etc can be used for screening stocks for intraday as well. You can use the toggle menu option T to toggle between long term and intraday config before you begin the scanners.

Creating your own Telegram channel to receive your own alerts:

You can create your own telegram channel to receive alerts wherenevr you run it locally on your laptop either from a command line interface console or run it as a scheduler. Simply, go ahead and

  1. Create a bot for yourself, then a channel and get their IDs. Follow the steps in https://medium.com/codex/using-python-to-send-telegram-messages-in-3-simple-steps-419a8b5e5e2 and https://www.siteguarding.com/en/how-to-get-telegram-bot-api-token
  2. After you have created the bot using botFather and have received/verified your bot id/token and channel ID using get id bot, simply go to pkscreener folder in the source code directory and create a .env.dev file with the following (If you are instead using the .exe or .bin or .run file from release, just create this file in the same folder where the executable (.exe or .bin or .run) is placed.)
    CHAT_ID=Your_Channel_Id_Here_Without_A_Hyphen_or_Minus_Sign
    TOKEN=Your_Bot_Token_Here
    chat_idADMIN=Your_Own_ID_Here
  3. From now on, you will begin to receive your own alerts on your telegram channel. alerts

Troubleshooting and Logs:

If you are having issues running the program, you can just launch a command line interface (On windows> Start > Run > cmd) and then launch PKScreener with a command line option of -l. For example, python pkscreenercli.py -l. This will show you the path where the program will save all the log outputs from this run. Copy that path and go ahead and run the application. Altenatively, you can just go ahead and modify the logsEnabled value to y, save & close it and then run python pkscreenercli.py.

After you have finished the run, go to that copied path, zip the contents of the file pkscreener-logs.txt and create an issue at https://github.com/pkjmesra/PKScreener/issues. Please do not forget to attach the log files in the issue.

Contributing:

Disclaimer: