#!/usr/bin/env python # coding: utf-8 # Open In Colab # # Installation # In[1]: # !pip install -e git+https://github.com/enzoampil/fastquant.git@master#egg=fastquant # # Get stock data # In[3]: from fastquant import get_stock_data df = get_stock_data('JFC', '2018-01-01', '2019-01-01') df.head() # # Plot daily closing prices # In[4]: 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) # # Analyze with a simple moving average (SMA) trading strategy # In[5]: 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) # In[ ]: