# !pip install -e git+https://github.com/enzoampil/fastquant.git@master#egg=fastquant
from fastquant import get_stock_data
df = get_stock_data('JFC', '2018-01-01', '2019-01-01')
df.head()
close | |
---|---|
dt | |
2018-01-03 | 255.4 |
2018-01-04 | 255.0 |
2018-01-05 | 255.0 |
2018-01-08 | 256.0 |
2018-01-09 | 255.8 |
from matplotlib import pyplot as plt
df.close.plot(figsize=(10, 6))
plt.title("Daily Closing Prices of JFC\nfrom 2018-01-01 to 2019-01-01", fontsize=20)
Text(0.5, 1.0, 'Daily Closing Prices of JFC\nfrom 2018-01-01 to 2019-01-01')
import pandas as pd
ma30 = df.close.rolling(30).mean()
close_ma30 = pd.concat([df.close, ma30], axis=1).dropna()
close_ma30.columns = ['Closing Price', 'Simple Moving Average (30 day)']
close_ma30.plot(figsize=(10, 6))
plt.title("Daily Closing Prices vs 30 day SMA of JFC\nfrom 2018-01-01 to 2019-01-01", fontsize=20)
Text(0.5, 1.0, 'Daily Closing Prices vs 30 day SMA of JFC\nfrom 2018-01-01 to 2019-01-01')