This TradingView-style Nifty 50 heatmap is built with Highcharts and Python: a Flask app fetches prices for the 50 index stocks with yfinance and a Highcharts treemap draws them, where the size of each box is the company’s market cap and the colour is its percentage change. The full source code is on GitHub (README).
- Box size = market capitalisation, box colour = % change, from red through grey to green.
- Stack: Python Flask backend, yfinance for prices, Highcharts treemap on the frontend.
- Run it locally with
pip install -r requirements.txtandpython app.py, then open localhost:5000. - Highcharts is free only for personal, non-commercial use; commercial use needs a paid licence.
As an investor, having a clear visual overview of market performance is essential. We are excited to introduce our latest project: a TradingView-inspired heatmap visualization for the Nifty 50 index. This tool provides a quick and intuitive way to understand the performance of India’s top 50 companies.

What is the Nifty 50 Heatmap?
The Nifty 50 Heatmap is an interactive, color-coded visualization that displays the performance of the 50 stocks in India’s benchmark Nifty 50 index. Each stock is represented by a rectangle with the following features:
- Size: Reflects the company’s market capitalization. Larger rectangles represent companies with higher market caps.
- Color: Indicates stock performance. Shades of green signify positive returns, while shades of red indicate negative returns. The intensity of the color correlates with the magnitude of the change.
- Information Display: Shows the stock’s symbol, current price, and percentage change. For smaller rectangles, only the company logo is displayed to maintain clarity.
A small squarified treemap that works like the Nifty 50 heatmap: box size is weight, colour is the day’s change. Switch scenarios and see how the picture changes.
Sample sector labels and made-up moves for illustration only, not live Nifty data. The real app in this post pulls prices from Yahoo Finance and sizes boxes by market capitalisation.
How We Built the Nifty 50 Heatmap with Highcharts
We utilized python flask and highcharts to create this treemap visualization:
- Flask: A lightweight Python web framework that serves as the backend for our application.
- Highcharts: A versatile JavaScript charting library that powers our interactive treemap visualization.
- yfinance: A Python library that fetches real-time stock data from Yahoo Finance.
The application fetches real-time data for the Nifty 50 stocks, processes it, and sends it to the frontend, where Highcharts renders the interactive heatmap.
How to run the Nifty 50 heatmap locally
The repository contains app.py (the Flask app), requirements.txt, symbols.csv (the Nifty 50 symbols) and the templates and static folders. To run it:
git clone https://github.com/marketcalls/highcharts-heatmap.git
cd highcharts-heatmap
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py # then open http://localhost:5000
- Edit
symbols.csvto show a different list of stocks, for example Nifty Next 50 or your own watchlist. - Change the colours by editing the
colorStopsarray inindex.html. - The fetch interval is set by the
timedeltavalue inapp.py.
The Highcharts treemap in a few lines
If you want to understand the chart part on its own, this minimal page draws a heatmap-style treemap where value sets the box size and colorValue sets the colour on a red to green colour axis. Note that the colour axis needs the coloraxis module (or heatmap) loaded before treemap; tested with Highcharts 13.1.1.
<div id="heatmap" style="height:500px"></div>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/coloraxis.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<script>
Highcharts.chart('heatmap', {
colorAxis: {
min: -3, max: 3,
stops: [[0, '#f63538'], [0.5, '#414554'], [1, '#30cc5a']]
},
series: [{
type: 'treemap',
layoutAlgorithm: 'squarified',
data: [
// value = market cap (size), colorValue = % change (colour)
{ name: 'STOCK A', value: 120, colorValue: 1.8 },
{ name: 'STOCK B', value: 80, colorValue: -0.6 },
{ name: 'STOCK C', value: 45, colorValue: -2.4 },
{ name: 'STOCK D', value: 30, colorValue: 0.3 }
],
dataLabels: { format: '{point.name}<br>{point.colorValue:.2f}%' }
}],
title: { text: 'Nifty 50 style heatmap' },
tooltip: { pointFormat: '{point.name}: {point.colorValue:.2f}%' }
});
</script>
Key Features
- Real-time Data: The heatmap updates with the latest stock prices and performance metrics.
- Interactive Tooltips: Hover over any stock to see detailed information.
- Responsive Design: The heatmap adjusts to different screen sizes for optimal viewing on any device.
- Performance Optimization: We use multithreading to fetch stock data efficiently, ensuring quick load times.
Benefits for Investors
This heatmap offers several advantages for investors:
- Quick Market Overview: Understand overall market sentiment at a glance.
- Sector Performance: Identify which sectors are performing well or underperforming.
- Relative Performance: Easily compare the performance of different stocks.
- Market Cap Visualization: Understand the weight of each company in the index.
How to read a Nifty 50 heatmap
- Look at the biggest boxes first. A handful of heavyweights drive most of the index move, so a green index on a mostly red map means the large caps are carrying it.
- Check breadth. Count green against red boxes; a rising index with more red boxes is a narrow, weaker rally.
- Spot sector rotation. When all the banks are one colour and all the IT names the other, money is moving between sectors.
- Mind the colour scale. If ±3% is the full scale, a 0.3% move looks almost grey; change the scale for quiet days.
Licensing note on Highcharts
The marketcalls code is MIT licensed, but Highcharts itself is not free for every use. Its licence agreement gives a free Personal Use licence for entirely non-commercial projects and a free Educational licence; any commercial use, including work inside a company, freelance work or internal business dashboards, needs a paid commercial licence. If that is a problem, the same treemap can be built with Plotly, as shown in visualizing Nifty 50 market capitalization using Plotly treemap.
Future Enhancements
We are continually looking to improve and expand this tool. Some ideas for future updates include:
- Adding more indices (e.g., Sensex, Nifty Next 50)
- Implementing time range selection (e.g., 1-day, 1-week, 1-month views)
- Including additional metrics like volume or P/E ratio
- Creating custom watchlists
Our TradingView-style Nifty 50 Heatmap Visualization is designed to help investors with a clear, visual representation of complex market data. We welcome your feedback and contributions to enhance this tool further!
For other ways to visualise index data, see our Nifty 50 heatmap Python tutorial with OpenAlgo and Plotly, Nifty monthly and quarterly returns heatmap with yfinance and Seaborn and our yfinance guide.
Happy investing!
Frequently Asked Questions
What is a Nifty 50 heatmap?
It is a treemap of the 50 Nifty stocks where each box is sized by market cap and coloured by the day’s percentage change, so you can see the market’s breadth and the heavyweights’ moves at a glance.
How do I make a stock heatmap in Python?
Fetch prices and market caps (for example with yfinance), then draw a treemap with Highcharts, Plotly or squarify, using market cap as size and % change as colour.
Is Highcharts free to use?
Only for personal non-commercial and educational use. Commercial use requires a paid Highcharts licence.
Why are some boxes grey on the heatmap?
Grey sits at the middle of the colour scale and means the stock is roughly unchanged for the day.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

