diff --git a/pandas_eval.py b/pandas_eval.py index ce31795..1ba8cda 100644 --- a/pandas_eval.py +++ b/pandas_eval.py @@ -1,7 +1,9 @@ import pandas as pd +import pandas_datareader.data as web import numpy as np import math import matplotlib.pyplot as plt +import datetime # Stock Investors Financial Math # https://www.fmlabs.com/reference/default.htm?url=SimpleMA.htm @@ -14,6 +16,8 @@ import matplotlib.pyplot as plt # Knowledge # https://www.investopedia.com/articles/technical/02/050602.asp +key = '0UO7Z2MVZ2YSQSVE' + def sin(f, a, N): result = np.empty(0) @@ -39,9 +43,15 @@ def macd(data): return ema_short - ema_long +# Get stock price via data reader +if 0: + start = datetime.datetime(2016,1,1) + end = datetime.date.today() + apple = web.DataReader("AAPL", "av-monthly", start, end, api_key=key) + type(apple) + pd_data = pd.read_csv("aapl.csv", names=['Dates', 'Price']) np_data = np.flip(pd_data['Price'].to_numpy()) -a = sin(2, 1, 100) plt.plot(np_data, label='Price') plt.plot(ema(np_data), label='EMA')