FabTrader_Logo_Main
  • Home
  • Courses
    • Build Algo Trading Platform using Python Course
  • Store
  • Tools
  • Stories
  • About Me
Edit Content
FabTrader_Logo_Main
Welcome to FabTrader Community!

Course Dashboard
Store Account
Cart
Algo Trading Course
Other Courses
About Me
Store
Stories

Get in touch with me

hello@fabtrader.in

blog banner background shape images
  • FabTrader
  • March 15, 2025

Supercharge Your Algo Trading with Chartink Screener Extractor

  • 6 min read
  • 297 Views

A skilled mechanic depends on the right tools to diagnose and fix a car efficiently. Similarly, an algo trader needs a powerful set of tools to build, refine, and execute trading strategies effectively. One such indispensable tool is the Chartink Screener Python Extractor Utility – a Python-based module that allows traders to extract stock screening results from the Chartink Scanner website with ease.

Why Use the Chartink Screener Python Extractor?

As an algo trader, you often spend countless hours building automated strategies, gathering stock data, and backtesting setups. The traditional approach involves sourcing historical data, calculating indicators, and then implementing the strategy logic. However, this process can be cumbersome and resource-intensive.

With Chartink, traders can define their screening conditions directly on the platform, and the scanner does the heavy lifting by fetching live results. The Python Extractor Utility takes it a step further by automating the extraction of these results, enabling seamless execution of trading strategies without unnecessary overhead.

How the Utility Works

The Chartink Screener Python Extractor Utility requires just two simple inputs:

  1. Chartink Screen URL: The URL of the scanner that contains your trading logic.
  2. Scan Clause: This is the payload request that Chartink sends when executing a scan. It can be obtained by inspecting the Chartink webpage and navigating to the ‘Network’ tab under Developer Tools.

Using the Python module, you can extract and process these results programmatically, allowing for rapid execution of trades based on the scanner output.


#
"""
Fetch Chartink Scanner results from Chartink.com website using python

Input:
1. Chartink scan URL
2. Scan Clause (Inspect webpage and find this under 'Network' / 'process' / 'Payload' section)

-- Dependencies to be installed --
pip install requests
pip install pandas
pip install beautifulsoup4

Disclaimer:
The information provided is for educational and informational purposes only and
should not be construed as financial, investment, or legal advice. The content is based on publicly available
information and personal opinions and may not be suitable for all investors. Investing involves risks,
including the loss of principal.

"""

# Import all dependencies
import requests
import pandas as pd
from bs4 import BeautifulSoup as bs
import time


def chartink_scraper(url, scan_clause):
    # Retrieves the results of Chartink scanner. Input is the url and the scan clause
    # Example of scan clause : {'scan_clause': '( {33619} ( latest close > latest sma( latest close , 200 )
    # and latest close > latest sma( latest close , 100 ) and latest close > latest sma( latest close , 50 ) )'}
    # Scan clause can be obtained by doing an 'inspect' on the page and under 'Network' / 'process' / 'Payload'

    df = pd.DataFrame()

    try:
        with requests.Session() as s:
            r = s.get(url)
            soup = bs(r.text, "html.parser")
            csrf = soup.select_one("[name='csrf-token']")['content']
            s.headers['x-csrf-token'] = csrf
            s.headers['Content-Type'] = 'application/x-www-form-urlencoded'
            r = s.post('https://chartink.com/screener/process', data=scan_clause)
            df = pd.DataFrame().from_dict(r.json()['data'])
        return df
    except requests.exceptions.HTTPError as e:
        print("Error in network connection")
    except requests.exceptions.RequestException as e:
        print("Error extracting data from website: ", e)

