diff --git a/pandas_eval.py b/pandas_eval.py index f6d1bcb..d016fda 100644 --- a/pandas_eval.py +++ b/pandas_eval.py @@ -89,12 +89,9 @@ def bollinger(data, window_days, f=2): mid = np.array(sma(tp_df, key='tp', window_days=window_days)) upper = mid + f * stddev lower = mid - f * stddev - print (mid) - print (upper) - print (lower) result = pd.DataFrame(upper, index=data.index, columns=['upper']) result['lower'] = lower - result['mid'] = mid + result['mid'] = stddev return result data = {} @@ -119,21 +116,22 @@ data['ema'] = ema(data, key='close', alpha=0.75) data['macd'] = macd(data, key='close') data['sma'] = sma(data, key='close', window_days=30) boll = bollinger(data, window_days=30) -data['boll(up)'] = boll['upper'] -data['boll(mid)'] = boll['mid'] -data['boll(low)'] = boll['lower'] -plt.subplot(211) +plt.subplot(311) data['close'].plot() -#data['ema'].plot() -#data['sma'].plot() -data['boll(up)'].plot() -data['boll(mid)'].plot() -data['boll(low)'].plot() +data['ema'].plot() +data['sma'].plot() plt.legend() plt.grid() -plt.subplot(212) +plt.subplot(312) +boll['upper'].plot() +boll['mid'].plot() +boll['lower'].plot() +plt.legend() +plt.grid() + +plt.subplot(313) data['macd'].plot() plt.legend() plt.grid()