Hi,
Like volume indicator on charts for each scrip, is there any website or tool that allow to add all the constituents volume for the index in live market.
Like I wanna see the total volume being traded for NIFTY 50 stocks combined. I don’t want to see for nifty future scrip but add the volume from all scrips it constitutes and plot it in form of bar graph.
I know I can create it in Grafana by writing script on my own.
I am just wondering if anyone has already done it or using it or publicly available, as there would be more such tools, I would love to know.
Thanks,
i am not sure if there are any ready made options online (check tradingview), but you can try running the below code. its in python. either use collab or local ide.
the base code (not provided here) i run it to get volumes of stocks and other such ideas. but i clipped and modified some part of the code for your needs. this also auto executes every 60 seconds which should give you real time data. i mean you can try and modify it further as per your needs… it prints bar graph as well.
import yfinance as yf
import matplotlib.pyplot as plt
import time
# List of nifty stock symbols
nifty50_symbols = ['RELIANCE.NS', 'TCS.NS', 'HDFCBANK.NS', 'INFY.NS', 'HINDUNILVR.NS'] # Add all nifty symbols as per you needs
def fetch_volume_data():
volume_data = {}
for symbol in nifty50_symbols:
stock = yf.Ticker(symbol)
hist = stock.history(period="1d", interval="1m") # fetch today's data with 1-minute intervals
if not hist.empty:
volume_data[symbol] = hist['Volume'].iloc[-1] # get the most recent volume
return volume_data
def plot_volume_data(volume_data):
plt.bar(volume_data.keys(), volume_data.values())
plt.xlabel('Stock Symbol')
plt.ylabel('Volume')
plt.title('Combined Trading Volume of NIFTY 50 Constituents')
plt.xticks(rotation=90)
plt.show()
def main():
while True:
volume_data = fetch_volume_data()
plt.figure(figsize=(15, 8))
plot_volume_data(volume_data)
time.sleep(60) # update every 60 seconds
if __name__ == "__main__":
main()
if you run locally make sure to pip the libraries yfinance, matplotlib and time. i think time is inbuilt, but just check. i ran this once in collab post modification and it works.