Links

Display chart from ticker

Tags: #yahoofinance #trading #plotly #naas_drivers #investors #snippet #image
Author: Florent Ravenel
With this template, you can get data from any ticker available in Yahoo finance.

Input

Import libraries

from naas_drivers import yahoofinance, plotly

Input parameters

👉 Here you can change the ticker, timeframe and add moving averages analysiss
ticker = "TSLA"
date_from = -365
date_to = "today"
interval = '1d'
moving_averages = [20, 50]

Model

Get dataset from Yahoo Finance

df_yahoo = yahoofinance.get(ticker,
date_from=date_from,
date_to=date_to,
interval=interval,
moving_averages=moving_averages)

Output

Display chart

chart = plotly.linechart(df_yahoo,
x="Date",
y=["Close", "MA20", "MA50"],
showlegend=True,
title=f"{ticker} stock as of today")