- improved

git-svn-id: http://moon:8086/svn/projects/Stock@298 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-12-09 21:17:14 +00:00
parent 7128ffc94d
commit 1aeffb1ff8
+12 -14
View File
@@ -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()