<jupyter_start><jupyter_text>Stock Kurtosis Chart<jupyter_code># Library
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as scs

import warnings
warnings.filterwarnings("ignore")

from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()
start = '2016-01-01' #input
end = '2020-07-01' #input
symbol = 'AMD'
df = yf.download("AMD", start, end)
returns = df['Adj Close'].pct_change()[1:].dropna()
def kurtosis(returns):
    stock_kurtosis = returns.kurtosis()
    return stock_kurtosis
# Compute the running kurtosis
running = [kurtosis(returns[i-90:i]) for i in range(90, len(returns))]

# Plot running kurtosis up to 100 days before the end of the data set
_, ax1 = plt.subplots(figsize=(12,8))
ax1.plot(range(90, len(returns)-100), running[:-100])
ticks = ax1.get_xticks()
ax1.set_xticklabels([df.index[int(i)].date() for i in ticks[:-1]]) # Label x-axis with dates
plt.title(symbol + ' Kurtosis')
plt.xlabel('Date')
plt.ylabel('Kurtosis')
kt = kurtosis(returns)
kt
running = [kurtosis(returns[i-90:i]) for i in range(90, len(returns))]
running<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14022787028921999, 'fraction_numerical': 0.03856266432953549, 'mean_word_length': 5.879518072289157, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '213988', 'license': 'MIT', 'n_tokens_mistral': 455, 'n_tokens_neox': 422, 'n_words': 111, 'path': 'Python_Stock/Stock_Measurement_Ratio_Chart/Stock_Kurtosis_Chart.ipynb', 'repo_name': 'chunsj/Stock_Analysis_For_Quant', 'size': '1141'}