Skip to content

Instantly share code, notes, and snippets.

import plotly.graph_objs as go
#Declare figure
fig = go.Figure()
#add a trace
fig.add_trace(go.Scatter(x=tesla_df.index, y=tesla_df['Close']))
#Update X and Y axis with title
fig.update_xaxes(
title = 'Date',rangeslider_visible=True
)
import pandas as pd
from pandas_datareader import data, wb
import datetime
start = pd.to_datetime('2020-02-04')
end = pd.to_datetime('today')
tesla_df = data.DataReader('TSLA', 'yahoo', start , end)
tesla_df
import pandas as pd
from pandas_datareader import data, wb
import datetime
start = pd.to_datetime('2020-02-04')
end = pd.to_datetime('today')
tesla_df = data.DataReader('TSLA', 'yahoo', start , end)
tesla_df
# Raw Package
import numpy as np
import pandas as pd
#Data Source
import yfinance as yf
#Data viz
import plotly.graph_objs as go
#Interval required 5 minutes
data = yf.download(tickers='UBER', period='5d', interval='5m')
#Print data
data
# Raw Package
import numpy as np
import pandas as pd
#Data Source
import yfinance as yf
#Data viz
import plotly.graph_objs as go
data = yf.download(tickers='SPY', period='1d', interval='1m')
#Draw the middle band, higher band, lowest band
data['Middle Band'] = data['Close'].rolling(window=21).mean()
data['Upper Band'] = data['Middle Band'] + 1.96*data['Close'].rolling(window=21).std()
data['Lower Band'] = data['Middle Band'] - 1.96*data['Close'].rolling(window=21).std()