| Overall Statistics |
|
Total Trades 18 Average Win 11.23% Average Loss -14.72% Compounding Annual Return 20.204% Drawdown 25.900% Expectancy 0.322 Net Profit 175.411% Sharpe Ratio 0.761 Probabilistic Sharpe Ratio 21.879% Loss Rate 25% Win Rate 75% Profit-Loss Ratio 0.76 Alpha 0.214 Beta -0.049 Annual Standard Deviation 0.274 Annual Variance 0.075 Information Ratio 0.312 Tracking Error 0.326 Treynor Ratio -4.218 Total Fees $618.24 |
class ModulatedOptimizedShield(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 2, 13) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity('SPXL', Resolution.Daily)
self.AddEquity('TBT', Resolution.Daily)
self.prev_close = -1
self.sma = self.SMA('SPXL', 50, Resolution.Daily)
self.SetWarmup(50)
def OnData(self, data):
if self.IsWarmingUp:
return
if not data.ContainsKey('SPXL') or data['SPXL'] is None:
self.prev_close = -1
return
if not self.Portfolio.Invested:
self.SetHoldings('TBT', -1)
close = data['SPXL'].Close
if close > 0 and close / self.prev_close < .9 and not self.Portfolio['SPXL'].Invested:
shares = self.Portfolio.Cash / close - .03
self.MarketOrder('SPXL', shares)
elif close < self.sma.Current.Value:
self.Liquidate('SPXL')
self.prev_close = close