Overall Statistics
Total Trades
199
Average Win
1.00%
Average Loss
-0.61%
Compounding Annual Return
12.567%
Drawdown
22.700%
Expectancy
1.533
Net Profit
394.255%
Sharpe Ratio
1.27
Probabilistic Sharpe Ratio
75.879%
Loss Rate
4%
Win Rate
96%
Profit-Loss Ratio
1.64
Alpha
0.097
Beta
0.316
Annual Standard Deviation
0.104
Annual Variance
0.011
Information Ratio
0.131
Tracking Error
0.163
Treynor Ratio
0.418
Total Fees
$208.24
class Stock_Bond_Portfolio(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2007, 6, 1)
        self.SetEndDate(2020, 11, 25)
        self.cap = 100000
        self.SetCash(self.cap)
        res = Resolution.Daily
        
        self.AddEquity('SPY')
        self.AddEquity('TLT')
        self.AddEquity('QQQ')
        self.spy = []

        self.Schedule.On(self.DateRules.MonthStart(), self.TimeRules.AfterMarketOpen('SPY', 75), self.rebalance)
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.BeforeMarketClose('SPY', 0), self.record_vars)

    def rebalance(self):
        self.SetHoldings("TLT", 0.5)
        self.SetHoldings("QQQ", 0.5)
        
    def record_vars(self): 
    
        hist = self.History(['SPY'], 2, Resolution.Daily)['close'].unstack(level= 0).dropna() 
        self.spy.append(hist['SPY'].iloc[-1])
        spy_perf = self.spy[-1] / self.spy[0] * self.cap
        self.Plot('Strategy Equity', 'SPY', spy_perf)