Get stock data via Yahoo finance API

Home   »   Get stock data via Yahoo finance API

# get Tesla stock information
tsla = yf.Ticker("TSLA")

# get historical market data
df = tsla.history(period="max")

# use index as column (index consists of dates)
df['Date'] = df.index

# use only the first 100 rows
df = df[:100]

# show df
df

Leave a Reply

Your email address will not be published.