Overall Statistics
Total Trades
53
Average Win
1.99%
Average Loss
-0.58%
Compounding Annual Return
35.831%
Drawdown
10.400%
Expectancy
2.425
Net Profit
40.467%
Sharpe Ratio
1.671
Probabilistic Sharpe Ratio
69.995%
Loss Rate
23%
Win Rate
77%
Profit-Loss Ratio
3.45
Alpha
0.295
Beta
0.071
Annual Standard Deviation
0.186
Annual Variance
0.035
Information Ratio
0.269
Tracking Error
0.328
Treynor Ratio
4.373
Total Fees
$91.03
Estimated Strategy Capacity
$39000000.00
# 
# ----------------------------------------------------------------
STOCKS = ['QQQ', 'XLP', 'MDY']; BONDS = ['TLT', 'IEF']; LEV = 1.0;
# ----------------------------------------------------------------
class FocusedBlueBee(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2021, 2, 8)
        self.SetCash(100000)
        
        self.stocks = [self.AddEquity(ticker, Resolution.Daily).Symbol for ticker in STOCKS]
        self.bonds = [self.AddEquity(ticker, Resolution.Daily).Symbol for ticker in BONDS]
        self.MKT = self.AddEquity('SPY', Resolution.Daily).Symbol 
        self.mom_lookback = 10
        self.ret_reb_month = 0
        self.wt = {}
        self.SetWarmUp(self.mom_lookback + 1)
        self.mom = self.MOMP(self.MKT, self.mom_lookback, Resolution.Daily)

        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen('SPY', 120),
            self.trade) 

    def trade(self):
        if self.ret_reb_month==self.Time.month: return
            
        self.ret_reb_month = self.Time.month
        self.bull = self.mom.Current.Value > 0
        
        for sec in self.stocks: 
            self.wt[sec] = LEV/len(self.stocks) if self.bull  else 0;
        for sec in self.bonds: 
            self.wt[sec] = 0 if self.bull else LEV/len(self.bonds);

        for sec, weight in self.wt.items():
            self.SetHoldings(sec, weight)