Overall Statistics
Total Trades
72
Average Win
3.17%
Average Loss
-1.16%
Compounding Annual Return
3.775%
Drawdown
15.100%
Expectancy
0.759
Net Profit
34.233%
Sharpe Ratio
0.46
Probabilistic Sharpe Ratio
3.603%
Loss Rate
53%
Win Rate
47%
Profit-Loss Ratio
2.72
Alpha
0.015
Beta
0.151
Annual Standard Deviation
0.06
Annual Variance
0.004
Information Ratio
-0.395
Tracking Error
0.143
Treynor Ratio
0.184
Total Fees
$267.78
Estimated Strategy Capacity
$880000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
# region imports
from AlgorithmImports import *
# endregion

class Quadcci(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2015, 1, 1)  # Set Start Date
        self.SetCash(183000)  # Set Strategy Cash
        
        self.AddEquity("spy", Resolution.Daily,)
      
        self.cci = self.CCI("spy", 200,  MovingAverageType.Simple, Resolution.Daily)
        #self.Med = self.CCI("spy", 50,  MovingAverageType.Simple, Resolution.Daily)
        self.CCIupperBound = 100 # CCI upper bound line
        self.CCIlowerBound = -100 # CCI lower bound 
        self.CCIBaseLine = 0 # cci baseline

        
    def OnData(self, data):
        if not self.cci.IsReady:
            return
        # get current price of Spy
        holdings = self.Portfolio["spy"].Quantity
        price = self.Securities["spy"].Close
        
        
        # buy if price closes above upper bollinger band
        if holdings <= 0:
               if self.cci.Current.Value > self.CCIupperBound:
                self.SetHoldings("spy", 1.0)
        
        # sell if price closes below middle bollinger band
        if holdings > 0 and self.cci.Current.Value < self.CCIupperBound:
                self.Liquidate()

        self.Plot("My Indicators", "commoditychannelindex", self.cci.Current)