@@ -309,8 +309,9 @@ <h3 id="example" class="title has-text-centered">
309309 n2 = 20
310310
311311 def init(self):
312- self.sma1 = self.I(SMA, self.data.Close, self.n1)
313- self.sma2 = self.I(SMA, self.data.Close, self.n2)
312+ close = self.data.Close
313+ self.sma1 = self.I(SMA, close, self.n1)
314+ self.sma2 = self.I(SMA, close, self.n2)
314315
315316 def next(self):
316317 if crossover(self.sma1, self.sma2):
@@ -319,8 +320,9 @@ <h3 id="example" class="title has-text-centered">
319320 self.sell()
320321
321322
322- bt = Backtest(GOOG, SmaCross, cash=10000,
323- commission=.002, exclusive_orders=True)
323+ bt = Backtest(GOOG, SmaCross,
324+ cash=10000, commission=.002,
325+ exclusive_orders=True)
324326
325327output = bt.run()
326328bt.plot()</ code > </ pre >
@@ -335,7 +337,12 @@ <h3 id="example" class="title has-text-centered">
335337Equity Final [$] 68935.12
336338Equity Peak [$] 68991.22
337339Return [%] 589.35
338- Buy & Hold Return [%] 703.46
340+ Buy & Hold Return [%] 703.46
341+ Return (Ann.) [%] 25.42
342+ Volatility (Ann.) [%] 38.43
343+ Sharpe Ratio 0.66
344+ Sortino Ratio 1.30
345+ Calmar Ratio 0.77
339346Max. Drawdown [%] -33.08
340347Avg. Drawdown [%] -5.58
341348Max. Drawdown Duration 688 days 00:00:00
@@ -350,9 +357,6 @@ <h3 id="example" class="title has-text-centered">
350357Profit Factor 2.13
351358Expectancy [%] 6.91
352359SQN 1.78
353- Sharpe Ratio 0.18
354- Sortino Ratio 0.44
355- Calmar Ratio 0.06
356360_strategy SmaCross(n1=10, n2=20)</ samp > </ pre >
357361 </ div >
358362 </ div >
0 commit comments