|
|
|
|
@ -43,7 +43,7 @@ def run(strategy, data, fund_mode=False):
|
|
|
|
|
)
|
|
|
|
|
thestrats = cerebro.run()
|
|
|
|
|
thestrat = thestrats[0]
|
|
|
|
|
cerebro.plot(iplot=False, style="candlestick")
|
|
|
|
|
# cerebro.plot(iplot=False, style="candlestick")
|
|
|
|
|
return thestrat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,14 +69,16 @@ if __name__ == "__main__":
|
|
|
|
|
# startDate = datetime.datetime.fromisoformat("2000-01-01")
|
|
|
|
|
# endDate = datetime.datetime.fromisoformat("2022-01-01")
|
|
|
|
|
print(stockList[0])
|
|
|
|
|
for period_years in (20, 50):
|
|
|
|
|
for period_years in (1, 2, 5):
|
|
|
|
|
endDate = datetime.datetime.now()
|
|
|
|
|
startDate = endDate - datetime.timedelta(days=period_years * 365)
|
|
|
|
|
stockData = get_data(stockList[0], startDate, endDate)
|
|
|
|
|
actualStart: datetime.datetime = stockData.index[0]
|
|
|
|
|
data = bt.feeds.PandasData(dataname=stockData)
|
|
|
|
|
|
|
|
|
|
for i, strategy in enumerate((st.SmaCross,)):
|
|
|
|
|
for i, strategy in enumerate(
|
|
|
|
|
(st.SmaCross, st.DCA, st.QDCA, st.VA, st.QVA, st.SmaVA)
|
|
|
|
|
):
|
|
|
|
|
therun = run(strategy, data)
|
|
|
|
|
dd = therun.analyzers.drawdown
|
|
|
|
|
ret = therun.analyzers.returns
|
|
|
|
|
|