EOD Data for NSE

Data for nse with API using python

The most important resource for algorithm development is: Data

To collect NSE End Of Day data we can use API calls.

Language: Python 3.6

import os
import pandas as pd

list_of_stocks = ['HDFCBANK','RELIANCE']

def get_eod_data_cash_stocks(list_of_stocks):
    count = 0
    for symbol in list_of_stocks:
        if count % 5 == 0 and count > 0:
            time.sleep(120)
        else:
            url = 'https://www.alphavantage.co/query?function='+
                  'TIME_SERIES_DAILY_ADJUSTED&symbol=NSE:'+ 
                  symbol+
                  '&outputsize=full&apikey=INSERTAPIKEY&datatype=csv'
            df = pd.read_csv(url)
            df = df.iloc[::-1]
            df.to_excel(r'c:/location/for/files'+str(symbol)
                                          +'.xlsx')
            count += 1
            print(symbol, count)
    print('Data Downloaded')    # print(symbol)

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *