Skip to main content

A Python-based stock screener for NSE, India with alerts to Telegram Channel (pkscreener)

Project description

PKScreener

MADE-IN-INDIA Windows Linux Mac OS GitHub release (latest by date) GitHub all releases GitHub CodeFactor BADGE

github license Downloads latest download PyPI is wheel Coverage Status codecov

Documentation Docker Status Docker Pulls w5. Production Scan Tests On Dev w9. After-Market Data Gen PKScreener Test - New Features 1. PKScreener Build - New Release Docker Build

What is PKScreener?

Telegram Alerts Nifty AI Prediction Scheduling Cron Jobs On-Demand Telegram Bot Backtesting
Nifty screening Volume scanners Breakout detection Consolidating stocks Reversal Signals
Chart Patterns CCI scanners 2% scanners Short-term bulls NR4 / NR7 Weekly Releases
RSI screening MACD scanners IPO Stocks Momentum Gainers Watchlist screening
F&O Stocks screening Live 5-EMA Index Scan Logging Telegram Channel Early Breakouts

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
<!-- Discussions [] https://t.me/PKScreeners > For any discussion related to PKScreener, you may like to join this related Telegram group Telegram Group -->

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:

  • Artificial Intelligence v2 for Nifty 50 Prediction
  • Live Index Scan : 5 EMA for Intraday
  • Screen stocks by the stock names (NSE Stock Code)
  • Nifty 50
  • Nifty Next 50
  • Nifty 100
  • Nifty 200
  • Nifty 500
  • Nifty Smallcap 50
  • Nifty Smallcap 100
  • Nifty Smallcap 250
  • Nifty Midcap 50
  • Nifty Midcap 100
  • Nifty Midcap 150
  • Nifty (All Stocks)
  • Newly Listed (IPOs in last 2 Year)
  • F&O Stocks Only

Followin scanners are already implemented. Others are In Progress

     0 > Full Screening (Shows Technical Parameters without any criterion)
     1 > Probable Breakouts              	2 > Today's Breakouts
     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 stocks(Intraday)	12 > 15 Minute Price & Volume breakout(Intraday)
    13 > Bullish RSI & MACD(Intraday)       	14 > NR4 Daily Today
    15 > 52 week low breakout(today/1 wk)	16 > 10 days low breakout
    17 > 52 week high breakout(today/1 wk)	18 > Bullish Aroon(14) Crossover
    19 > MACD Histogram x below 0       	20 > Bullish for next day
    21 > Most Popular Stocks            	22 > View Stock Performance         
    23 > Breaking out now               	

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

Installing the latest version from PyPi.

  • Go ahead and install using pip install pkscreener
  • This should install all of the major dependencies, except maybe, TA-Lib.
  • This app can still run without TA-Lib, but if you need to install TA-Lib for technical indicators (which otherwise is used from pandas_ta in the absence of TA-Lib), you can do this: Head to .github/dependencies/ under this repo. Download the respective TA-Lib file/whl file and install either from the .whl file or from source. Check out any of the workflow files for steps to install TA-Lib.
  • Now launch your favorite command line CLI and issue pkscreener. This will launch the pkscreener executable.

Using docker, running within docker container

  • Download and install docker desktop: https://docs.docker.com/get-docker/
  • After installation, launch/run docker desktop and if it asks, login using your docker credentials.
  • Launch any command line and type docker pull pkjmesra/pkscreener-debian:latest. Then type docker run pkjmesra/pkscreener-debian:latest python3 pkscreenercli -a Y -o X:12:10 -e ow whatever -o options you'd like executed.
  • Pass whatever option you'd like to pass in -o. Look at the menu options above. For, example, 10 is Closing at least 2% up since last 3 days etc. Wait while it runs and produces the output for you.

Building from source repo

  • Install python 3.9 for your OS/CPU. Download the installer from https://www.python.org/downloads/release/python-3913/#Files
  • Just clone the repo with git clone https://github.com/pkjmesra/PKScreener.git
  • cd PKScreener
  • pip install -r requirements.txt .
  • (Optional) If you would like to have technical indicators evaluated using TA-Lib, go ahead and install TA-Lib as well. pip3 install ta-lib. Please review additional steps to buil TA-Lib in tthe workflow files meant for your OS under .github > workflows.
  • cd pkscreener
  • Finally, from within the pkscreener directory, run python pkscreenercli.py. You are all set.

