diff --git a/aapl.h5 b/aapl.h5 new file mode 100644 index 0000000..b4705d0 Binary files /dev/null and b/aapl.h5 differ diff --git a/pandas_eval.py b/pandas_eval.py index b0f197f..6f2e55e 100644 --- a/pandas_eval.py +++ b/pandas_eval.py @@ -45,18 +45,56 @@ def macd(data): return ema_short - ema_long +data = {} if 0: # Get stock price via data reader start = datetime.datetime(2016,1,1) end = datetime.date.today() - apple = web.DataReader("AAPL", "av-monthly", start, end, api_key=key) - type(apple) + data = web.DataReader("AAPL", "av-monthly", start, end, api_key=key) +# data = web.DataReader("AAPL", "stooq", start, end) -pd_data = pd.read_csv("aapl.csv", names=['Dates', 'Price']) -np_data = np.flip(pd_data['Price'].to_numpy()) + type(data) + hdf = pd.HDFStore('aapl.h5') + hdf['open'] = data['open'] + hdf['close'] = data['close'] + hdf['high'] = data['high'] + hdf['low'] = data['low'] + hdf.close() +else: + hdf = pd.HDFStore('aapl.h5', 'r') + data['open'] = hdf['open'] + data['close'] = hdf['close'] + data['high'] = hdf['high'] + data['low'] = hdf['low'] + hdf.close() + +df = pd.DataFrame({"A": ["a", "b", "c", "a"]}) +print(df) + +v = data.values() +i = data.items() +print(data) + +data['ema'] = ema(data['close'], alpha=0.75) + +data['open'].plot() +data['close'].plot() +data['high'].plot() +data['low'].plot() +plt.legend() +plt.grid() +plt.show() + +np_data = np.flip(data['close'].to_numpy()) + +plt.subplot(211) plt.plot(np_data, label='Price') plt.plot(ema(np_data), label='EMA') +plt.legend() +plt.grid() + +plt.subplot(212) plt.plot(macd(np_data), label='MACD') plt.legend() plt.grid()