Change indicators to return their results and work on three indicator strat

This commit is contained in:
2020-11-02 09:10:01 -05:00
parent 4679910374
commit 43e297c075
3 changed files with 55 additions and 25 deletions

View File

@@ -27,16 +27,20 @@ def experiment1():
df["Manual"] = marketsim.compute_portvals(orders, start_value)
df["Orders Manual"] = orders["Shares"]
# indicators.price_sma(df, symbol, 21)
# sma = indicators.sma(df, symbol, [9, 21])
# rsi = indicators.rsi(df, symbol)
price_sma = indicators.price_sma(df, symbol, [21])
bb = indicators.bollinger_band(df, symbol)
sma = indicators.sma(df, symbol, [9, 21])
rsi = indicators.rsi(df, symbol)
macd = indicators.macd(df, symbol).copy()
fig, ax = plt.subplots(4, sharex=True)
df[symbol].plot(ax=ax[0])
macd.plot(ax=ax[3])
df[["Benchmark", "Manual"]].plot(ax=ax[1])
df[["Orders Benchmark", "Orders Manual"]].plot(ax=ax[2])
df[[symbol]].plot(ax=ax[0])
# bb.plot(ax=ax[0])
price_sma.plot(ax=ax[1])
macd.plot(ax=ax[2])
rsi.plot(ax=ax[3])
# df[["Benchmark", "Manual"]].plot(ax=ax[1])
# df[["Orders Benchmark", "Orders Manual"]].plot(ax=ax[2])
for a in ax:
a.grid()