Running the executables

  • Download the suitable file according to your OS.

  • Linux & Mac users should make sure that the pkscreenercli.bin or pkscreenercli.run is having execute permission.

  • Run the file. Following window will appear after a brief delay.

  • Configure the parameters as per your requirement using Option > E.

config

  • Scanner Menus the scanner menus for each level/sub-level menulevel1 menulevel2 menulevel3

  • Following are the screenshots of screening and output results.

screening results

  • Once done, you can also save the results in an excel file.

Backtests

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

  • Once done, you can also view the output html file saved at the same location from where you launched the app.

Scanning as a scheduled job once or at regular intervals

  • Running it once with pre-defined inputs You can also run it as a one time job in any scheduler with pre-defined options. For example ./pkscreenercli.py -a Y -o X:12:10 -e (or pkscreenercli.exe -a Y -o X:12:10 -e if you're executing with the exe) will run the scanner for all Nifty stocks and find all stocks matching CCI filter, save the results in xlsx file and exit. ./pkscreenercli.py -a Y -o X:12:9:2.5 -e will run the scanner (menu option X) for all Nifty stocks (menu option 12) to find volume gainers (menu option 9) with at least the volume multiplier of 2.5 (input variable 2.5), save the results in xlsx file and exit (menu option -e). Passing in the -p option for example pkscreenercli.py -a Y -p -o X:12:6:1 -e will also silence all command line prints/outputs and just run silently for the given options, save results and exit. Try and see all options with ./pkscreenercli.py -h.

  • Running it at regular intervals If you want to runn it at regular intervals, you can just pass the interval in -c command line option. For example, ./pkscreenercli.py -a Y -o X:12:6:1 -c 180 will run it every 180 seconds with console outputs also being printed. If you'd just like it to run as a cron job without console outputs, you may also pass the -p parameter. For example, ./pkscreenercli.py -a Y -p -o X:12:6:1 -c 180

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 = 300d
daystolookback = 30
duration = 1d
minprice = 30
maxprice = 10000
volumeratio = 2
consolidationpercentage = 10
shuffle = y
cachestockdata = y
onlystagetwostocks = y
useema = n
logsEnabled = n
generaltimeout = 2.0
longtimeout = 4.0
maxnetworkretrycount = 10
backtestPeriod = 30

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
  1. 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:

  • Please feel free to Suggest improvements bugs by creating an issue.
  • Please follow the Guidelines for Contributing while making a Pull Request.

Disclaimer:

  • DO NOT use the results provided by the software 'solely' to make your trading decisions.
  • Always backtest and analyze the stocks manually before you trade.
  • The Author(s), the software and any related/unrelated entity will not be held liable for your own investing decisions or losses. The authors or this softfware does not make any claim about the correctness of the results.
  • This screener began as a fork of https://github.com/pranjal-joshi/Screeni-py but has since added a lot of additional scanners, backtesting, Telegram bots, Alerts and a number of modifications and improvements.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkscreener-0.42.20231225.42.tar.gz (572.0 kB view details)

Uploaded Source

Built Distribution

pkscreener-0.42.20231225.42-py3-none-any.whl (575.0 kB view details)

Uploaded Python 3

File details

Details for the file pkscreener-0.42.20231225.42.tar.gz.

File metadata

  • Download URL: pkscreener-0.42.20231225.42.tar.gz
  • Upload date:
  • Size: 572.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pkscreener-0.42.20231225.42.tar.gz
Algorithm Hash digest
SHA256 4b3414f09357df3255c1905f99238d5beee36680e042ad93c3c3dded1ad2e096
MD5 f6c0f9944bace6f59db96fe9f24164ac
BLAKE2b-256 c77eab9382de1e66f0be119f836ec97efc69c3b25adbbbd2b323dbab3ce955e5

See more details on using hashes here.

Provenance

File details

Details for the file pkscreener-0.42.20231225.42-py3-none-any.whl.

File metadata

File hashes

Hashes for pkscreener-0.42.20231225.42-py3-none-any.whl
Algorithm Hash digest
SHA256 82a665e17cae5cef2b0f83cd86550fd54545c213c5ed4b5441dbb5f274a03d2a
MD5 690f0b8b4842a6d0dfeac42ab0d0dd75
BLAKE2b-256 46f4455c9023380bbe8c0c0846ba8326c91dbe50604e2b8ac5fe0108f00135fa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page