filmov
tv
Finding the Volatility of GameStop using Average True Range(ATR) — Plotting with Python and Plotly

Показать описание
Hello Everyone! My name is Andrew Fung, in this video, I will be showing you how to measure a stock's short-term volatility using the 14-day Average True Range in Python. It is one of the technical indicators that allows you to get an idea of the price changes and fluctuation happening to a stock.
#python #gme #wallstreetbets #atr #jupyternotebook #bb #datavisualization
Installation and Setup!
Check out my Github!
Timestamps
0:00 | Introduction
1:04 | Initial input
4:52 | True Range(TR) calculation
7:01 | Data processing
11:16 | Computing ATR(%)
15:09 | Data Visualisation
20:20 | Out tro
Full code:
———————————————————————————————
import pandas as pd
import datetime as dt
# change the default plotting to plotly
# specify stock ticker and timeframe in concern
stock_chosen = ‘GME’
days_concerned = 14
# retrieve data within the timeframe and store it in df
# get the closing price of the previous day
df['Previous Close'] = df['Adj Close'].shift()
# The 3 calculations of True Range
df['High - Low'] = df['High'] - df['Low']
df['High - PClose'] = abs(df['High'] - df['Previous Close'])
df['Low - PClose'] = abs(df['Low'] - df['Previous Close'])
# Compute the max out of the 3
df['True_Range'] = df[['High - Low','High - PClose','Low - PClose']].max(axis=1)
# get the average TR for the previous 14 days or days_concerned
# actual figure plotting
fig = df['ATR'].plot()
# customize the plot
title = f'{stock_chosen} {days_concerned}-day Average True Range %',
yaxis_title= 'ATR (%)',
legend_title='technical indicator'
)
# visualize the plot
———————————————————————————————
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
#python #gme #wallstreetbets #atr #jupyternotebook #bb #datavisualization
Installation and Setup!
Check out my Github!
Timestamps
0:00 | Introduction
1:04 | Initial input
4:52 | True Range(TR) calculation
7:01 | Data processing
11:16 | Computing ATR(%)
15:09 | Data Visualisation
20:20 | Out tro
Full code:
———————————————————————————————
import pandas as pd
import datetime as dt
# change the default plotting to plotly
# specify stock ticker and timeframe in concern
stock_chosen = ‘GME’
days_concerned = 14
# retrieve data within the timeframe and store it in df
# get the closing price of the previous day
df['Previous Close'] = df['Adj Close'].shift()
# The 3 calculations of True Range
df['High - Low'] = df['High'] - df['Low']
df['High - PClose'] = abs(df['High'] - df['Previous Close'])
df['Low - PClose'] = abs(df['Low'] - df['Previous Close'])
# Compute the max out of the 3
df['True_Range'] = df[['High - Low','High - PClose','Low - PClose']].max(axis=1)
# get the average TR for the previous 14 days or days_concerned
# actual figure plotting
fig = df['ATR'].plot()
# customize the plot
title = f'{stock_chosen} {days_concerned}-day Average True Range %',
yaxis_title= 'ATR (%)',
legend_title='technical indicator'
)
# visualize the plot
———————————————————————————————
Feel free to drop a like and comment if you enjoy and video and let me know if you want me to do other types of programming videos ;) !!!
Комментарии