Click here to Skip to main content
14,573,882 members
Rate this:
Please Sign up or sign in to vote.
See more:
The code when i use TSLA , FB , and other us stocks it will work but for indian stocks it wont like ADANIPORTS etc etc . So, pls anyone tell me how to get data for indian stocks from yahoo or any other ....

What I have tried:

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web

style.use('ggplot')

start = dt.datetime(2000,1,1)
end = dt.datetime(2020,5,22)
df = web.DataReader('TSLA' ,  'yahoo' , start , end)
df.to_csv('tsla.csv')
Posted
Updated 22-May-20 5:44am
Comments
Richard MacCutchan 22-May-20 11:34am
   
You need to get the web information from the correct feed. If the one you are using is US based then it probably will not include Indian stocks.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Looks like you're using Yahoo Finance, where Indian stocks have an ".NS" suffix. For example, try "TATAMOTORS.NS" for Tata Motors.
   
Comments
PythonPreran 22-May-20 21:42pm
   
WoW man awesome thanks for the help , it worked . I actually didnt find anywhere on net , so i asked . Thanks by the way it worked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100