if __name__ == "__main__":

    # Extract Chartink scan results into a dataframe
    # Sometimes extract fails temporarily due to network congestion. The loop below will try thrice before giving up
    try_again = 0
    smart_money_stocks = []
    while try_again <= 3:  # If the chartink extract fails, try for a couple of times
        scan_clause = {
            'scan_clause': '( {57960} ( ( {57960} ( latest sma( latest close , 5 ) '
                           '< latest close * 1.03 and latest sma( latest close , 20 ) '
                           '< latest close * 1.03 and latest sma( latest close , 50 ) '
                           '< latest close * 1.03 and latest sma( latest close , 100 ) '
                           '< latest close * 1.03 and latest sma( latest close , 200 ) '
                           '< latest close * 1.03 and latest sma( latest close , 5 ) '
                           '> latest close * 0.97 and latest sma( latest close , 20 ) '
                           '> latest close * 0.97 and latest sma( latest close , 50 ) '
                           '> latest close * 0.97 and latest sma( latest close , 100 ) '
                           '> latest close * 0.97 and latest sma( latest close , 200 ) '
                           '> latest close * 0.97 ) ) ) )'}
        url = 'https://chartink.com/screener/consolidatedbo'
        df = chartink_scraper(url, scan_clause)
        print(df)
        stocks_list = df['nsecode'].tolist()
        print(stocks_list)
        print("Extract Successful!")
        if df.empty:
            print("Extract failed. Going to try again...")
            time.sleep(10)
            try_again += 1
        else:
            break
#

Key Benefits of This Approach

1. No Need for Historical Data Downloading

One of the biggest challenges for algo traders is maintaining an extensive database of historical stock prices and indicator calculations. With Chartink handling these computations, you can focus on strategy execution rather than data collection.

2. No Need to Manually Code Indicators

Most trading strategies rely on technical indicators such as Moving Averages, RSI, MACD, etc. Instead of manually coding these indicators, you can define them in the Chartink scanner and fetch pre-calculated results instantly.

3. Rapid Strategy Implementation

Time is money in the trading world. The Chartink Screener Python Extractor speeds up the process by allowing traders to extract signals directly and execute trades without delay. Whether you’re trading manually or integrating with an algo-trading system, this tool ensures efficiency.

4. Versatile & Scalable

Whether you’re a retail trader or running a sophisticated algo-trading operation, this utility can be scaled to fit your needs. By automating the extraction of Chartink results, you can apply multiple strategies across different asset classes in a streamlined manner.

How to Get Started

  1. Define Your Screening Criteria: Use the Chartink Scanner to create a custom stock screen based on your trading rules.
  2. Extract the Scan Clause: Open the developer tools on your browser, go to the ‘Network’ tab, and capture the request payload when executing the scan.
  3. Use the Python Utility: Pass the Chartink Screen URL and Scan Clause into the Python module to extract the screened results.
  4. Execute Your Strategy: Once the results are obtained, integrate them into your trading system for automatic buy/sell execution.
Final Thoughts

In the fast-paced world of algo trading, efficiency and automation are paramount. The Chartink Screener Python Extractor Utility is a game-changer, enabling traders to extract valuable trading signals effortlessly. By leveraging Chartink’s powerful scanning capabilities alongside this Python module, traders can focus on execution rather than the tedious backend work of data processing and indicator calculations.

Whether you’re a beginner exploring algo trading or an experienced trader looking to optimize your workflow, this utility is a must-have in your trading toolkit. Try it out and take your trading efficiency to the next level!


Support this community : FabTrader.in is a one-person initiative dedicated to helping individuals on their F.I.R.E. journey. Running and maintaining this community takes time, effort, and resources. If you’ve found value in the content, consider making a donation to support this mission.

Donate

Disclaimer: The information provided in this article is for educational and informational purposes only and should not be construed as financial, investment, or legal advice. The content is based on publicly available information and personal opinions and may not be suitable for all investors. Investing involves risks, including the loss of principal. Always conduct your own research and consult a qualified financial advisor before making any investment decisions. The author and website assume no liability for any financial losses or decisions made based on the information presented.

FabTrader

Vivek is an algorithmic trader, Python programmer, and a passionate advocate of the F.I.R.E. (Financial Independence, Retire Early) movement. He achieved his financial independence at the age of 45 and is dedicated to helping others embark on their own journeys toward financial freedom.

Home
Store
Stories
Algo Trading Platform Using Python Course
About Me

©2024 Fabtrader.in - An unit of Rough Sketch Company. All Rights Reserved

Terms & Conditions
Privacy Policy