Overall Statistics
Total Trades
2487
Average Win
0.73%
Average Loss
-0.71%
Compounding Annual Return
4.755%
Drawdown
41.000%
Expectancy
0.008
Net Profit
26.138%
Sharpe Ratio
0.189
Probabilistic Sharpe Ratio
2.828%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
1.03
Alpha
0.022
Beta
0.111
Annual Standard Deviation
0.154
Annual Variance
0.024
Information Ratio
-0.161
Tracking Error
0.221
Treynor Ratio
0.264
Total Fees
$282936.26
Estimated Strategy Capacity
$770000.00
Lowest Capacity Asset
OEF RZ8CR0XXNOF9
Portfolio Turnover
130.41%


from AlgorithmImports import *
import statsmodels.api as sm
class EmotionalLightBrownGuanaco(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2018, 1, 1)  
        self.SetEndDate(2023, 1, 1)  
        
        self.SetCash(1000000)
        res=Resolution.Hour # change to Resolution.Minute to compare!!!!

    

        self.SPY = self.AddEquity("SPY",res ).Symbol
        self.SetBenchmark("SPY")
    
        self.tickers=['GDX',"OEF"]
        self.symbols=[]
     
    
        for i in  self.tickers:
            self.symbols.append(self.AddEquity(i, res).Symbol)

    
        self.Schedule.On(
            self.DateRules.EveryDay(),
            self.TimeRules.AfterMarketOpen('SPY', 60),
            self.rebalance_when_in_the_market)
            

    def rebalance_when_in_the_market(self):
        if self.Time.day%2!=0:
            self.SetHoldings(self.symbols[1],-0.5)
            self.SetHoldings(self.symbols[0],0.5)
        else:
            self.SetHoldings(self.symbols[0],-0.5)
            self.SetHoldings(self.symbols[1],0.5)