Overall Statistics |
Total Trades 133 Average Win 0.93% Average Loss -0.63% Compounding Annual Return 11.702% Drawdown 13.400% Expectancy 0.678 Net Profit 39.418% Sharpe Ratio 0.925 Probabilistic Sharpe Ratio 41.273% Loss Rate 32% Win Rate 68% Profit-Loss Ratio 1.48 Alpha 0.043 Beta 0.36 Annual Standard Deviation 0.091 Annual Variance 0.008 Information Ratio -0.227 Tracking Error 0.135 Treynor Ratio 0.233 Total Fees $298.54 Estimated Strategy Capacity $69000000.00 Lowest Capacity Asset BND TRO5ZARLX6JP |
class FormalBlueCaterpillar(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 1) self.SetEndDate(2021, 1, 1) self.SetCash(100000) self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol self.bnd = self.AddEquity("BND", Resolution.Daily).Symbol self.sma = self.SMA(self.spy, 30, Resolution.Daily) self.rebalancetime = datetime.min self.uptrend = True def OnData(self, data): if not self.sma.IsReady or self.spy not in data or self.bnd not in data: return if data[self.spy].Price >= self.sma.Current.Value: if self.Time >= self.rebalancetime or not self.uptrend: self.SetHoldings(self.spy, 0.8) self.SetHoldings(self.bnd, 0.2) self.uptrend = True self.rebalancetime = self.Time + timedelta(30) elif self.Time >= self.rebalancetime or self.uptrend: #Check ob es Zeit für Rebalance ist oder ob wir vorher in einem Uptrend waren self.SetHoldings(self.spy, 0.2) self.SetHoldings(self.bnd, 0.8) self.uptrend = False self.rebalancetime = self.Time + timedelta(30) self.Plot("Benchmark", "SMA", self.sma.Current.Value)