Overall Statistics
Total Trades
960
Average Win
0.94%
Average Loss
-0.36%
Compounding Annual Return
16.527%
Drawdown
17.900%
Expectancy
0.620
Net Profit
182.659%
Sharpe Ratio
1.112
Probabilistic Sharpe Ratio
56.207%
Loss Rate
55%
Win Rate
45%
Profit-Loss Ratio
2.64
Alpha
0.076
Beta
0.388
Annual Standard Deviation
0.106
Annual Variance
0.011
Information Ratio
0.076
Tracking Error
0.127
Treynor Ratio
0.303
Total Fees
$1171.94
Estimated Strategy Capacity
$74000000.00
Lowest Capacity Asset
CMB R735QTJ8XC9X
# MAC and MACD static portfolio

# ------------------------------------------------------------------------------------
STOCKS = ["AAPL", "MSFT", "GOOGL", "AMZN", "FB", "TSLA", "NVDA", "V", "JPM", "JNJ"]; 
MA_F = 5; MA_S = 20; FAST = 12; SLOW = 26; SIGN = 9; LEV = 0.95;
# ------------------------------------------------------------------------------------

class SimpleStockTrade_KOK(QCAlgorithm):
   
    def Initialize(self):
        self.SetStartDate(2015, 1, 1)  
        self.SetEndDate(2021, 10, 15)
        self.SetCash(100000)  
        res = Resolution.Daily
        self.fast_sma = {}
        self.slow_sma = {}
        self.macd = {}
        self.signalDeltaPercent = {}
        self.stocks =  [self.AddEquity(ticker, Resolution.Minute).Symbol for ticker in STOCKS]
        for sec in self.stocks:
            self.fast_sma[sec] = self.SMA(sec, MA_F, res)
            self.slow_sma[sec] = self.SMA(sec, MA_S, res)
            self.macd[sec] = self.MACD(sec, FAST, SLOW, SIGN, MovingAverageType.Exponential, res)
        self.SetWarmUp(150)
        
       
    def OnData(self, data):
        if self.IsWarmingUp: return
        if self.Time.time() != time(9, 31): return
    
        for sec in self.stocks:
            if not (self.fast_sma[sec].IsReady) or not (self.slow_sma[sec].IsReady): continue
            if not (self.macd[sec].IsReady): continue
            self.signalDeltaPercent[sec] = (self.macd[sec].Current.Value - self.macd[sec].Signal.Current.Value)/self.macd[sec].Fast.Current.Value
            
            if self.Portfolio[sec].Quantity <= 0:
                if self.slow_sma[sec] < self.fast_sma[sec] and self.signalDeltaPercent[sec] > 0:
                    self.SetHoldings(sec, LEV / len(self.stocks))

            elif self.Portfolio[sec].Quantity > 0 : 
                if self.slow_sma[sec] > self.fast_sma[sec]:
                    self.Liquidate(sec)