Overall Statistics
Total Orders
11180
Average Win
0.15%
Average Loss
-0.09%
Compounding Annual Return
66.910%
Drawdown
16.100%
Expectancy
0.548
Start Equity
100000
End Equity
1485637.82
Net Profit
1385.638%
Sharpe Ratio
2.263
Sortino Ratio
2.883
Probabilistic Sharpe Ratio
99.728%
Loss Rate
43%
Win Rate
57%
Profit-Loss Ratio
1.71
Alpha
0.356
Beta
0.728
Annual Standard Deviation
0.188
Annual Variance
0.036
Information Ratio
2.214
Tracking Error
0.149
Treynor Ratio
0.586
Total Fees
$32180.33
Estimated Strategy Capacity
$3600000.00
Lowest Capacity Asset
VIXM UT076X30D0MD
Portfolio Turnover
14.34%
#region imports
from AlgorithmImports import *
#endregion


# Your New Python File
#region imports
from AlgorithmImports import *
#endregion
from AlgorithmImports import *
from indicators import *
from main import YellowCatStrat

class TQQQFTLTStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm, 'SPY', 200):
            if RSI(self.algorithm, 'TQQQ', 10) > 78:
                AH(self.algorithm, ['SPXU', 'UVXY', 'SQQQ'], 1, 0.33)
            else:
                if RSI(self.algorithm, 'SPXL', 10) > 79:
                    AH(self.algorithm, ['SPXU', 'UVXY', 'SQQQ'], 1, 0.33)
                else:
                    if CumReturn(self.algorithm, 'TQQQ', 4) > 0.2:
                        if RSI(self.algorithm, 'TQQQ', 10) < 31:
                            AH(self.algorithm, 'TQQQ', 1, 1)
                        else:
                            if RSI(self.algorithm, 'UVXY', 10) > RSI(self.algorithm, 'SQQQ', 10):
                                AH(self.algorithm, ['SPXU', 'UVXY', 'SQQQ'], 1, 0.33)
                            else:
                                AH(self.algorithm, 'SQQQ', 1, 1)
                    else:
                        AH(self.algorithm, 'TQQQ', 1, 1)
        else:
            if RSI(self.algorithm, 'TQQQ', 10) < 31:
                AH(self.algorithm, 'TECL', 1, 1)
            else:
                if RSI(self.algorithm, 'SMH', 10) < 30:
                    AH(self.algorithm, 'SOXL', 1, 1)
                else:
                    if RSI(self.algorithm, 'DIA', 10) < 27:
                        AH(self.algorithm, 'UDOW', 1, 1)
                    else:
                        if RSI(self.algorithm, 'SPY', 14) < 28:
                            AH(self.algorithm, 'UPRO', 1, 1)
                        else:
                            self.Group1()
                            self.Group2()

    def Group1(self):
        if CumReturn(self.algorithm, 'QQQ', 200) < -0.2:
            if GetCurrentPrice(self.algorithm,'QQQ') < SMA(self.algorithm, 'QQQ', 20):
                if CumReturn(self.algorithm, 'QQQ', 60) < -0.12:
                    self.Group5()
                    self.Group6()
                else:
                    if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
                        AH(self.algorithm, 'TQQQ', 1, 0.5)
                    else:
                        AH(self.algorithm, 'SQQQ', 1, 0.5)
            else:
                if RSI(self.algorithm, 'SQQQ', 10) < 31:
                    AH(self.algorithm, 'PSQ', 1, 0.5)
                else:
                    if CumReturn(self.algorithm, 'QQQ', 9) > 0.055:
                        AH(self.algorithm, 'PSQ', 1, 0.5)
                    else:
                        if RSI(self.algorithm, 'TQQQ', 10) > RSI(self.algorithm, 'SOXL', 10):
                            AH(self.algorithm, 'TQQQ', 1, 0.5)
                        else:
                            AH(self.algorithm, 'SOXL', 1, 0.5)

    def Group2(self):
        if GetCurrentPrice(self.algorithm,'QQQ') < SMA(self.algorithm, 'QQQ', 20):
            if CumReturn(self.algorithm, 'QQQ', 60) < -0.12:
                self.Group3()
                self.Group4()
            else:
                if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
                    AH(self.algorithm, 'TQQQ', 1, 0.5)
                else:
                    AH(self.algorithm, 'SQQQ', 1, 0.5)
        else:
            if RSI(self.algorithm,'TQQQ', 10) > RSI(self.algorithm,'SOXL', 10):
                AH(self.algorithm, 'TQQQ', 1, 0.5)
            else:
                AH(self.algorithm, 'SOXL', 1, 0.5)

    def Group3(self):
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm, 'SPY', 20):
            AH(self.algorithm, 'SPY', 1, 0.25)
        else:
            if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
                AH(self.algorithm, 'QQQ', 1, 0.25)
            else:
                AH(self.algorithm, 'PSQ', 1, 0.25)

    def Group4(self):
        if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
            AH(self.algorithm, 'QQQ', 1, 0.25)
        else:
            AH(self.algorithm, 'PSQ', 1, 0.25)

    def Group5(self):
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm, 'SPY', 20):
            AH(self.algorithm, 'SPY', 1, 0.25)
        else:
            if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
                AH(self.algorithm, 'QQQ', 1, 0.25)
            else:
                AH(self.algorithm, 'PSQ', 1, 0.25)
    def Group6(self):
        if RSI(self.algorithm, 'TLT', 10) > RSI(self.algorithm, 'SQQQ', 10):
            AH(self.algorithm, 'QQQ', 1, 0.25)
        else:
            AH(self.algorithm, 'PSQ', 1, 0.25)

class TQQQorNotStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm,'TQQQ',10) > 78:
            AH(self.algorithm,['SPXU','UVXY','SQQQ'],2,1/3)
        else:
            if CumReturn(self.algorithm,'TQQQ',6) < -0.12:
                if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                    AH(self.algorithm,['SPXU','UVXY','SQQQ'],2,1/3)
                else:
                    if RSI(self.algorithm,'TQQQ',10) < 32:
                        AH(self.algorithm,'TQQQ',2,1)
                    else:
                        if MaxDD(self.algorithm,'TMF',10)<0.07:
                            AH(self.algorithm,'TQQQ',2,1)
                        else:
                            AH(self.algorithm,'BIL',2,1)
            else:
                if MaxDD(self.algorithm,'QQQ',10)>0.06:
                    AH(self.algorithm,'BIL',2,1)
                else:
                    if MaxDD(self.algorithm,'TMF',10)>0.07:
                        AH(self.algorithm,'BIL',2,1)
                    else:
                        if GetCurrentPrice(self.algorithm,'QQQ') > SMA(self.algorithm,'QQQ', 25):
                            AH(self.algorithm,'TQQQ',2,1)
                        else:
                            if RSI(self.algorithm,'SPY',60) > 50:
                                if RSI(self.algorithm,'BND',45) > RSI(self.algorithm,'SPY',45):
                                    AH(self.algorithm,'TQQQ',2,1)
                                else:
                                    AH(self.algorithm,'BIL',2,1)
                            else:
                                if RSI(self.algorithm,'IEF',200) < RSI(self.algorithm,'TLT',200):
                                    if RSI(self.algorithm,'BND',45) > RSI(self.algorithm,'SPY',45):
                                        AH(self.algorithm,'TQQQ',2,1)
                                    else:
                                        AH(self.algorithm,'BIL',2,1)
                                else:
                                    AH(self.algorithm,'BIL',2,1)



class DereckCustomBetaBallerStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        self.DereckCustomBetaBaller()

    def DereckCustomBetaBaller(self):
        if SMADayRet(self.algorithm,'TLT',350) < SMADayRet(self.algorithm,'TLT',550):
            if GetCurrentPrice(self.algorithm,'SPY') < SMA(self.algorithm,'SPY',200):
                self.V1()
            else:
                self.B2()
        else:
            self.N3()
    def V1(self):
        if RSI(self.algorithm,'BIL',8) < 35:
            if RSI(self.algorithm,'TQQQ',10) > 80:
                self.O6()
            else:
                AH(self.algorithm,'SOXL',3,1)
        else:
            if RSI(self.algorithm,'SPY',6) < 27:
                self.E77()
            else:
                self.B5()
    def O6(self):
        Sort(self.algorithm,"RSI",["VIXM","VIXY"],13,False,1,3,1)

    def E77(self):
        if RSI(self.algorithm,'BSV',7) < RSI(self.algorithm,'SPHB',7):
            Sort(self.algorithm,"RSI",["SOXS","SOXS"],7,False,1,3,1)
        else:
           Sort(self.algorithm,"RSI",["SOXL","TECL"],7,False,1,3,1)
    def B5(self):
        if RSI(self.algorithm,'BSV',7) > RSI(self.algorithm,'SHY',7):
            self.B4()
        else:
            AH(self.algorithm,'SOXL',3,1)
    def B4(self):
        if RSI(self.algorithm,'QQQ',10) < 30:
            Sort(self.algorithm,"SMADayRet",["TQQQ","SPXL","SOXL","UPRO"],5,True,1,3,1)
        else:
            if RSI(self.algorithm,'SPY',10) < 30:
                AH(self.algorithm,'UPRO',3,1)
            else:
                if GetCurrentPrice(self.algorithm,'QLD') > SMA(self.algorithm,'QLD',20):
                    self.B14()
                else:
                    self.A42()
    def B14(self):
        if 50 > RSI(self.algorithm,'IEF',7):
            self.B15()
        else:
            if RSI(self.algorithm,'SPY',6) > 75:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            else:
                AH(self.algorithm,'SOXL',3,1)
    def B15(self):
        if GetCurrentPrice(self.algorithm,'TLT') < SMA(self.algorithm,'TLT',21):
            self.B16()
        else:
            self.B17()
    def B16(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPY',2) < -0.02:
                    Sort(self.algorithm,"CumReturn",["SPXS","TECS","SOXS","SQQQ","ERX"],5,False,1,3,1)
                else:
                    if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                        Sort(self.algorithm,"CumReturn",["SOXS","SQQQ","EPI"],5,True,1,3,1)
                    else:
                        Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TMV"],5,False,1,3,1)
        else:
            if SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                        if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","IYK","TMV"],5,False,1,3,1)
                    else:
                        if 50 < RSI(self.algorithm,'IEF',7):
                            Sort(self.algorithm,"SMADayRet",["TQQQ","IYK","SOXL","UPRO","TECL"],5,True,1,3,1)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","IYK","UPRO"],22,False,1,3,1)
            else:
                self.Defence()
    def Defence(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            if STD(self.algorithm,'DBC',10) > 0.03:
                if STD(self.algorithm,'TMV',5) < STD(self.algorithm,'DBC',5):
                    AH(self.algorithm,'TMV',3,1)
                else:
                    AH(self.algorithm,'DBC',3,1)
            else:
                if 50 < RSI(self.algorithm,'IEF',7):
                    Sort(self.algorithm,"SMADayRet",["TMV","SOXS","SPXU"],5,True,1,3,1)

                else:
                    Sort(self.algorithm,"CumReturn",["EFA","EEM","SPXS","SOXS","UCO","TMV"],5,False,1,3,1)
        else:
            if 50 < RSI(self.algorithm,'IEF',7):
                Sort(self.algorithm,"SMADayRet",["EPI","SOXL","UPRO","IYK"],5,False,1,3,1)

            else:
                Sort(self.algorithm,"CumReturn",["EWZ","TECS","SOXS","EUO","YCS","TMV"],5,False,1,3,1)
    def B17(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPY',2) < -0.02:
                Sort(self.algorithm,"SMADayRet",["SPXS","TECS","SOXS","SQQQ"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                    Sort(self.algorithm,"CumReturn",["BIL","AGG","TMF"],5,False,1,3,1)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TQQQ","EWZ","TMF"],5,False,1,3,1)
        else:
            if SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
                if EMA(self.algorithm,'SPY',210) > EMA(self.algorithm,'SPY',360):
                    if RSI(self.algorithm,'TQQQ',11) > 77:
                        AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                    else:
                        if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                            if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                            else:
                                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SPXL","EPI","SOXL","UPRO","QLD","EWZ","MVV","XLU","IYK","USD","TMF"],7,False,1,3,1)
                        if 50 < RSI(self.algorithm,'IEF',7):
                            Sort(self.algorithm,"SMADayRet",["TECL","SPXL","EPI","SOXL","UPRO","MVV"],7,False,1,3,1)
                        else:
                            Sort(self.algorithm,"CumReturn",["SOXS","TMF"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"RSI",["SPXS","SQQQ","TECS","SOXS"],5,False,1,3,1)
            else:
                self.Defence2()
    def Defence2(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            Sort(self.algorithm,"RSI",["SPXS","EPI","TECS","SOXS","SQQQ"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","TMF"],5,True,1,3,1)
    def A42(self):
        if RSI(self.algorithm,'TQQQ',9) < 32:
            if CumReturn(self.algorithm,'TQQQ',2) > CumReturn(self.algorithm,'TQQQ',5):
                self.A41()
            else:
                Sort(self.algorithm,"RSI",["TMF","UCO","USD","SOXL","SQQQ"],5,False,1,3,1)
        else:
             self.A43()
    def A41(self):
        self.Substrategy1()
        self.Substrategy2()
    def Substrategy1(self):
        Sort(self.algorithm,"RSI",["TECL","SOXL","SHY"],10,False,1,3,0.5)
    def Substrategy2(self):
        Sort(self.algorithm,"RSI",["SHY","SOXL"],5,False,1,3,0.5)
    def A43(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm,'TLT',200):
            self.A19()
        else:
            self.B18()
    def A19(self):
        if SMADayRet(self.algorithm,'TLT',20) < 0:
            self.A44()
        else:
            self.A55()
    def A44(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO"],5,False,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                    Sort(self.algorithm,"CumReturn",["SOXS","EUO","YCS"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TQQQ","CURE"],5,False,1,3,1)
        else:
            if RSI(self.algorithm,'TQQQ',11) > 77:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            else:
                Sort(self.algorithm,"SMADayRet",["SOXL","TECL","TMV","TQQQ","UPRO"],5,False,1,3,1)
    def A55(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TQQQ"],5,False,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPY',2) < -0.02:
                    Sort(self.algorithm,"CumReturn",["TECS","SOXS","SQQQ"],5,True,1,3,1)
                else:
                    if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                        Sort(self.algorithm,"CumReturn",["ERX","EUO","YCS"],5,True,1,3,1)
                    else:
                        Sort(self.algorithm,"SMADayRet",["EWZ","SOXL","MVV","USD"],5,False,1,3,1)
        else:
            if SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                        if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                        else:
                            if 50 < RSI(self.algorithm,'IEF',7):
                                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                            else:
                                Sort(self.algorithm,"CumReturn",["EWZ","UUP","TMF","UCO"],5,True,1,3,1)
                    else:
                        if 50 < RSI(self.algorithm,'IEF',7):
                            Sort(self.algorithm,"SMADayRet",["TQQQ","SPXL","QLD","USD","TECL"],5,False,1,3,1)
                        else:
                            Sort(self.algorithm,"CumReturn",["EWZ","EWZ","TMF"],5,True,1,3,1)
            else:
                self.Defence3()
    def Defence3(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            Sort(self.algorithm,"RSI",["SHY","EWZ","GLD","SPXS","TECS","SOXS","UCO","YCS"],5,False,1,3,1)
        else:
            if 50 < RSI(self.algorithm,'IEF',7):
                Sort(self.algorithm,"SMADayRet",["SOXL","USD","TMF"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"CumReturn",["EWZ","SPXS","SOXS","UCO","YCS"],5,True,1,3,1)
    def B18(self):
        if SMADayRet(self.algorithm,'TLT',20) < 0:
            self.A57()
        else:
            self.B17()
    def A57(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPY',2) < -0.02:
                    Sort(self.algorithm,"CumReturn",["SPXS","TECS","SOXS","SQQQ","ERX"],5,False,1,3,1)
                else:
                    if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                        Sort(self.algorithm,"CumReturn",["SOXS","SQQQ","EPI"],5,True,1,3,1)
                    else:
                        Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TMV"],5,False,1,3,1)
        else:
            if SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                        if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","IYK","TMV"],5,False,1,3,1)
                    else:
                        if 50 < RSI(self.algorithm,'IEF',7):
                            Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","IYK","TMV","UPRO","TECL"],5,True,1,3,1)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","IYK","UPRO"],22,False,1,3,1)
            else:
                self.Defence()
    def B2(self):
        if RSI(self.algorithm,'SPY',40) > 75:
            if 50 < RSI(self.algorithm,'IEF',7):
                AH(self.algorithm,'QQQ',3,1)
            else:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
        else:
            self.A54()
    def A54(self):
        if 50 > RSI(self.algorithm,'IEF',7):
            self.A53()
        else:
            if RSI(self.algorithm,'SPY',6) > 75:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            else:
                AH(self.algorithm,'SOXL',3,1)
    def A53(self):
        if RSI(self.algorithm,'TQQQ',14) > 75:
            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
        else:
            if RSI(self.algorithm,'SPXL',10) > 80:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            else:
                self.B23()
    def B23(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm,'TLT',200):
            self.A24()
        else:
            self.A52()
    def A24(self):
        if RSI(self.algorithm,'TLT',14) < 50:
            self.A22()
        else:
            self.A26()
    def A22(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm,'TLT',5):
            self.A25()
        else:
            self.A51()
    def A25(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO","TECL","SPXL"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPXU',6) > CumReturn(self.algorithm,'UPRO',3):
                    Sort(self.algorithm,"CumReturn",["TECS","SOXS","SQQQ","TMF","SHY"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","SOXL","UPRO","EWZ","TMF","TQQQ"],5,False,1,3,1)
        else:
            if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","TMF"],7,False,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["SOXL","TMF"],7,False,1,3,1)
    def A51(self):
        if RSI(self.algorithm,'TLT',14) < 20:
            AH(self.algorithm,'SHY',3,1)
        else:
            if SMADayRet(self.algorithm,'TLT',20) < 0:
                self.A21()
            else:
                self.A50()
    def A21(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                Sort(self.algorithm,"CumReturn",["SOXS","ERX","SHY"],5,True,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","CURE","EWZ","SHY"],5,False,1,3,1)
        else:
            if SMA(self.algorithm,'SPY',210) > SMA(self.algorithm,'DBC',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                        if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                        else:
                            Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO","TMV","SHY"],5,False,1,3,1)
                    else:
                        Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO","TMV","SHY"],5,True,1,3,1)
            else:
                self.A49()
    def A49(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            Sort(self.algorithm,"RSI",["EEM","TECS","SOXS","TMV"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"RSI",["EEM","TECS","SOXS","TMV"],10,False,1,3,1)
    def A50(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO","TECL","TMF"],5,True,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","TMF"],5,False,1,3,1)
        elif SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
            if RSI(self.algorithm,'TQQQ',11) > 77:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            elif CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SPXL","EPI","SOXL","UPRO","QLD","EWZ","MVV","PUI","IYK","USD","TMF"],7,False,1,3,1)
            else:
                if 50 < RSI(self.algorithm,'IEF',7):
                    Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","PUI"],5,False,1,3,1)
                else:
                    Sort(self.algorithm,"CumReturn",["SOXS","SQQQ","UCO","DIG"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"SMADayRet",["EPI","UPRO","SOXL","TQQQ"],5,True,1,3,1)
    def A26(self):
        if RSI(self.algorithm,'TLT',14) > 80:
            self.A27()
        else:
            if GetCurrentPrice(self.algorithm,'TLT') < SMA(self.algorithm,'TLT',21):
                self.A44()
            else:
                self.A55()
    def A27(self):
        if SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
            if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"RSI",["SQQQ","TECS","SOXS","TMV"],5,True,1,3,1)
        else:
            Sort(self.algorithm,"SMADayRet",["EPI","UPRO","SOXL","TQQQ","TMV"],5,True,1,3,1)
    def A52(self):
        if GetCurrentPrice(self.algorithm,'TLT') < SMA(self.algorithm,'TLT',21):
            self.A57()
        else:
            self.A56()
    def A56(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPY',2) <= -0.02:
                Sort(self.algorithm,"CumReturn",["SPXS","TECS","SOXS","SQQQ"],5,True,1,3,1)
            elif CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                Sort(self.algorithm,"CumReturn",["BIL","AGG","TMF"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","EWZ","TMF"],5,False,1,3,1)
        elif SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
            if EMA(self.algorithm,'SPY',210) > EMA(self.algorithm,'SPY',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                elif CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                    if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                        AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                    else:
                        Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SPXL","EPI","SOXL","UPRO","QLD","EWZ","MVV","XLU","IYK","USD","TMF"],7,False,1,3,1)
                elif 50 < RSI(self.algorithm,'IEF',7):
                    Sort(self.algorithm,"SMADayRet",["TECL","SPXL","EPI","SOXL","UPRO","MVV","UGE"],7,False,1,3,1)
                else:
                    Sort(self.algorithm,"CumReturn",["SOXS","TMF"],5,True,1,3,1)
            else:
                Sort(self.algorithm,"RSI",["SPXS","SQQQ","TECS","SOXS"],5,False,1,3,1)
        else:
            self.Defence2()
    def N3(self):
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm,'SPY',200):
            if RSI(self.algorithm,'QQQ',14) > 80:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            else:
                if RSI(self.algorithm,'SPY',10) > 80:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    self.A31()
        else:
            if RSI(self.algorithm,'TQQQ',9) < 32:
                if CumReturn(self.algorithm,'TQQQ',2) >= CumReturn(self.algorithm,'TQQQ',5):
                    self.A41()
                else:
                    if RSI(self.algorithm,'SPY',10) < 30:
                        self.A40()
                    else:
                        if GetCurrentPrice(self.algorithm,'TQQQ') > SMA(self.algorithm,'TQQQ',20):
                            if RSI(self.algorithm,'SQQQ',10) < 31:
                                AH(self.algorithm,'SQQQ',3,1)
                            else:
                                AH(self.algorithm,'TQQQ',3,1)
                        else:
                            Sort(self.algorithm,"RSI",["TMF","UCO","USD","SOXL","SQQQ"],5,False,1,3,1)
            else:
                self.A31()
    def A31(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm,'TLT',200):
            self.A30()
        else:
            self.A37()
    def A30(self):
        if RSI(self.algorithm,'TLT',14) < 50:
            self.A29()
        else:
            self.A28()
    def A29(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm,'TLT',5):
            self.A32()
        else:
            self.A33()
    def A32(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                    Sort(self.algorithm,"CumReturn",["TECS","SOXS","SQQQ","TMF","SHY"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO","EWZ","TMF"],5,False,1,3,1)
        else:
            if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","TMF"],7,False,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["SOXL","TMF"],7,False,1,3,1)
    def A33(self):
        if RSI(self.algorithm,'TLT',14) < 20:
            AH(self.algorithm,'TMF',3,1)
        else:
            if SMADayRet(self.algorithm,'TLT',20) < 0:
                self.A21()
            else:
                self.A34()
    def A34(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO","TECL","TMF"],5,True,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","TMF"],5,False,1,3,1)
        elif SMA(self.algorithm,'SPY',210) > SMA(self.algorithm,'DBC',360):
            if RSI(self.algorithm,'TQQQ',11) > 77:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            elif CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","EPI","SOXL","UPRO","QLD","EWZ","MVV","XLU","USD","TMF"],7,False,1,3,1)
            elif 50 < RSI(self.algorithm,'IEF',7):
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","XLU"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"CumReturn",["SOXS","SQQQ","UCO","DIG"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"SMADayRet",["EPI","UPRO","SOXL","TQQQ"],5,True,1,3,1)
    def A28(self):
        if RSI(self.algorithm,'TLT',14) > 80:
            self.A27()
        else:
            self.A35()
    def A35(self):
        if SMADayRet(self.algorithm,'TLT',20) < 0:
            self.A44()
        else:
            self.A36()
    def A36(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL"],5,False,1,3,1)
            elif CumReturn(self.algorithm,'SPY',2) <= -0.02:
                Sort(self.algorithm,"CumReturn",["TECS","SOXS","SQQQ"],5,True,1,3,1)
            elif CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                Sort(self.algorithm,"CumReturn",["ERX","EUO","YCS"],5,True,1,3,1)
            else:
                Sort(self.algorithm,"SMADayRet",["SOXL","EWZ","MVV","USD"],5,False,1,3,1)
        elif SMADayRet(self.algorithm,'SPY',210) > SMADayRet(self.algorithm,'DBC',360):
            if RSI(self.algorithm,'TQQQ',11) > 77:
                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
            elif CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                elif 50 < RSI(self.algorithm,'IEF',7):
                    AH(self.algorithm,'SOXL',3,1)
                else:
                    Sort(self.algorithm,"CumReturn",["EWZ","UUP","TMF","UCO"],5,True,1,3,1)
            elif 50 < RSI(self.algorithm,'IEF',7):
                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","UPRO","QLD","USD"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"CumReturn",["EWZ","UUP","TMF"],5,True,1,3,1)
        else:
            self.A45()
    def A45(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            Sort(self.algorithm,"RSI",["SHY","EWZ","GLD","SPXU","TECS","SOXS","UCO","YCS"],5,False,1,3,1)
        elif 50 < RSI(self.algorithm,'IEF',7):
            Sort(self.algorithm,"SMADayRet",["SOXL","USD","TMF"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"CumReturn",["EWZ","SPXU","SOXS","UCO","YCS"],5,True,1,3,1)
    def A37(self):
        if GetCurrentPrice(self.algorithm,'TLT') < SMA(self.algorithm,'TLT',21):
            self.A38()
        else:
            self.A39()
    def A38(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if RSI(self.algorithm,'TQQQ',10) < 30:
                Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPY',2) <= -0.02:
                    Sort(self.algorithm,"CumReturn",["SPXU","TECS","SOXS","SQQQ","ERX"],5,False,1,3,1)
                else:
                    if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                        Sort(self.algorithm,"CumReturn",["SOXS","SQQQ","EPI"],5,True,1,3,1)
                    else:
                        Sort(self.algorithm,"SMADayRet",["TECL","SOXL","TMV"],5,False,1,3,1)
        else:
            if SMA(self.algorithm,'SPY',210) > SMA(self.algorithm,'DBC',360):
                if RSI(self.algorithm,'TQQQ',11) > 77:
                    AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                else:
                    if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                        if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                            AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","IYK","TMV"],5,False,1,3,1)
                    else:
                        if 50 < RSI(self.algorithm,'IEF',7):
                            Sort(self.algorithm,"SMADayRet",["TQQQ","SOXL","UPRO","TMV","TECL"],5,True,1,3,1)
                        else:
                            Sort(self.algorithm,"SMADayRet",["SOXL","UPRO","IYK"],22,False,1,3,1)
            else:
                self.A46()
    def A46(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            if STD(self.algorithm,'DBC',10) >= 0.03:
                if STD(self.algorithm,'TMV',5) <= STD(self.algorithm,'DBC',5):
                    AH(self.algorithm,'TMV',3,1)
                else:
                    AH(self.algorithm,'DBC',3,1)
            else:
                if 50 < RSI(self.algorithm,'IEF',7):
                    Sort(self.algorithm,"SMADayRet",["TMV","SOXS","SPXU"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"CumReturn",["EFA","EEM","SPXU","SOXS","UCO","TMV"],5,False,1,3,1)
        else:
            if 50 < RSI(self.algorithm,'IEF',7):
                Sort(self.algorithm,"SMADayRet",["EPI","SOXL","UPRO"],5,False,1,3,1)
            else:
                Sort(self.algorithm,"CumReturn",["EWZ","TECS","SOXS","EUO","YCS","TMV"],5,True,1,3,1)
    def A39(self):
        if EMA(self.algorithm,'SPY',210) <= SMA(self.algorithm,'SPY',360):
            if CumReturn(self.algorithm,'SPY',2) < -0.02:
                Sort(self.algorithm,"CumReturn",["SPXU","TECS","SOXS","SQQQ"],5,True,1,3,1)
            else:
                if CumReturn(self.algorithm,'SPXU',6) >= CumReturn(self.algorithm,'UPRO',3):
                    Sort(self.algorithm,"CumReturn",["BIL","AGG","TMF"],5,False,1,3,1)
                else:
                    Sort(self.algorithm,"CumReturn",["TECL","TQQQ","SOXL","EWZ","TMF"],5,False,1,3,1)
        else:
            if SMA(self.algorithm,'SPY',210) > SMA(self.algorithm,'DBC',360):
                if EMA(self.algorithm,'SPY',210) > EMA(self.algorithm,'SPY',360):
                    if RSI(self.algorithm,'TQQQ',11) > 77:
                        AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                    else:
                        if CumReturn(self.algorithm,'TQQQ',6) < -0.1:
                            if CumReturn(self.algorithm,'TQQQ',1) > 0.055:
                                AH(self.algorithm,['BIL','UVXY','SQQQ'],3,0.33)
                            else:
                                Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","EPI","SOXL","UPRO","QLD","EWZ","MVV","XLU","USD","TMF"],7,True,1,3,1)
                        else:
                            if 50 < RSI(self.algorithm,'IEF',7):
                                Sort(self.algorithm,"SMADayRet",["TECL","EPI","SOXL","UPRO","MVV"],7,False,1,3,1)
                            else:
                                Sort(self.algorithm,"CumReturn",["SOXS","TMF"],5,True,1,3,1)
                else:
                    Sort(self.algorithm,"RSI",["SPXU","SQQQ","TECS","SOXS"],5,False,1,3,1)
            else:
                self.A47()
    def A47(self):
        if STD(self.algorithm,'DBC',20) > STD(self.algorithm,'SPY',20):
            Sort(self.algorithm,"RSI",["SPXU","EPI","TECS","SOXS","SQQQ"],5,False,1,3,1)
        else:
            Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","TMF"],5,True,1,3,1)
    def A40(self):
        Sort(self.algorithm,"SMADayRet",["TECL","TQQQ","SOXL","UPRO","QLD"],5,False,1,3,1)

from indicators import *
from project.main import YellowCatStrat

#https://app.composer.trade/symphony/dgSMXwsjnzgBgD59Emf7/details

class ProposalV304cBetaBallerTCCCWithBelcampo692012DDReductionAdditionalOverallDDReductionStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'BIL', 42) < RSI(self.algorithm, 'IEF', 70):
            if RSI(self.algorithm, 'SPY', 7) > 75:
                Sort(self.algorithm, 'RSI', ('UVXY', 'VIXY'), 12, False, 1, 130, 1)
            else:
                if RSI(self.algorithm, 'SOXL', 5) <= 75:
                    Sort(self.algorithm,'SMA',('SOXL', 'TQQQ', 'TECL'),12,True,1,130,1)
                else:
                    Sort(self.algorithm,'SMA',('SOXS', 'SQQQ'),12,True,1,130,1)
        else:
            if RSI(self.algorithm, 'SPY', 6) < 27:
                if RSI(self.algorithm, 'SHY', 7) < RSI(self.algorithm, 'SPHB', 8):
                    Sort(self.algorithm,'RSI',('SOXS', 'SQQQ'),7,False,1,130,1)
                else:
                    Sort(self.algorithm,'RSI',('SOXL', 'SPXL', 'TECL', 'TMF', 'UPRO', 'USD', 'TQQQ'),18,False,1,130,1)
            else:
                if RSI(self.algorithm, 'SPY', 10) < 30:
                    Sort(self.algorithm,'RSI',('SOXL', 'TECL', 'TMF', 'UPRO'),17,False,1,130,1)
                else:
                    if RSI(self.algorithm, 'UVXY', 10) > 84:
                        if self.algorithm.Portfolio['TLT'].Price > SMA(self.algorithm, 'TLT', 200):
                            if SMA(self.algorithm, 'TLT', 20) < 0:
                                if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                    if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'UPRO'),5,False,1,130,0.21)
                                    else:
                                        if CumReturn(self.algorithm, 'SPXU', 6) <= CumReturn(self.algorithm, 'UPRO', 3):
                                            Sort(self.algorithm,'CumReturn',('SQQQ', 'EUO', 'YCS'),5,True,1,130,0.21)
                                        else:
                                            Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'CURE'),5,False,1,130,0.21)
                                else:
                                    if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                        AH(self.algorithm, 'UVXY', 130, 0.21)
                                    else:
                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'UPRO', 'TMV'),5,False,1,130,0.21)
                            else:
                                if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                    if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL'),5,False,1,130,0.21)
                                    else:
                                        if CumReturn(self.algorithm, 'UUP', 2) >= 1:
                                            Sort(self.algorithm,'CumReturn',('TECS', 'SOXS', 'SQQQ'),5,True,1,130,0.21)
                                        else:
                                            if CumReturn(self.algorithm, 'SPXU', 5) >= CumReturn(self.algorithm, 'UPRO', 4):
                                                Sort(self.algorithm,'CumReturn',('ERX', 'EUO', 'YCS'),5,True,1,130,0.21)
                                            else:
                                                Sort(self.algorithm,'SMA',('SOXL', 'EWZ', 'MVV', 'USD'),5,False,1,130,0.21)
                                else:
                                    if SMA(self.algorithm, 'SPY', 210) > SMA(self.algorithm, 'DBC', 360):
                                        if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                            AH(self.algorithm, 'UVXY', 130, 0.21)
                                        else:
                                            if CumReturn(self.algorithm, 'TQQQ', 6) < -10:
                                                if CumReturn(self.algorithm, 'TQQQ', 1) > 5.5:
                                                    AH(self.algorithm, 'UVXY', 130, 0.21)
                                                else:
                                                    if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                        Sort(self.algorithm,'SMA',('SOXL',),5,False,1,130,0.21)
                                                    else:
                                                        Sort(self.algorithm,'CumReturn',('EWZ', 'UUP', 'TMF', 'UCO'),5,True,1,130,0.21)
                                            else:
                                                if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                    Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SPXL', 'QLD', 'USD'),5,False,1,130,0.21)
                                                else:
                                                    Sort(self.algorithm,'CumReturn',('EWZ', 'UUP', 'TMF'),5,True,1,130,0.21)
                                    else:
                                        if STD(self.algorithm, 'DBC', 20) > STD(self.algorithm, 'SPY', 20):
                                            Sort(self.algorithm,'RSI',('SHY', 'EWZ', 'GLD', 'SPXS', 'TECS', 'SOXS', 'UCO', 'YCS'),5,False,1,130,0.21)
                                        else:
                                            if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                Sort(self.algorithm,'SMA',('SOXL', 'USD', 'TMF'),5,False,1,130,0.21)
                                            else:
                                                Sort(self.algorithm,'CumReturn',('EWZ', 'SPXS', 'SOXS', 'UCO', 'YCS'),5,True,1,130,0.21)
                        else:
                            if SMA(self.algorithm, 'TLT', 20) < 0:
                                if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                    if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                        Sort(self.algorithm,'SMA',('TQQQ', 'SOXL', 'UPRO'),5,True,1,130,0.21)
                                    else:
                                        if CumReturn(self.algorithm, 'UUP', 2) >= 1:
                                            Sort(self.algorithm,'CumReturn',('SPXS', 'TECS', 'SOXS', 'SQQQ', 'ERX'),5,False,1,130,0.21)
                                        else:
                                            if CumReturn(self.algorithm, 'SPXU', 5) >= CumReturn(self.algorithm, 'UPRO', 4):
                                                Sort(self.algorithm,'CumReturn',('SOXS', 'SQQQ', 'EPI'),5,True,1,130,0.21)
                                            else:
                                                if CumReturn(self.algorithm, 'BIL', 3) >= CumReturn(self.algorithm, 'TMV', 3):
                                                    Sort(self.algorithm,'SMA',('TECL', 'SOXL', 'TNA'),5,False,1,130,0.21)
                                                else:
                                                    Sort(self.algorithm,'SMA',('TECL', 'SOXL', 'TMV'),3,False,1,130,0.21)
                            else:
                                if SMA(self.algorithm, 'SPY', 210) > SMA(self.algorithm, 'DBC', 360):
                                    if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                        AH(self.algorithm, 'UVXY', 130, 0.21)
                                    else:
                                        if CumReturn(self.algorithm, 'TQQQ', 6) < -10:
                                            if CumReturn(self.algorithm, 'TQQQ', 1) > 5.5:
                                                AH(self.algorithm, 'UVXY', 130, 0.21)
                                            else:
                                                Sort(self.algorithm,'SMA',('SOXL', 'TMV'),5,False,1,130,0.21)
                                        else:
                                            if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                Sort(self.algorithm,'SMA',('TQQQ', 'SOXL', 'UPRO', 'TMV', 'TECL'),5,True,1,130,0.21)
                                            else:
                                                Sort(self.algorithm,'SMA',('SOXL', 'UPRO'),22,False,1,130,0.21)
                                else:
                                    if STD(self.algorithm, 'DBC', 20) > STD(self.algorithm, 'SPY', 20):
                                        if STD(self.algorithm, 'DBC', 10) >= 3:
                                            if STD(self.algorithm, 'TMV', 5) <= STD(self.algorithm, 'DBC', 5):
                                                AH(self.algorithm, 'TMV', 130, 0.21)
                                            else:
                                                AH(self.algorithm, 'DBC', 130, 0.21)
                                        else:
                                            if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                Sort(self.algorithm,'SMA',('TMV', 'SOXS', 'SPXU'),5,True,1,130,0.21)
                                            else:
                                                Sort(self.algorithm,'CumReturn',('EFA', 'EEM', 'SPXS', 'SOXS', 'UCO', 'TMV'),5,False,1,130,0.21)
                                    else:
                                        if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                            Sort(self.algorithm,'SMA',('EPI', 'SOXL', 'UPRO'),5,False,1,130,0.21)
                                        else:
                                            Sort(self.algorithm,'CumReturn',('EWZ', 'TECS', 'SOXS', 'EUO', 'YCS', 'TMV'),5,True,1,130,0.21)
                    else:
                        if RSI(self.algorithm, 'UVXY', 10) > 74:
                            AH(self.algorithm, 'UVXY', 130, 1)
                        else:
                            if self.algorithm.Portfolio['TLT'].Price > SMA(self.algorithm, 'TLT', 200):
                                if SMA(self.algorithm, 'TLT', 20) < 0:
                                    if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                        if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                            Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'UPRO'),5,False,1,130,0.5)
                                        else:
                                            if CumReturn(self.algorithm, 'SPXU', 6) <= CumReturn(self.algorithm, 'UPRO', 3):
                                                Sort(self.algorithm,'CumReturn',('SQQQ', 'EUO', 'YCS'),5,True,1,130,0.5)
                                            else:
                                                Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'CURE'),5,False,1,130,0.5)
                                    else:
                                        if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                            AH(self.algorithm, 'UVXY', 130, 0.5)
                                        else:
                                            Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'UPRO', 'TMV'),5,False,1,130,0.5)
                                else:
                                    if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                        if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                            Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL'),5,False,1,130,0.5)
                                        else:
                                            if CumReturn(self.algorithm, 'UUP', 2) >= 1:
                                                Sort(self.algorithm,'CumReturn',('TECS', 'SOXS', 'SQQQ'),5,True,1,130,0.5)
                                            else:
                                                if CumReturn(self.algorithm, 'SPXU', 5) >= CumReturn(self.algorithm, 'UPRO', 4):
                                                    Sort(self.algorithm,'CumReturn',('ERX', 'EUO', 'YCS'),5,True,1,130,0.5)
                                                else:
                                                    if CumReturn(self.algorithm, 'BIL', 3) >= CumReturn(self.algorithm, 'TMV', 3):
                                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SPXL', 'QLD', 'USD'),5,False,1,130,0.5)
                                                    else:
                                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'TMV'),5,False,1,130,0.5)
                                    else:
                                        if SMA(self.algorithm, 'SPY', 210) > SMA(self.algorithm, 'DBC', 360):
                                            if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                                AH(self.algorithm, 'UVXY', 130, 0.5)
                                            else:
                                                if CumReturn(self.algorithm, 'TQQQ', 6) < -10:
                                                    if CumReturn(self.algorithm, 'TQQQ', 1) > 5.5:
                                                        AH(self.algorithm, 'UVXY', 130, 0.5)
                                                    else:
                                                        if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                            Sort(self.algorithm,'SMA',('SOXL',),5,False,1,130,0.5)
                                                        else:
                                                            Sort(self.algorithm,'CumReturn',('EWZ', 'UUP', 'TMF', 'UCO'),5,True,1,130,0.5)
                                                else:
                                                    if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                        Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SPXL', 'QLD', 'USD'),5,True,1,130,0.5)
                                                    else:
                                                        Sort(self.algorithm,'SMA',('SOXL', 'UPRO'),22,False,1,130,0.5)
                                        else:
                                            if STD(self.algorithm, 'DBC', 20) > STD(self.algorithm, 'SPY', 20):
                                                Sort(self.algorithm,'RSI',('SHY', 'EWZ', 'GLD', 'SPXS', 'TECS', 'SOXS', 'UCO', 'YCS'),5,False,1,130,0.5)
                                            else:
                                                if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                    Sort(self.algorithm,'SMA',('SOXL', 'USD', 'TMF'),5,False,1,130,0.5)
                                                else:
                                                    Sort(self.algorithm,'CumReturn',('EWZ', 'SPXS', 'SOXS', 'UCO', 'YCS'),5,True,1,130,0.5)
                            else:
                                if SMA(self.algorithm, 'TLT', 20) < 0:
                                    if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                        if RSI(self.algorithm, 'TQQQ', 10) < 30:
                                            Sort(self.algorithm,'SMA',('TQQQ', 'SOXL', 'UPRO'),5,True,1,130,0.5)
                                        else:
                                            if CumReturn(self.algorithm, 'UUP', 2) >= 1:
                                                Sort(self.algorithm,'CumReturn',('SPXS', 'TECS', 'SOXS', 'SQQQ', 'ERX'),5,False,1,130,0.5)
                                            else:
                                                if CumReturn(self.algorithm, 'SPXU', 5) >= CumReturn(self.algorithm, 'UPRO', 4):
                                                    Sort(self.algorithm,'CumReturn',('SOXS', 'SQQQ', 'EPI'),5,True,1,130,0.5)
                                                else:
                                                    if CumReturn(self.algorithm, 'BIL', 3) >= CumReturn(self.algorithm, 'TMV', 3):
                                                        Sort(self.algorithm,'SMA',('TECL', 'SOXL', 'UPRO'),5,False,1,130,0.5)
                                                    else:
                                                        Sort(self.algorithm,'SMA',('TECL', 'SOXL', 'TMV', 'TQQQ'),3,False,1,130,0.5)
                                    else:
                                        if SMA(self.algorithm, 'SPY', 210) > SMA(self.algorithm, 'DBC', 360):
                                            if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                                AH(self.algorithm, 'UVXY', 130, 0.5)
                                            else:
                                                if CumReturn(self.algorithm, 'TQQQ', 6) < -10:
                                                    if CumReturn(self.algorithm, 'TQQQ', 1) > 5.5:
                                                        AH(self.algorithm, 'UVXY', 130, 0.5)
                                                    else:
                                                        Sort(self.algorithm,'SMA',('SOXL', 'TMV'),5,False,1,130,0.5)
                                                else:
                                                    if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                        Sort(self.algorithm,'SMA',('TQQQ', 'SOXL', 'UPRO', 'TMV', 'TECL'),5,True,1,130,0.5)
                                                    else:
                                                        Sort(self.algorithm,'SMA',('SOXL', 'UPRO'),22,False,1,130,0.5)
                                        else:
                                            if STD(self.algorithm, 'DBC', 20) > STD(self.algorithm, 'SPY', 20):
                                                if STD(self.algorithm, 'DBC', 10) >= 3:
                                                    if STD(self.algorithm, 'TMV', 5) <= STD(self.algorithm, 'DBC', 5):
                                                        AH(self.algorithm, 'TMV', 130, 0.5)
                                                    else:
                                                        AH(self.algorithm, 'DBC', 130, 0.5)
                                                else:
                                                    if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                        Sort(self.algorithm,'SMA',('TMV', 'SOXS', 'SPXU'),5,True,1,130,0.5)
                                                    else:
                                                        Sort(self.algorithm,'CumReturn',('EFA', 'EEM', 'SPXS', 'SOXS', 'UCO', 'TMV'),5,False,1,130,0.5)
                                            else:
                                                if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                    Sort(self.algorithm,'SMA',('EPI', 'SOXL', 'UPRO'),5,False,1,130,0.5)
                                                else:
                                                    Sort(self.algorithm,'CumReturn',('EWZ', 'TECS', 'SOXS', 'EUO', 'YCS', 'TMV'),5,True,1,130,0.5)
                                else:
                                    if EMA(self.algorithm, 'SPY', 210) <= SMA(self.algorithm, 'SPY', 360):
                                        if CumReturn(self.algorithm, 'SPY', 2) <= -2:
                                            Sort(self.algorithm,'CumReturn',('SPXS', 'TECS', 'SOXS', 'SQQQ'),5,True,1,130,0.5)
                                        else:
                                            if CumReturn(self.algorithm, 'SPXU', 6) >= CumReturn(self.algorithm, 'UPRO', 3):
                                                Sort(self.algorithm,'CumReturn',('BIL', 'AGG', 'TMF'),5,False,1,130,0.5)
                                            else:
                                                Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'EWZ', 'TMF'),5,False,1,130,0.5)
                                    else:
                                        if SMA(self.algorithm, 'SPY', 210) > SMA(self.algorithm, 'DBC', 360):
                                            if EMA(self.algorithm, 'SPY', 210) > EMA(self.algorithm, 'SPY', 360):
                                                if RSI(self.algorithm, 'TQQQ', 11) > 77:
                                                    AH(self.algorithm, 'UVXY', 130, 0.5)
                                                else:
                                                    if CumReturn(self.algorithm, 'TQQQ', 6) < -10:
                                                        if CumReturn(self.algorithm, 'TQQQ', 1) > 5.5:
                                                            AH(self.algorithm, 'UVXY', 130, 0.5)
                                                        else:
                                                            Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SPXL', 'EPI', 'SOXL', 'UPRO', 'QLD', 'EWZ', 'MVV', 'PUI', 'USD', 'TMF'),7,False,1,130,0.5)
                                                    else:
                                                        if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'IEF', 7):
                                                            Sort(self.algorithm,'SMA',('TECL', 'SPXL', 'EPI', 'SOXL', 'UPRO', 'MVV'),7,False,1,130,0.5)
                                                        else:
                                                            Sort(self.algorithm,'CumReturn',('SOXS', 'TMF'),5,True,1,130,0.5)
                                            else:
                                                Sort(self.algorithm,'RSI',('SPXS', 'SQQQ', 'TECS', 'SOXS'),5,False,1,130,0.5)
                                        else:
                                            if STD(self.algorithm, 'DBC', 20) > STD(self.algorithm, 'SPY', 20):
                                                Sort(self.algorithm,'RSI',('SPXS', 'EPI', 'TECS', 'SOXS', 'SQQQ'),5,False,1,130,0.5)
                                            else:
                                                Sort(self.algorithm,'SMA',('TECL', 'TQQQ', 'SOXL', 'TMF'),5,True,1,130,0.5)


#https://app.composer.trade/symphony/eWuObiu8EmMaM1wLJjar/details

class V3BWCManagedFuturesStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.v3_bwc_managed_futures()
    
    def v3_bwc_managed_futures(self):
        Sort(self.algorithm, 'STD', ('DBMF', 'KMLM', 'FMF', 'CTA', 'WTMF'), 20, False, 1, 128, 0.25)
        Sort(self.algorithm, 'RSI', ('DBMF', 'KMLM', 'FMF', 'CTA', 'WTMF'), 10, False, 1, 128, 0.25)
        Sort(self.algorithm, 'MaxDD', ('DBMF', 'KMLM', 'FMF', 'CTA', 'WTMF'), 20, False, 1, 128, 0.25)
        Sort(self.algorithm, 'RSI', ('DBMF', 'KMLM', 'FMF', 'CTA', 'WTMF'), 14, False, 1, 128, 0.25)

#https://app.composer.trade/symphony/0K6liVmTr0q82Y5HdspZ/details

class The60408020StyleDeez21JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.group1()
        self.group2()
        self.group3()
        self.group4()
    
    def group1(self):
        AH(self.algorithm, 'QQQ', 129, 0.12)
        AH(self.algorithm, 'SPY', 129, 0.12)
    def group2(self):
        AH(self.algorithm, 'TQQQ', 129, 0.48)
        AH(self.algorithm, 'UPRO', 129, 0.48)
    def group3(self):
        AH(self.algorithm, 'TLT', 129, 0.32)
        AH(self.algorithm, 'IEF', 129, 0.32)        
    def group4(self):
        AH(self.algorithm, 'TMF', 129, 0.08)
        AH(self.algorithm, 'TYD', 129, 0.08)

#https://app.composer.trade/symphony/SB3GTubqQnGWm3eQptUX/details

class JasonKozsFearForTheLongTermOriginalStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SVIX', 132, 0.75)
        AH(self.algorithm, 'UVIX', 132, 0.25)
#region imports
from AlgorithmImports import *
#endregion


# Your New Python File
#CombinedStrategy2 version1.py
from AlgorithmImports import *
#endregion
from AlgorithmImports import *
from indicators import *
from main import YellowCatStrat

#https://app.composer.trade/symphony/oLw39T5NArarGky6aLhC/details

class ZeroFiveBetaYoloStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('AMN','CHD','CVBF','DG','ERIE','FCN','FFNW','NTES','OTTR','PGR','PINC','QDEL','RLI','RMD','SFM','SMMF','TPB','UBCP','VIPS','VRTX','WDFC','ZM'),10,False,5,4,1)
    
#https://app.composer.trade/symphony/EqmnUjWtHBbCT7PUBbSK/details

class FortyTwovs69BILVSSOXLFIGHTStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'BIL', 12) > RSI(self.algorithm, 'IEF', 12):
            AH(self.algorithm, 'BIL', 5, 1) 
      else:
            AH(self.algorithm, 'SOXL', 5, 1)

#https://app.composer.trade/symphony/GsdpzOHycF5UKJxRohRR/details

class SeventySOXL30SOXSStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SOXS', 6, 0.3)
        AH(self.algorithm, 'SOXL', 6, 0.7)

#https://app.composer.trade/symphony/Do36TWTu1gWh8SewO1Go/details

class Six040ReturnStackingStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'NTSX', 7,0.66)
        AH(self.algorithm, 'DBMF', 7,0.15) 
        AH(self.algorithm, 'BSJN', 7,0.15) 
        AH(self.algorithm, 'VIXM', 7,0.04)

#https://app.composer.trade/symphony/PQaK6XWI4Ird5bT5b7Bo/details

class Nine010UNHCOSTQQQSMHStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'UNH', 8,0.45)
        AH(self.algorithm, 'COST', 8,0.45) 
        AH(self.algorithm, 'QQQ', 8,0.05) 
        AH(self.algorithm, 'SMH', 8,0.05)

#https://app.composer.trade/symphony/T2vzrOHG6E9Rk1flV0di/details

class Two30407BatshitSimplev10SharedCopyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('JEPI', 'UPRO'), 10, 9,1)

#https://app.composer.trade/symphony/QzwW2e6QFcxxfmNClUw8/details

class AutoIndexDeez6JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'SMADayRet',('AAPL','TSLA','GOOG'),90,True,1,10,0.8)
        Sort(self.algorithm,'SMADayRet',('MSFT','NVDA','JNJ','AMZN','V','JPM','BRK/B','META','PG','MA'),42,True,1,10,0.2)


#https://app.composer.trade/symphony/iZICMymgVkj7lka9rBgO/details

class ApplebutbadStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        if SMA(self.algorithm, 'AAPL', 21) > SMA(self.algorithm, 'AAPL', 252):
            AH(self.algorithm, 'BIL', 11, 1)
        else:
            Sort(self.algorithm,'CumReturn',('AAPL','BIL'),21,False,1,11,1)
    
#https://app.composer.trade/symphony/ysDMJE5KKVCP9lWD8FGS/details

class ApplealsoterribleDeez8JUL20233YRBTAR12Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'AAPL', 2) > 69: 
            AH(self.algorithm, 'AAPL', 12, 1) 
        else:
            AH(self.algorithm, 'BIL', 12, 1)

#https://app.composer.trade/symphony/RtoW10P6KipuEE99fWbP/details

class ALLIDOISWINWINWINNOMATTERWHATStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SPY', 13, 0.25) 
        AH(self.algorithm, 'QQQ', 13, 0.25) 
        AH(self.algorithm, 'DIA', 13, 0.25) 
        AH(self.algorithm, 'IWM', 13, 0.25)

#https://app.composer.trade/symphony/rCGPyUpqomZibcZLsLru/details

class ABetterQQQStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('ATEN','CCRD','CHKP','CRUS','CSCO','DQ','ECOM','ELTK','ERIC','HCKT','INFY','JKHY','LOGI','MNDO','MSFT','NSYS','QLYS','SIMO','TSM','TSRI','WSTG'),40,False,4,14,1)
    
#https://app.composer.trade/symphony/gWd5fpkaofGVtHMwLjYb/details

class ABadIdeaStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        if MaxDD(self.algorithm, 'SVXY', 4) > 10:
            AH(self.algorithm, 'BIL', 15, 1) 
        else:
            AH(self.algorithm, 'SVXY', 15, 1)

#https://app.composer.trade/symphony/BwF1pzV15LjyY4OhVxVz/details

class BTCRothsDynamicDeez3JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('MSTR','COIN','MARA','HUT','BITF','RIOT','BIL'),10,False,2,16,1)

#https://app.composer.trade/symphony/ddD6u7HvWFwOlFfmMnuh/details

class BrianEsPortfoliol26May2022Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('UPRO', 'TQQQ', 'SOXL', 'UDOW', 'TECL'), 25, 17,1)
    
#https://app.composer.trade/symphony/VJB3T4rpOycCFc25K7tc/details

class BitetheApple10918Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if CumReturn(self.algorithm, 'AAPL', 10) > -1:
            AH(self.algorithm, 'AAPB', 18, 1) 
      else:
            AH(self.algorithm, 'AAPD', 18, 1)

#https://app.composer.trade/symphony/Ksz4NUONdDyUDLAH09MK/details

class BILtestdriveStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if STD(self.algorithm, 'BIL', 2) > STD(self.algorithm, 'BIL', 3):
          AH(self.algorithm, 'SPY', 19, 1) 
      else:
          AH(self.algorithm, 'BIL', 19, 1)
#https://app.composer.trade/symphony/bGVzMtaIInv85FuVysnm/details

class BestCryptoRebalancerFeaverStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'MSTR', 20,0.375)
        AH(self.algorithm, 'BITX', 20,0.375)
        AH(self.algorithm, 'HUT', 20,0.0625)
        AH(self.algorithm, 'BITF', 20,0.0625)
        AH(self.algorithm, 'MARA', 20,0.0625)
        AH(self.algorithm, 'COIN', 20,0.0625)
        
#https://app.composer.trade/symphony/HAx2CLC7knePDxP4PlXQ/details

class BelieveinBigTechStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('META','AMZN','AAPL','MSFT','GOOG','PYPL','ADBE','NVDA'),20,True,2,21,1)

#https://app.composer.trade/symphony/6nP4CoYDtzIHq1tvNGt4/details

class BBsimpleStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'BIL', 42) < 70:
            AH(self.algorithm, 'SPXL', 22, 1) 
      else:
            AH(self.algorithm, 'BIL', 22, 1)

#https://app.composer.trade/symphony/Vhhi0M0jPwArFBskS258/details

class BalancedPortfolioStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'TLT', 23, 0.5) 
        AH(self.algorithm, 'SPY', 23, 0.5)

#https://app.composer.trade/symphony/aPm93t3bC3Jnfsh1WH1t/details

class CQFNGUTMVSTOPTRYINGSOHARD8223Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'FNGU', 24, 0.5) 
        AH(self.algorithm, 'TMV', 24, 0.5)

#https://app.composer.trade/symphony/tuDq0KiVG9f6rXqUHmME/details

class CQBankBlenderV108223Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'FNGU', 25, 1)

#https://app.composer.trade/symphony/6oGqcHPz8hb9s93lIeD2/details

class CopyRayDalioStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'VTI', 26,0.3)
        AH(self.algorithm, 'TLT', 26,0.4)
        AH(self.algorithm, 'IEF', 26, 0.15) 
        AH(self.algorithm, 'DBC', 26, 0.075) 
        AH(self.algorithm, 'GLD', 26,0.075)

#https://app.composer.trade/symphony/zp49VUtDfrHce2eBvoEN/details

class CopyofYourABasicBroStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'SMADayRet',('SVXY','UVXY','TQQQ','SQQQ','BIL','GLD','UDN','UUP','HEQT','BTAL','TJUL','RSBT','SPYC'),20,False,3,27,1.0)

#https://app.composer.trade/symphony/WP9xp1rLTO4c2H9UHUCQ/details

class CopyofTheboringIndexStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('SPY', 'QQQ', 'IWM', 'DIA'), 90, 28,1)

#https://app.composer.trade/symphony/UW3aJor3qOT9fcQXOVPp/details

class DragonPortfolioStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('UPRO', 'TMF', 'XLF'), 45, 29,1)

#https://app.composer.trade/symphony/6lLWbBtodpMpQjZlP1Od/details

class DiversifywithSinStocksStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('GLD', 'UUP'), 26, 30,1)
    
#https://app.composer.trade/symphony/0dKcj7cKmeHhafQKlrHM/details

class DiversifywithGoldtheDollarStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('GLD', 'UUP'), 26, 31,1)

#https://app.composer.trade/symphony/aXiDzYzGFlraxOVfSXtL/details

class DiversifiedPortfolioStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SPY', 32, 0.33) 
        AH(self.algorithm, 'VO', 32, 0.33) 
        AH(self.algorithm, 'IJR', 32, 0.33)

#https://app.composer.trade/symphony/DQsRooIeQ48GW9RThp6S/details

class DEVDollarsUUP10OCT2022DeezStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'UUP', 7) > 50:
            Sort(self.algorithm,'RSI',('DG','DLTR'),7,False,1,33,1)
      else:
            Sort(self.algorithm,'RSI',('WMT','COST'),7,False,1,33,1)

#https://app.composer.trade/symphony/cS2s3Pj6tQV7cgCcwWQd/details

class DerpLordStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'UVXY', 30) > 72:
            AH(self.algorithm, 'UVXY', 34, 1) 
      else:
            AH(self.algorithm, 'BIL', 34, 1)

#https://app.composer.trade/symphony/Ke1My3uRO19opK9hHod8/details

class DBCStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'DBC', 35, 1)

#https://app.composer.trade/symphony/vaxElezfN4Ns1C2FOm0F/details

class D0ppV1GUGGRSISectorRotationStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('XLU','XLV','XLRE','XLE','XLF','XBI','XLK','XLY'),10,False,3,36,1.0)

#https://app.composer.trade/symphony/9fF2WR5z4OlljLfAEHwA/details

class InversevolatiltyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
         AHIV(self.algorithm, ('UPRO', 'TQQQ', 'SOXL', 'UDOW'), 25, 37, 1)

#https://app.composer.trade/symphony/7CQSvqELSubp5fw4OL1T/details

class InverseVolatilitywithTECLStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
         AHIV(self.algorithm, ('UPRO', 'TQQQ', 'SOXL', 'UDOW', 'TECL'), 25, 38, 1)

#https://app.composer.trade/symphony/idFdBU6ElbRpdFt5uOQa/details

class IMPORTANTEPacoAseguirCopyofTQQQFTLTOriginalJKozInvestCopyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'MaxDD',('VOX','VFH','VDC','VAW','VIS','VGT','VPU','VCR','VHT','VDE','VNQ','PG','MCD','WMT','REGN','KMB','UL'),46,True,1,39,1)

#https://app.composer.trade/symphony/LvUwIJ4oCTZxT0QFXuPn/details

class ICrackedtheCodeStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'FNGU', 40, 1)

#https://app.composer.trade/symphony/SpVte7pz0lHBYN4DjoPD/details

class HFEAmorediversifiedStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'UPRO', 41,0.35)
      AH(self.algorithm, 'TMF', 41, 0.35) 
      AH(self.algorithm, 'VIXM', 41, 0.15) 
      AH(self.algorithm, 'FAS', 41,0.15)

#https://app.composer.trade/symphony/Zt96r6DsP7cRnSZ0uLpK/details

class HFEADiverseDeez12JUN2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
          AHIV(self.algorithm, ('IEF', 'IEI', 'UTWO', 'TLT'), 42, 42,0.4)
          AHIV(self.algorithm, ('TQQQ', 'SOXL', 'SPXL'), 69, 42,0.6)
#https://app.composer.trade/symphony/FYBISYMcAYEDPPGESs9e/details

class HFEA94DeleveragedDeez23JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'RSI',('SPY','QQQ','IWM','EFA','EEM','AGG','GLD','SLV','USO','UNG','XLE','XLF','XLV','XLY','XLP','XLC','XLI','XLB','XLRE','XLK','XLU'),45,True,5,43,1)
    
#https://app.composer.trade/symphony/In9SPETm1zZFmKdzj7pr/details

class HedgefundieexploresthesuppositoryisleDeez9JUN2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'BIL', 44,0.45)
      AH(self.algorithm, 'SOXL', 44,0.55)

#https://app.composer.trade/symphony/wQ5LH2GeJppqxjnlVgbO/details

class GoalkeeperStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'MaxDD',('VOX','VFH','VDC','VAW','VIS','VGT','VPU','VCR','VHT','VDE','VNQ','PG','MCD','WMT','REGN','KMB','UL'),46,True,1,45,1)
    
#https://app.composer.trade/symphony/XhwZL9FMBbkSBGQWlXcu/details

class FollowDumbMoneyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('UPRO','SOXL','TECL'),21,False,1,46,0.55)
        AH(self.algorithm, 'TMF', 46,0.45)
    
#https://app.composer.trade/symphony/QsPkgniHZmeYCzoxoPEE/details

class FactcheckJasonStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if CumReturn(self.algorithm, 'VTI', 1) > 0:
          AH(self.algorithm, 'TQQQ', 47, 1) 
      else:
          AH(self.algorithm, 'BIL', 47, 1)
    
#https://app.composer.trade/symphony/w23LDhD3E8uZBFA0iKTW/details

class ExpiredWarrantyV10EricSwithpiratedcontentfromBrianERonniem90narwhal44DereckNHinnomTXStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'RSI',('TLT','IEI','UPRO','TQQQ','SOXL'),14,False,2,48,1)

#https://app.composer.trade/symphony/JotPwgE3JbDxDjXPvPpz/details

class ExampleSymphonyMixNoK1Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.simple_sort()
    
    def simple_sort(self):
         Sort(self.algorithm,'RSI',('AAPL','MSFT','NFLX','NVDA','XOM'),14,True,2,49,1.0)

#https://app.composer.trade/symphony/OhKqWWTHI5o9l2wwaKUl/details

class EnhancedMomentumSimpleETFLeverageStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'VTI', 50, 0.5) 
      AH(self.algorithm, 'BND', 50, 0.5)
    
#https://app.composer.trade/symphony/cSjTwQC04w6objHPPvVC/details

class LudwigsMoonshotSonataStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'CumReturn',('AAPL','AMZN','GOOGL','MSFT','UPRO','TQQQ','ERX'),20,True,2,51,0.5) 
      AH(self.algorithm, 'IEP', 51, 0.5)

#https://app.composer.trade/symphony/8jLmqX7IzngSO3Zomd3X/details

class LongBacktestSlimel12Dec2012UUPDBCStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if CumReturn(self.algorithm, 'LQD', 20) > CumReturn(self.algorithm, 'BIL', 20):
          AH(self.algorithm, 'SPY', 52, 1) 
      else:
          AH(self.algorithm, 'BIL', 52, 1)

#https://app.composer.trade/symphony/3a4CLkIzTVe7Sw4I7VVX/details

class LindyInvestingStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'CumReturn',('BK','ED','PG','KO','PFE','IBM','JNJ'),28,False,2,53,1)

#https://app.composer.trade/symphony/rl9qVhFinS9jAuQIrdhc/details

class LeveragedGoldenButterfly17APY44DDSince1992Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'UPRO', 54, 0.36) 
      AH(self.algorithm, 'TYD', 54, 0.36) 
      AH(self.algorithm, 'UGL', 54,0.28)

#https://app.composer.trade/symphony/TAz29Ay9AsRoOwIxlsdM/details

class Layer4StandardVolatilityHedgeUUPGLDStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.layer_4_standard_volatility_hedge_uupgld()
    
    def layer_4_standard_volatility_hedge_uupgld(self):
           AHIV(self.algorithm, ('UUP', 'GLD'), 30, 55, 1.0)

#https://app.composer.trade/symphony/E1sJRzphemoxQHkCCAfe/details

class JasonsNightmareStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'CumReturn',('TSLY','CONY','NVDY','AMDY','APLY','AMZY','OARK','DISO','GOOY','PYPY','MSFO','JPMO','XOMO','NFLY','FBY','SQY','MRNY','FEPI'),5,True,4,56,1)
    
#https://app.composer.trade/symphony/mrAchwGfNh4nH0VAKjoM/details

class PUBWAMColonelSandersRSI20dSPYTFLOSafeWAMV1aBWCWhichWAMBILBILQQQSPYcomboStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm,('SARK','SVIX','SOXL'), 9, 57, 1)

#https://app.composer.trade/symphony/OUBuESSWODBwwPpPFyK5/details

class PUBNEWSCHDSPYMovingAverageComboDereckNHTXStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'SPY', 10) > 80: 
          AH(self.algorithm, 'UVXY', 58, 1) 
      else:
          AH(self.algorithm, 'SPY', 58, 1)

#https://app.composer.trade/symphony/lOTax8Ltw6CM9xSaQxJH/details

class PopBotQ068S368Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'CumReturn',('VDE','VNQ','VHT','VFH','VOX','VPU','VAW','VGT','VIS','VDC','VCR'),200,True,3,59,1)

#https://app.composer.trade/symphony/q91iuhstVZPDfRsoKv2i/details

class PHASETESTofInflationSpiralHedgeStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if CumReturn(self.algorithm, 'TBT', 60) >= 10:
            Sort(self.algorithm,'STD',('TBF'),14,True,1,60,1) 
        else:
            AH(self.algorithm, 'QQQ', 60, 1)

#https://app.composer.trade/symphony/VxyLxfj0lIZBsLqJ3oyj/details

class NFLXnBILStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'NFLX', 61,0.042)
        AH(self.algorithm, 'BIL', 61, 0.69) 
        AH(self.algorithm, 'TECL', 61,0.268)

#https://app.composer.trade/symphony/mDSFgfohWY82RWyZtUbG/details

class NewSymphonyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('MSFT', 'AAPL', 'GOOGL', 'AMZN', 'JNJ', 'UNH', 'ABBV', 'PFE', 'JPM', 'BAC', 'C', 'WFC', 'PG', 'KO', 'UL', 'D', 'NEE', 'DUK', 'EXC'), 21, 62, 1)
    
#https://app.composer.trade/symphony/10gAZFrWUyt0yKglAD6O/details

class MonthlyMARSSStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.monthly_mar_ss()
    
    def monthly_mar_ss(self):
         Sort(self.algorithm,'SMADayRet',('AAPL','MSFT','NVDA','TSLA'),10,True,1,63,1.0)

#https://app.composer.trade/symphony/Y8nRTfQ3ybKp3Eo4yb0Z/details

class MARABETAHEDGEStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
         AHIV(self.algorithm, ('TLT', 'IEF', 'SHY', 'XLP', 'DBC', 'XLU', 'XLY'), 7, 64, 1)
    

#https://app.composer.trade/symphony/SLJ1etdxxgtbfjQaSFt3/details

class rsisorttbtshygbacktestJune222023toJune302023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'RSI',('TBT','SHYG'),30,True,1,65,1)

#https://app.composer.trade/symphony/ClJl4KBkgqwKQ6iomW68/details

class rsisortbacktestJune222023toJune302023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'RSI',('TBT','SHYG'),30,True,1,66,1)
    
#https://app.composer.trade/symphony/aswQVVXTdJMJzsqwNuFO/details

class RSIBugStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'BIL', 42) < RSI(self.algorithm, 'IEF', 69):
          AH(self.algorithm, 'SPY', 67, 1) 
      else:
          AH(self.algorithm, 'BIL', 67, 1)

#https://app.composer.trade/symphony/2CMhgSve60w0acTxNjrj/details

class risingratesHFEAStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
         AHIV(self.algorithm, ('UPRO', 'TMF', 'XLF'), 45, 68, 1)

#https://app.composer.trade/symphony/bFuiNeJNwCuBOtGLZHly/details

class RenTechnoPPOStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'YINN', 69, 1)

#https://app.composer.trade/symphony/TSM1J4BRV9zHEgfGYpcY/details

class RecessionTesterStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if CumReturn(self.algorithm, 'LQD', 20) > CumReturn(self.algorithm, 'BIL', 20):
          AH(self.algorithm, 'SPY', 70, 1) 
      else:
          AH(self.algorithm, 'BIL', 70, 1)
    
#https://app.composer.trade/symphony/9EyiCvgJOCy2rxhC2pUP/details

class QYLDGangStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      Sort(self.algorithm,'CumReturn',('QYLD','RYLD','XYLD','NUSI','JEPI','SCHD','DIVO'),40,True,4,71,1)

#https://app.composer.trade/symphony/EcE0QtZn1CEFjqT3WO1O/details

class QQQ81RSIStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.qqq_81rsi()
    
    def qqq_81rsi(self):
         if RSI(self.algorithm, 'QQQ', 10) < 31:
             AH(self.algorithm, 'QLD', 72, 1) 
         else:
             AH(self.algorithm, 'BIL', 72, 1.0)
    
#https://app.composer.trade/symphony/OLmSkeqQV46tcWSZnAfK/details

class QQQ10dabove80l30May2007Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'QQQ', 10) > 80: 
          AH(self.algorithm, 'QID', 73, 1) 
      else:
          AH(self.algorithm, 'BIL', 73, 1)

#https://app.composer.trade/symphony/NTdktMdbrUiCq0A5MH79/details

class SSTraderSafetyOrchestrav110202216982DDStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('XLU','XLV','XLRE','XLE','XLF','XBI','XLK','XLY'),10,False,3,74,1.0)

#https://app.composer.trade/symphony/wea1pez8Im13TD5unDN9/details

class SPYOverboughtUVXYTestStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'SPY', 10) > 68: 
          AH(self.algorithm, 'UVXY', 75, 1) 
      else:
          AH(self.algorithm, 'BIL', 75, 1)

#https://app.composer.trade/symphony/gv99mKXm2PaRO3CSoUPB/details

class SPYOverboughtTestPublicationStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'SPY', 10) > 80: 
          AH(self.algorithm, 'UVXY', 76, 1) 
      else:
          AH(self.algorithm, 'SPY', 76, 1)

#https://app.composer.trade/symphony/OV3ohHkJ4tKA6HqqSfle/details

class SPYandChillStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'SPY', 77, 1)

#https://app.composer.trade/symphony/5WKW0M0LvaWzIVeZvrAJ/details

class SPY200dMASPYelseSHYStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if GetCurrentPrice(self.algorithm, 'SPY') > SMA(self.algorithm, 'SPY', 200):
          AH(self.algorithm, 'SPY', 78, 1) 
      else:
          AH(self.algorithm, 'SHY', 78, 1)
    
#https://app.composer.trade/symphony/T0Wj7LuRJrPcVs22XpPV/details

class SPY10dabove80l30May2007Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'SPY', 10) > 80: 
          AH(self.algorithm, 'SDS', 79, 1) 
      else:
          AH(self.algorithm, 'BIL', 79, 1)

#https://app.composer.trade/symphony/MGNt4WFhVh6Zw6p2COun/details

class SPY9dMaxDDTestStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if MaxDD(self.algorithm, 'SPY', 9) < 0.000001:
          AH(self.algorithm, 'TLT', 80, 1) 
      else:
          AH(self.algorithm, 'SPY', 80, 1)

#https://app.composer.trade/symphony/tTd3LX15VYRoUiCxdKTi/details

class SOXSwhenOverboughtStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'TQQQ', 10) > 79:
          AH(self.algorithm, 'SOXS', 81, 1)
      else:
          AH(self.algorithm, 'BIL', 81, 1)

#https://app.composer.trade/symphony/qfNzXsjnvXTzQyJ7h35U/details

class SimplifiedLevelsStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'QQQ', 10) > 80: 
          AH(self.algorithm, 'UVXY', 82, 1) 
      else:
          AH(self.algorithm, 'BIL', 82, 1)

#https://app.composer.trade/symphony/rNl1ELtsUlUbSUYt2JBG/details

class SimpleVIXSharedCopyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'VIXM', 83, 0.5) 
      AH(self.algorithm, 'SVXY', 83, 0.5)

#https://app.composer.trade/symphony/WME1hYvaGYKI3pzJHjmy/details

class SimpleSortStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.simple_sort()
    
    def simple_sort(self):
         Sort(self.algorithm,'RSI',('AAPL','MSFT','NFLX','NVDA','XOM'),14,True,2,84,1.0)

#https://app.composer.trade/symphony/aH53aAlLhwd1kSxkMbFs/details

class ShyvSpyUVXY20dRSI70Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if RSI(self.algorithm, 'UVXY', 20) < 70: 
          AH(self.algorithm, 'SPY', 85, 1) 
      else:
          AH(self.algorithm, 'SHY', 85, 1)


#https://app.composer.trade/symphony/lM8PIp0ipSjup6brD10c/details

class ShyvSpySPY12dMDD12Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if MaxDD(self.algorithm, 'SPY', 12) < 12:
          AH(self.algorithm, 'SPY', 86, 1) 
      else:
          AH(self.algorithm, 'SHY', 86, 1)

#https://app.composer.trade/symphony/cf9FHFVsml7INNRmBMcX/details

class ShortJimStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      AH(self.algorithm, 'BIL', 87, 1)

#https://app.composer.trade/symphony/jia7HyanMNsUuKQVxHeV/details

class TQQQFTLTsshareStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'USA', 88, 1)

#https://app.composer.trade/symphony/W4BuxgU3dJWBAh4LhCtw/details

class TMBPEStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('SPY', 'QQQ', 'IWM', 'DIA'), 90, 89,1.0)

#https://app.composer.trade/symphony/VII5ylQXfKPHI9v22Br0/details

class TimElonandHuangsMostExcellentAdventureNoK1MultirangeorQQQmodStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'BIL', 90, 1)

#https://app.composer.trade/symphony/GDyyeD1p6KNa5jT5qkhj/details

class ThresholddemoStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SPY', 91,0.25)
        AH(self.algorithm, 'QQQ', 91, 0.25) 
        AH(self.algorithm, 'DIA', 91, 0.25) 
        AH(self.algorithm, 'AAPL', 91,0.25)

#https://app.composer.trade/symphony/7Ep618hWKBYw7blBvvI0/details

class TheTimeless6040InvestCopyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'VTI', 92, 0.5) 
        AH(self.algorithm, 'BND', 92, 0.5)

#https://app.composer.trade/symphony/V68tn0WRdvjLKAVdd2m3/details

class Thenamesbondv2Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('SHV','TLT','HYG','GLD','UUP'),90,True,2,93,0.5)
        Sort(self.algorithm,'CumReturn',('SHV','TLT','HYG','GLD','UUP'),119,True,2,93,0.5)

#https://app.composer.trade/symphony/97lyngIGuxcHQU9lnJyn/details

class ThenamesbondStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('HYG','TLT','AGG','TIP','IEF','SHV'),90,True,1,94,0.5)
        Sort(self.algorithm,'CumReturn',('HYG','TLT','AGG','TIP','IEF','SHV'),90,True,2,94,0.5)
    
#https://app.composer.trade/symphony/LKpwvyC5AMt7VQKH5FX0/details

class TheFourHorsemenoftheApocalypseLexLugerRemixStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.monthly_mar_ss()
    
    def monthly_mar_ss(self):
        Sort(self.algorithm,'SMADayRet',('AAPL','MSFT','NVDA','TSLA'),10,True,1,95,1.0)
    
#https://app.composer.trade/symphony/pHcP5TnjPANcUKm59N6f/details

class TheAristocratDeez8JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AHIV(self.algorithm, ('AAPL', 'MSFT', 'AMZN', 'NVDA', 'GOOGL'), 90, 96,0.4)
        AHIV(self.algorithm, ('WBA', 'MMM', 'O'), 90, 96,0.6)

#https://app.composer.trade/symphony/8FODoQxQEBTopXux4pXK/details

class The4HorsemenStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'UNH', 97, 0.25)
        AH(self.algorithm, 'ULTA', 97, 0.25)
        AH(self.algorithm, 'COST', 97, 0.25)
        AH(self.algorithm, 'MNST', 97, 0.25)

#https://app.composer.trade/symphony/MMhqp5SpbTZJzYyOsn4W/details

class TestOverboughtStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'SPY', 10) > 80: 
            AH(self.algorithm, 'UVXY', 98, 1) 
        else:
            AH(self.algorithm, 'BIL', 98, 1)
    
#https://app.composer.trade/symphony/pIE8eI9f5WUflMWqeBXb/details

class TestIBKRFeesStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('TQQQ','SQQQ','SOXL','SOXS','BSV','BIL','TMF','TMV','TLT','SPXS','UPRO','QID','QLD'),2,False,4,99,1)
    
#https://app.composer.trade/symphony/BOH7t4anTqXMBc2iA78F/details

class TechEnthusiastStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'QQQ', 100, 1)

#https://app.composer.trade/symphony/IkLHKU4IWV9xw9dZIQlj/details

class TaxableEventMachineDeez23JUL2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'RSI',('SPY','QQQ','IWM','EFA','EEM','AGG','GLD','SLV','USO','UNG','XLE','XLF','XLV','XLY','XLP','XLC','XLI','XLB','XLRE','XLK','XLU'),45,True,5,101,1)
        
#https://app.composer.trade/symphony/a0OyPcu0xi4JsnHcYzsk/details

class treasuryswitchStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if MaxDD(self.algorithm, 'TLT', 11) > MaxDD(self.algorithm, 'SHY', 11):
            AH(self.algorithm, 'SPY', 102, 1) 
      else:
            AH(self.algorithm, 'XLP', 102, 1)

#https://app.composer.trade/symphony/6sJp2lojS2hn1OUThlFa/details

class tradingalpha901ExampleStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if GetCurrentPrice(self.algorithm, 'SPY') > SMA(self.algorithm, 'SPY', 220):
            AH(self.algorithm, 'SPY', 103, 1) 
      else:
            AH(self.algorithm, 'BIL', 103, 1)
    
#https://app.composer.trade/symphony/1kpCKMUZwgnCyyJcv6sl/details

class TradeUnweightedTestStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'VIXM', 104, 0.5) 
        AH(self.algorithm, 'SVXY', 104, 0.5)

#https://app.composer.trade/symphony/2dVYXvm5P5Kafl6LSwB9/details

class TQXLDeez11JUN2023Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.group()
    
    def group(self):
        AHIV(self.algorithm, ('TQQQ', 'SOXL'), 30, 105, 1.0)

#https://app.composer.trade/symphony/N7nxAmvVwxT7kLkaoTLs/details

class V10BetaBallerDeez6MOAR137404DD274Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'BIL', 7) < RSI(self.algorithm, 'BND', 7):
            AH(self.algorithm, 'SOXS', 106, 1) 
        else:
            AH(self.algorithm, 'SOXL', 106, 1)

#https://app.composer.trade/symphony/SqtiyYC7K0iJwT8ft69x/details

class V10BetaBaller2007Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'BIL', 7) > RSI(self.algorithm, 'BND', 7):
            AH(self.algorithm, 'SH', 107, 1) 
        else:
            AH(self.algorithm, 'SHY', 107, 1)
    
#https://app.composer.trade/symphony/AUp3kSElLckqaeJafS3a/details

class V7aBWCMarketAssassinK1FreeStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'SPY', 10) > 80: 
            AH(self.algorithm, 'UVXY', 108, 1) 
        else:
            AH(self.algorithm, 'BIL', 108, 1)

#https://app.composer.trade/symphony/FNBPlbrt8a6MCvC5DRO0/details

class V6BWCTechRotatorComboStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'FNGU', 109, 1) 
        AH(self.algorithm, 'TMV', 109, 1)

#https://app.composer.trade/symphony/cZ3yeg2l4AopolFtVYU6/details

class V6BWCCommoditiesStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'SPY', 10) > 68: 
            AH(self.algorithm, 'UVXY', 110, 1) 
        else:
            AH(self.algorithm, 'BIL', 110, 1)


#https://app.composer.trade/symphony/3l4zGMF4vtvL2huNlUSf/details

class v05FNGUorSafetyTownAllSharedVersionsPlusNAILBlackSwanMeanRevBondSignalStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'TMF', 111, 1)
    

#https://app.composer.trade/symphony/APs6lX70kNe2HrAU9xyz/details

class V2YieldCurveInversionsignalStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if CumReturn(self.algorithm, 'SHY', 252) > -3.5:
            AH(self.algorithm, 'SHY', 112, 1) 
        else:
            AH(self.algorithm, 'IEF', 112, 1)
    
#https://app.composer.trade/symphony/kfFPpRdm6vHXFeFB0Yl2/details

class V02AlphaBallerDeez1YrAR842DD148Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'SOXL', 7) > RSI(self.algorithm, 'SH', 7):
            AH(self.algorithm, 'BIL', 113, 1) 
        else:
            AH(self.algorithm, 'TBT', 113, 1)

#https://app.composer.trade/symphony/LkjKmhmoWKhwiy0G3QxZ/details

class V1MomentumStrengthBuilderMichaelB6040Top10SafetyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'BIL', 7) > RSI(self.algorithm, 'BND', 7):
            AH(self.algorithm, 'SH', 114, 1) 
        else:
            AH(self.algorithm, 'SHY', 114, 1)
    
#https://app.composer.trade/symphony/h6YU0XCuEf437QDbdJ1X/details

class V1DEVYieldCurveInversionsignalInversionwhileinUUPStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if SMADayRet(self.algorithm, 'STIP', 175) <= -0.01:
            AH(self.algorithm, 'UUP', 115, 1) 
        else:
            AH(self.algorithm, 'BIL', 115, 1)
    
#https://app.composer.trade/symphony/BZHwAVNp4OHMnODpMVgt/details

class V1DEVRussianRoublyat10OCT2022Strategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'UVXY', 30) > 72:
            AH(self.algorithm, 'UVXY', 116, 1) 
        else:
            AH(self.algorithm, 'BIL', 116, 1)

#https://app.composer.trade/symphony/tROOkrhejbWmcRtHBoR1/details

class V1BWCWashSaleSymphonyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'CLIP', 117, 1)
    
#https://app.composer.trade/symphony/iICCVNSaNxA7guWhwK2w/details

class V1aMagicInternetMoneyV1aTQQQFTLTStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
      if MaxDD(self.algorithm, 'SVXY', 4) > 10:
            AH(self.algorithm, 'BIL', 118, 1) 
      else:
            AH(self.algorithm, 'SVXY', 118, 1)

#https://app.composer.trade/symphony/nlv4y8ozIJjCoY8M2LcD/details

class YourABasicBroStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'SMADayRet',('SVXY','UVXY','TQQQ','SQQQ','BIL','GLD','UDN','UUP','HEQT','BTAL','TJUL','RSBT','SPYC'),20,False,3,119,1.0)

#https://app.composer.trade/symphony/S7sHo0RRUGToFio0MCqI/details

class YieldmaxMonthlyMARSSStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.yieldmax_monthly_mar_ss()
    
    def yieldmax_monthly_mar_ss(self):
        Sort(self.algorithm,'SMADayRet',('APLY','MSFO','NVDY','TSLY'),10,True,1,120,1.0)

#https://app.composer.trade/symphony/QMk6DqM7klooDv4mqksW/details

class YieldMax25dCRTop2wFEPIPWNStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('TSLY','CONY','NVDY','AMDY','APLY','AMZY','OARK','DISO','GOOY','PYPY','MSFO','JPMO','XOMO','NFLY','FBY','SQY','MRNY','FEPI'),25,True,2,121,1)

#https://app.composer.trade/symphony/vFBdD30gPXtvda29vmYS/details

class YieldMax5dCRTop4wFEPIStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        Sort(self.algorithm,'CumReturn',('TSLY','CONY','NVDY','AMDY','APLY','AMZY','OARK','DISO','GOOY','PYPY','MSFO','JPMO','XOMO','NFLY','FBY','SQY','MRNY','FEPI'),25,True,2,123,1)

#https://app.composer.trade/symphony/i2YgyBckNTlPKH0skQ06/details

class YesmySonStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.group()
        AH(self.algorithm, 'VGSH', 123,0.1)
    
    def group(self):
        AHIV(self.algorithm, ('VOO', 'JEPQ'), 90, 123, 1) 

#https://app.composer.trade/symphony/2OZwOxXfpl1ihAH8Af8m/details

class YesStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'TMF', 124, 1)
    
#https://app.composer.trade/symphony/nXbAx6pA4Kszx99J0eKu/details

class XLYRSITestStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if RSI(self.algorithm, 'XLY', 10) > 80: 
            AH(self.algorithm, 'UVXY', 125, 1) 
        else:
            AH(self.algorithm, 'BIL', 125, 1)

#https://app.composer.trade/symphony/LZOzW78YtjssJUmxLwR9/details

class WaltsAntiYOLOFornicationDrillStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'YINN', 126, 1)


#https://app.composer.trade/symphony/NKRwNRCR6unqJX9rEArH/details

class SandysGoldenDragonStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.long_volatility()
        self.trend_and_momentum()
        self.fiat_alternatives()
        self.secular_growth_assets()
        self.interest_rate_linked()

    def long_volatility(self):
        self.group_long_volatility()

    def group_long_volatility(self):
        if MaxDD(self.algorithm, 'SPY', 4) > 6:
            if CumReturn(self.algorithm, 'UVXY', 45) < 500:
                AH(self.algorithm, 'UVXY', 127, 0.078750)
            else:
                AH(self.algorithm, 'SHY', 127, 0.026250)
                AH(self.algorithm, 'GLD', 127, 0.026250)
                AH(self.algorithm, 'UUP', 127, 0.026250)
                self.group_commodity()
                self.group_equity_linked1()
        else:
            AH(self.algorithm, 'SHY', 127, 0.026250)
            AH(self.algorithm, 'GLD', 127, 0.026250)
            AH(self.algorithm, 'UUP', 127, 0.026250)
            self.group_commodity()
            self.group_equity_linked1()

        if MaxDD(self.algorithm, 'SPY', 15) > 11:
            if CumReturn(self.algorithm, 'UVXY', 45) < 500:
                AH(self.algorithm, 'UVXY', 127, 0.078750)
            else:
                AH(self.algorithm, 'SHY', 127, 0.026250)
                AH(self.algorithm, 'GLD', 127, 0.026250)
                AH(self.algorithm, 'UUP', 127, 0.026250)
                self.group_commodity()
                self.group_equity_linked1()
        else:
            AH(self.algorithm, 'SHY', 127, 0.026250)
            AH(self.algorithm, 'GLD', 127, 0.026250)
            AH(self.algorithm, 'UUP', 127, 0.026250)
            self.group_commodity()
            self.group_equity_linked1()

        self.Garens_advanced_volatility_hedge_v2()
                
    def group_commodity(self):
        AH(self.algorithm, 'COM', 127, 0.013125)
        AH(self.algorithm, 'FAAR', 127, 0.013125)

    def group_equity_linked1(self):
        AH(self.algorithm, 'FTLS', 127, 0.009187)
        AH(self.algorithm, 'CCOR', 127, 0.017063)
        
    def Garens_advanced_volatility_hedge_v2(self):
        if CumReturn(self.algorithm, 'UVXY', 5) > -1:
            AHIV(self.algorithm, ('VIXM', 'UUP', 'UVXY', 'VIXM'), 5, 127, 0.05250) 
        else:
            if MaxDD(self.algorithm, 'TLT', 45) < 5:
                AHIV(self.algorithm, ('TMF', 'IEF', 'TLT', 'SPY'), 5, 127, 0.05250)
            else:
                if EMA(self.algorithm, 'TLT', 10) > EMA(self.algorithm, 'TLT', 200):
                    AHIV(self.algorithm, ('IEF', 'TLT', 'TMF', 'TMF'), 5, 127, 0.05250)
                else:
                    if CumReturn(self.algorithm, 'UVXY', 5) > -0.5:
                        AHIV(self.algorithm, ('VIXM', 'UUP', 'UVXY'), 5, 127, 0.05250)
                    else:
                        AHIV(self.algorithm, ('UUP', 'SHY'), 5, 127, 0.05250)

    def trend_and_momentum(self):
        self.group_equity_momentum()
        self.group_commodity_momentum()

    def group_equity_momentum(self):
        self.group_australia()
        self.group_germany()
        self.group_spain()
        self.group_france()
        self.group_uk()
        self.group_japan()
        self.group_italy()
        self.group_usa()
        self.group_netherlands()
        
    def group_australia(self):
        if CumReturn(self.algorithm, 'EWA', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWA', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_germany(self):
        if CumReturn(self.algorithm, 'EWG', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWG', 127, 0.02) 
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_spain(self):
        if CumReturn(self.algorithm, 'EWP', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWP', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_france(self):
        if CumReturn(self.algorithm, 'EWQ', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWQ', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_uk(self):
        if CumReturn(self.algorithm, 'EWU', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWU', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_japan(self):
        if CumReturn(self.algorithm, 'EWJ', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWJ', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_italy(self):
        if CumReturn(self.algorithm, 'EWI', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWI', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_usa(self):
        if CumReturn(self.algorithm, 'SPY', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'SPY', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_netherlands(self):
        if CumReturn(self.algorithm, 'EWN', 252) > CumReturn(self.algorithm, 'IEF', 252):
            AH(self.algorithm, 'EWN', 127, 0.02)
        else:
            AH(self.algorithm, 'IEF', 127, 0.02)

    def group_commodity_momentum(self):
        self.DBMF_replication()

    def DBMF_replication(self):
        self.group_Oil()
        self.group_NattyGas()
        self.group_Dollar()
        self.group_Aggs()
        self.group_BaseMetals()
        self.group_Uranium()
        self.group_Timber()
        self.group_Gold()
        self.group_Treasuries()
        self.group_SP500()

    def group_Oil(self):
        if STD(self.algorithm, 'USO', 30) > 1.75:
            if CumReturn(self.algorithm, 'USO', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'UCO', 127, 0.02)
            else:
                AH(self.algorithm, 'SCO', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'USO', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'UCO', 127, 0.02)
            else:
                AH(self.algorithm, 'SCO', 127, 0.02)

    def group_NattyGas(self):
        if STD(self.algorithm, 'UNG', 30) > 5:
            if CumReturn(self.algorithm, 'UNG', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'BOIL', 127, 0.02)
            else:
                AH(self.algorithm, 'KOLD', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'UNG', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'BOIL', 127, 0.02)
            else:
                AH(self.algorithm, 'KOLD', 127, 0.02)

    def group_Dollar(self):
        if STD(self.algorithm, 'UUP', 30) > 0.75:
            if CumReturn(self.algorithm, 'UUP', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'EUO', 127, 0.01)
                AH(self.algorithm, 'YCS', 127, 0.01)
            else:
                AH(self.algorithm, 'YCL', 127, 0.01)
                AH(self.algorithm, 'ULE', 127, 0.01)
        else:
            if CumReturn(self.algorithm, 'UUP', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'EUO', 127, 0.01)
                AH(self.algorithm, 'YCS', 127, 0.01)
            else:
                AH(self.algorithm, 'YCL', 127, 0.01)
                AH(self.algorithm, 'ULE', 127, 0.01)
                
    def group_Aggs(self):
        if STD(self.algorithm, 'DBA', 30) > 3.5:
            if CumReturn(self.algorithm, 'DBA', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'DBA', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'DBA', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'DBA', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
                
    def group_BaseMetals(self):
        if STD(self.algorithm, 'DBB', 30) > 1.25:
            if CumReturn(self.algorithm, 'DBB', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'DBB', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'DBB', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'DBB', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
                
    def group_Uranium(self):
        if STD(self.algorithm, 'URA', 30) > 3.5:
            if CumReturn(self.algorithm, 'URA', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'URA', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'URA', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'URA', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
                
    def group_Timber(self):
        if STD(self.algorithm, 'WOOD', 30) > 3.5:
            if CumReturn(self.algorithm, 'WOOD', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'WOOD', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'WOOD', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'WOOD', 127, 0.02)
            else:
                AH(self.algorithm, 'SHV', 127, 0.02)
                
    def group_Gold(self):
        if STD(self.algorithm, 'GLD', 30) > 0.75:
            if CumReturn(self.algorithm, 'GLD', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'UGL', 127, 0.02) 
            else:
                AH(self.algorithm, 'GLL', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'GLD', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'UGL',127, 0.02)
            else:
                AH(self.algorithm, 'GLL', 127, 0.02)

    def group_Treasuries(self):
        if STD(self.algorithm, 'TLT', 30) > 0.75:
            if CumReturn(self.algorithm, 'TLT', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'TMF', 127, 0.02)
            else:
                AH(self.algorithm, 'TMV', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'TLT', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'TMF', 127, 0.02)
            else:
                AH(self.algorithm, 'TMV', 127, 0.02)
                
    def group_SP500(self):
        if STD(self.algorithm, 'SPY', 30) > 2:
            if CumReturn(self.algorithm, 'SPY', 90) > CumReturn(self.algorithm, 'SHV', 90):
                AH(self.algorithm, 'SPY', 127, 0.02)
            else:
                AH(self.algorithm, 'SH', 127, 0.02)
        else:
            if CumReturn(self.algorithm, 'SPY', 45) > CumReturn(self.algorithm, 'SHV', 45):
                AH(self.algorithm, 'SPY', 127, 0.02)
            else:
                AH(self.algorithm, 'SH', 127, 0.02)

    def fiat_alternatives(self):
        AH(self.algorithm, 'GLD', 127, 0.19)

    def secular_growth_assets(self):
        self.group_equities()
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm, 'SPY', 200):
            if RSI(self.algorithm, 'TQQQ', 10) > 79:
                AH(self.algorithm, 'UVXY', 127, 0.1008)
            else:
                if RSI(self.algorithm, 'SPXL', 10) > 80:
                    AH(self.algorithm, 'UVXY', 127, 0.1008)
                else:
                    AH(self.algorithm, 'TQQQ', 127, 0.1008)
        else:
            if RSI(self.algorithm, 'TQQQ', 10) < 31:
                AH(self.algorithm, 'TECL', 127, 0.1008)
            else:
                if RSI(self.algorithm, 'SPY', 10) < 30:
                    AH(self.algorithm, 'SPXL', 127, 0.1008)
                else:
                    if RSI(self.algorithm, 'UVXY', 10) > 74:
                        if RSI(self.algorithm, 'UVXY', 10) > 84:
                            if GetCurrentPrice(self.algorithm,'TQQQ') > SMA(self.algorithm, 'TQQQ', 20):
                                AH(self.algorithm, 'TQQQ', 127, 0.1008)
                            else:
                                Sort(self.algorithm,'RSI',('SQQQ','BSV'),10,True,1,127,0.1008)
                        else:
                            AH(self.algorithm, 'UVXY', 127, 0.1008)
                    else:
                        if GetCurrentPrice(self.algorithm,'TQQQ') > SMA(self.algorithm, 'TQQQ', 20):
                            AH(self.algorithm, 'TQQQ', 127, 0.1008)
                        else:
                            Sort(self.algorithm,'RSI',('SQQQ','BSV'),10,True,1,127,0.1008)

    def group_equities(self):
        if CumReturn(self.algorithm, 'BND', 60) > CumReturn(self.algorithm, 'BIL', 60):
            self.risk_on_bullish()
        else:
            if SMADayRet(self.algorithm, 'TLT', 15) < 0:
                self.risk_off_rising_rates()
            else:
                self.risk_on_falling_rates()

    def risk_on_bullish(self):
        if MaxDD(self.algorithm, 'SPY', 10) < 5:
            self.group_3x_aggressive_equities()
        else:
            self.group_1x_defensive_equities()

    def group_3x_aggressive_equities(self):
        Sort(self.algorithm,'SMADayRet',('UPRO','TECL','TQQQ','SOXL','FAS'),10,False,4,127,0.1680)

    def group_1x_defensive_equities(self):
        AH(self.algorithm, 'SPY', 127, 0.0420)
        Sort(self.algorithm,'CumReturn',('RSP','RPV','QUAL','BTAL'),10,True,1,127,0.1260)

    def risk_off_rising_rates(self):
        if GetCurrentPrice(self.algorithm,'SPY') > SMA(self.algorithm, 'SPY', 25):
            self.defensive_fund_surf()
        else:
            self.fund_surf_with_shorting()

    def defensive_fund_surf(self):
        Sort(self.algorithm,'RSI',('XLP','XLE','BTAL','XLY','XLF'),10,False,3,127,0.1440)
        AH(self.algorithm, 'USDU', 127, 0.0960)

    def fund_surf_with_shorting(self):
        Sort(self.algorithm,'RSI',('XLP','XLE','SDS','SQQQ','BTAL'),10,False,3,127,0.1440)
        AH(self.algorithm, 'USDU', 127, 0.0960)

    def risk_on_falling_rates(self):
        if SMADayRet(self.algorithm, 'SPY', 25) > SMADayRet(self.algorithm, 'QUAL', 25):
            self.modified_nasdaq_buy_the_dip()
        else:
            self.recessionary_defensive()

    def modified_nasdaq_buy_the_dip(self):
        if CumReturn(self.algorithm, 'QQQ', 5) < -5:
            AH(self.algorithm, 'UPRO', 127, 0.1200)
            if CumReturn(self.algorithm, 'TQQQ', 1) > 5:
                AH(self.algorithm, 'SSO', 127, 0.1200)
            else:
                Sort(self.algorithm,'RSI',('TQQQ','TECL'),5,False,1,127,0.1200)
        else:
            AH(self.algorithm, 'SPY', 127, 0.2400)

    def recessionary_defensive(self):
        AH(self.algorithm, 'SCHD', 127, 0.1200)
        Sort(self.algorithm,'CumReturn',('RSP','RPV','QUAL','BTAL','XLP','XLF'),10,True,1,127,0.1200)

    def interest_rate_linked(self):
        self.group_treasury_bonds()

    def group_treasury_bonds(self):
        self.group_safer_20_year_treasury_bonds_with_leverage()

    def group_safer_20_year_treasury_bonds_with_leverage(self):
        if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm, 'TLT', 200):
            if RSI(self.algorithm, 'TLT', 14) < 50:
                if GetCurrentPrice(self.algorithm,'TLT') > SMA(self.algorithm, 'TLT', 5):
                    AH(self.algorithm, 'TMF', 127, 0.18)
                else:
                    if RSI(self.algorithm, 'TLT', 14) < 20:
                        AH(self.algorithm, 'TMF', 127, 0.18)
                    else:
                        self.group_leveraged_safety()
            else:
                if RSI(self.algorithm, 'TLT', 14) > 80:
                    AH(self.algorithm, 'TMV', 127, 0.18)
                else:
                    self.group_leveraged_safety()
        else:
            self.group_safety_long_term()

    def group_leveraged_safety(self):
        if SMADayRet(self.algorithm, 'TLT', 20) < 0:
            self.group_risk_off_rising_rates()
        else:
            self.group_risk_off_falling_rates()

    def group_risk_off_rising_rates(self):
        AH(self.algorithm, 'UUP', 127, 0.09)
        Sort(self.algorithm,'RSI',('PSQ','SH','UUP','TMV'),20,False,1,127,0.09)

    def group_risk_off_falling_rates(self):
        AH(self.algorithm, 'GLD', 127, 0.045) 
        AH(self.algorithm, 'TMF', 127, 0.045)
        AH(self.algorithm, 'BTAL', 127, 0.045)
        AH(self.algorithm, 'XLP', 127, 0.045)

    def group_safety_long_term(self):
        self.group_leveraged_safety()
        
    #https://app.composer.trade/symphony/MJFwIcAvjEVoRhbfBBaz/details

class RiskParityDynamicAssetAllocationStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        if MaxDD(self.algorithm, 'SPY', 10) >= 5:
            self.risk_off()
        else:
            self.risk_on()

    def risk_off(self):
        self.group_equity()
        self.group_fixed_income()

    def risk_on(self):
        self.group_equity()
        self.group_fixed_income()

    def group_equity(self):
        AH(self.algorithm, 'UPRO', 131, 0.4)

    def group_fixed_income(self):
        AH(self.algorithm, 'TMF', 131, 0.6)
#region imports
from AlgorithmImports import *
#endregion


# Your New Python File
#region imports
from AlgorithmImports import *
#endregion
from AlgorithmImports import *
from indicators import *
from main import YellowCatStrat

#https://app.composer.trade/symphony/89MBBnScMMeOlm7dZjVw/details

class PSQEquivalentStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SQQQ', 132, 0.55)
        AH(self.algorithm, 'QQQ', 132, 0.45)

#https://app.composer.trade/symphony/ugS2TJ8Ko9rcgScpYIFC/details

class HedgefundiesLeveragedStocksandBondsStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'UPRO', 133, 0.55)
        AH(self.algorithm, 'TMF', 133, 0.45)

#https://app.composer.trade/symphony/lEpHCO16WUKcVnkUXIoj/details
class CopyOf2DHiLoProtectionV2BWCBuyWriteIncomeStrategyStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.group_2DHiLoProtectionV2BWCBuyWriteIncomeStrategy()

    def group_2DHiLoProtectionV2BWCBuyWriteIncomeStrategy(self):
        if RSI(self.algorithm, 'SPY', 2) > 80:
            AH(self.algorithm, 'BIL', 134, 0.8)
            AHIV(self.algorithm, ('SQQQ', 'SOXS', 'SPXS'), 30, 134, 0.2)
        else:
            if RSI(self.algorithm, 'SPY', 2) < 10:
                Sort(self.algorithm, 'STD', ('HIBL', 'TQQQ', 'UPRO', 'SOXL', 'TECL', 'FAS', 'TNA', 'WANT', 'YINN', 'UDOW'), 20, True, 2, 134, 1)
            else:
                Sort(self.algorithm, 'STD', ('DIVO', 'XYLD', 'NUSI', 'SPYI', 'LQDW', 'TLTW', 'RYLD', 'ACIO', 'FTQI', 'PUTW'), 7, True, 2, 134, 1)

#https://app.composer.trade/symphony/gZaJy91yYYq6SHKRLzyt/details

class BenchmarkBasic6040Portfolio60SPY40BNDStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        AH(self.algorithm, 'SPY', 135, 0.6)
        AH(self.algorithm, 'BND', 135, 0.4)

#https://app.composer.trade/symphony/bGVzMtaIInv85FuVysnm/details
class BestCryptoRebalancerFeaverStrategy(YellowCatStrat):
    def __init__(self, algorithm):
        super().__init__()
        self.algorithm = algorithm

    def Execute(self):
        self.group1()
        self.group2()
    
    def group1(self):
        AH(self.algorithm, 'MSTR', 136, 0.375)
        AH(self.algorithm, 'BITX', 136, 0.375)
        
    def group2(self):
        AH(self.algorithm, 'HUT', 136, 0.0625)
        AH(self.algorithm, 'BITF', 136, 0.0625)
        AH(self.algorithm, 'MARA', 136, 0.0625)
        AH(self.algorithm, 'COIN', 136, 0.0625)
#indicators.py
from AlgorithmImports import *
from AlgorithmImports import *
import math
import pandas as pd
from cmath import sqrt
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data.Custom import *
from QuantConnect.Python import PythonData
import csv
import io
import time
import json
def RSI(self,equity,period):
    extension = min(period*5,250)
    r_w = RollingWindow[float](extension)
    history = self.History(equity,extension - 1,Resolution.Daily)
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    while r_w.Count < extension:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    if r_w.IsReady:
        average_gain = 0
        average_loss = 0
        gain = 0
        loss = 0
        for i in range(extension - 1,extension - period -1,-1):
            gain += max(r_w[i-1] - r_w[i],0)
            loss += abs(min(r_w[i-1] - r_w[i],0))
        average_gain = gain/period
        average_loss = loss/period
        for i in range(extension - period - 1,0,-1):
            average_gain = (average_gain*(period-1) + max(r_w[i-1] - r_w[i],0))/period
            average_loss = (average_loss*(period-1) + abs(min(r_w[i-1] - r_w[i],0)))/period
        if average_loss == 0:
            return 100
        else:
            rsi = 100 - (100/(1 + average_gain/average_loss))
            return rsi
    else:
        return None
def CumReturn(self,equity,period):
    history = self.History(equity,period,Resolution.Daily)
    closing_prices = pd.Series([bar.Close for bar in history])
    current_price = self.Securities[equity].Price
    closing_prices = pd.concat([closing_prices, pd.Series([current_price])])
    first_price = closing_prices.iloc[0]
    if first_price == 0:
        return None
    else:
        return_val = (current_price/first_price) - 1
        return return_val
def STD(self, equity, period):
    r_w = RollingWindow[float](period + 1)
    r_w_return = RollingWindow[float](period)
    history = self.History(equity, period, Resolution.Daily)
    
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    
    while r_w.Count < period + 1:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    
    for i in range(period, 0, -1):
        if r_w[i] != 0:
            daily_return = (r_w[i-1] / r_w[i] - 1)
        else:
            daily_return = 0  # or any other appropriate value
        r_w_return.Add(daily_return)
    
    dfstd = pd.DataFrame({'r_w_return': r_w_return})
    
    if r_w.IsReady:
        std = dfstd['r_w_return'].std()
        if std == 0:
            return 0
        else:
            return std
    else:
        return 0
def MaxDD(self, equity, period):
        history = self.History(equity,period - 1,Resolution.Daily)
        closing_prices = pd.Series([bar.Close for bar in history])
        current_price = self.Securities[equity].Price
        closing_prices = pd.concat([closing_prices, pd.Series([current_price])])
        rolling_max = closing_prices.cummax()
        drawdowns = (rolling_max - closing_prices)/rolling_max
        max_dd = drawdowns.min()
        return max_dd
def SMA(self,equity,period):

    r_w = RollingWindow[float](period)
    history = self.History(equity,period - 1,Resolution.Daily)
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    while r_w.Count < period:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    if r_w.IsReady:
        sma = sum(r_w)/period
        return sma
    else:
        return 0
def IV(self,equity,period):
    r_w = RollingWindow[float](period + 1)
    r_w_return = RollingWindow[float](period)
    history = self.History(equity,period,Resolution.Daily)
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    while r_w.Count < period + 1:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    for i in range (period,0,-1):
        if r_w[i] == 0:
            return 0
        else:
            daily_return = (r_w[i-1]/r_w[i] - 1)
            r_w_return.Add(daily_return)
    dfinverse = pd.DataFrame({'r_w_return':r_w_return})
    if r_w.IsReady:
        std = dfinverse['r_w_return'].std()
        if std == 0:
            return 0
        else:
            inv_vol = 1/std
            return inv_vol
    else:
        return 0
def SMADayRet(self,equity,period):
    r_w = RollingWindow[float](period + 1)
    r_w_return = RollingWindow[float](period)
    history = self.History(equity,period,Resolution.Daily)
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    while r_w.Count < period + 1:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    for i in range (period,0,-1):
        if r_w[i] == 0:
            return None
        daily_return = (r_w[i-1]/r_w[i] - 1)
        r_w_return.Add(daily_return)
    if r_w.IsReady:
        smareturn = sum(r_w_return)/period
        return smareturn
    else:
        return 0
def EMA(self,equity,period):
    extension = period + 50
    r_w = RollingWindow[float](extension)
    history = self.History(equity,extension - 1,Resolution.Daily)
    for historical_bar in history:
        r_w.Add(historical_bar.Close)
    while r_w.Count < extension:
        current_price = self.Securities[equity].Price
        r_w.Add(current_price)
    if r_w.IsReady:
        total_price = 0
        for i in range(extension - 1,extension - period - 2,-1):
            total_price += r_w[i]
        average_price = total_price/period
        for i in range(extension - period - 2,-1,-1):
            average_price = r_w[i]*2/(period+1) + average_price*(1-2/(period+1))
        return average_price
    else:
        return None

def Sort(self, sort_type, equities, period, reverse, num_assets, number, multiplier):
    # Update the PT value for the given strategy number
    PT = getattr(self, f"PT{number}") * multiplier

    # Define a dictionary to map sort types to functions
    indicator_functions = {
        'EMA': EMA,
        'RSI': RSI,
        'CumReturn': CumReturn,
        'STD': STD,
        'MaxDD': MaxDD,
        'SMA': SMA,
        'IV': IV,
        'SMADayRet': SMADayRet,
        # Add other indicators here as needed
    }

    # Compute the indicator value for each equity
    returns = {}
    for equity in equities:
        indicator_function = indicator_functions.get(sort_type, None)
        if callable(indicator_function):
            indicator_value = indicator_function(self, equity, period)
            if indicator_value is not None:
                returns[equity] = indicator_value

    # Sort the equities based on the indicator values
    sorted_equities = sorted(returns.items(), key=lambda x: x[1], reverse=reverse)

    # Select the top 'num_assets' from the sorted list
    top_equities = sorted_equities[:num_assets]

    # Get the current HT and HTS attributes for the strategy
    HT = getattr(self, f"HT{number}")
    HTS = getattr(self, f"HTS{number}")

    # Assign each of the top equities to the next available slot in HT and HTS
    for equity, value in top_equities:
        for i in HT.keys():
            if HT[i] == 0:
                HT[i] = PT / num_assets  # Distribute PT evenly among the assets
                HTS[i].append(equity)  # Append the asset symbol
                break  # Move to the next asset after appending

    # Update the HT and HTS attributes for the strategy
    setattr(self, f"HT{number}", HT)
    setattr(self, f"HTS{number}", HTS)


def AH(self,equities,PTnumber,multiplier): #AppendHolding
    if not isinstance(equities,list):
        equities = [equities]
    HT = getattr(self,f"HT{PTnumber}")
    HTS = getattr(self,f"HTS{PTnumber}")
    PT = getattr(self,f"PT{PTnumber}") * multiplier
    
    for equity in equities:
        for i in HT.keys():
            if HT[i] == 0:
                HT[i] = PT
                HTS[i].append(equity)
                break

def GetCurrentPrice(self, symbol):
    """
    Gets the current price of a security.

    :param self: The self instance containing the securities.
    :param symbol: The symbol of the security.
    :return: The current price of the security or None if not available.
    """
    if symbol in self.Securities:
        return self.Securities[symbol].Price
    else:
        self.Debug(f"Symbol {symbol} not found in securities.")
        return None

def AHIV(self, assets, period, PTnumber,multiplier):
    # Calculate sum_IV_assets
    tickers_IV = [f"IV(self, '{ticker}', {period})" for ticker in assets]
    sum_IV_assets = '+'.join(tickers_IV)

    # Execute the sum_IV_assets calculation
    sum_IV_assets_value = eval(sum_IV_assets)

    HT = getattr(self, f"HT{PTnumber}")
    HTS = getattr(self, f"HTS{PTnumber}")
    PT = getattr(self,f"PT{PTnumber}") * multiplier

    # Call the AH function for each asset with the calculated portion
    for ticker in assets:
        IV_value = eval(f"IV(self, '{ticker}', {period})")
        portion = IV_value / sum_IV_assets_value

        if not isinstance(ticker, list):
            ticker = [ticker]

        for equity in ticker:
            for i in HT.keys():
                if HT[i] == 0:
                    HT[i] = portion*PT
                    HTS[i].append(equity)
                    break

def GroupSort(self, filter_type, def_str_method, window, select_type, num_assets, number, multiplier):
    # Invoke the specified method to get a list of equities and their weights
    equities, weights = def_str_method()

    # Define a dictionary to map filter types to their corresponding functions
    indicator_functions = {
        'EMA': EMA,
        'RSI': RSI,
        'CumReturn': CumReturn,
        'STD': STD,
        'MaxDD': MaxDD,
        'SMA': SMA,
        'IV': IV,
        'SMADayRet': SMADayRet,
    }

    # Ensure the filter type is supported
    if filter_type not in indicator_functions:
        raise ValueError(f"Unsupported filter type: {filter_type}")

    # Calculate the weighted indicator values for each equity
    weighted_indicator_values = {}
    for equity, weight in zip(equities, weights):
        indicator_value = indicator_functions[filter_type](self, equity, window)
        if indicator_value is not None:
            weighted_indicator_values[equity] = weight * indicator_value

    # Determine sorting direction
    reverse = True if select_type == 'Top' else False

    # Sort equities based on the weighted indicator values
    sorted_equities = sorted(weighted_indicator_values.items(), key=lambda x: x[1], reverse=reverse)[:num_assets]

    # Get the current HT and HTS attributes for the strategy
    HT = getattr(self, f"HT{number}")
    HTS = getattr(self, f"HTS{number}")

    # Update HT and HTS based on the sorted equities
    total_weight = sum(weight for _, weight in sorted_equities)
    for equity, _ in sorted_equities:
        for i in HT.keys():
            if HT[i] == 0:
                HT[i] = (weights[equities.index(equity)] / total_weight) * multiplier
                HTS[i].append(equity)
                break

    # Update the HT and HTS attributes for the strategy
    setattr(self, f"HT{number}", HT)
    setattr(self, f"HTS{number}", HTS)
# main.py
from AlgorithmImports import *
import math
import pandas as pd
from cmath import sqrt
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data.Custom import *
from QuantConnect.Python import PythonData
import csv
import io
import time
import json
import os
import importlib
import inspect
import re
from indicators import *

class YellowCatStrat(QCAlgorithm):

    def Initialize(self):
        self.cash = 100000
        
        self.SetStartDate(2019,1,12)
        self.SetEndDate(2024,4,17)
        self.SetCash(self.cash)
        self.equities = ['BRK/B','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AMN','CHD','CVBF','DG','ERIE','FCN','FFNW','NTES','OTTR','PGR','PINC','QDEL','RLI','RMD','SFM','SMMF','TPB','UBCP','VIPS','VRTX','WDFC','ZM','BIL','IEF','SOXL','SOXS','NTSX','DBMF','BSJN','VIXM','UNH','COST','QQQ','SMH','JEPI','UPRO','AAPL','TSLA','GOOG','MSFT','NVDA','JNJ','AMZN','JPM','META','PG','MA','SPY','DIA','IWM','ATEN','CCRD','CHKP','CRUS','CSCO','DQ','ECOM','ELTK','ERIC','HCKT','INFY','JKHY','LOGI','MNDO','NSYS','QLYS','SIMO','TSM','TSRI','WSTG','SVXY','MSTR','COIN','MARA','HUT','BITF','RIOT','TQQQ','UDOW','TECL','AAPB','AAPD','BITX','PYPL','ADBE','SPXL','TLT','FNGU','TMV','VTI','DBC','GLD','UVXY','SQQQ','UDN','UUP','HEQT','BTAL','TJUL','RSBT','SPYC','TMF','XLF','VO','IJR','DLTR','WMT','XLU','XLV','XLRE','XLE','XBI','XLK','XLY','VOX','VFH','VDC','VAW','VIS','VGT','VPU','VCR','VHT','VDE','VNQ','MCD','REGN','KMB','UL','FAS','IEI','UTWO','EFA','EEM','AGG','SLV','USO','UNG','XLP','XLC','XLI','XLB','NFLX','XOM','BND','GOOGL','ERX','IEP','LQD','BK','ED','KO','PFE','IBM','TYD','UGL','TSLY','CONY','NVDY','AMDY','APLY','AMZY','OARK','DISO','GOOY','PYPY','MSFO','JPMO','XOMO','NFLY','FBY','SQY','MRNY','FEPI','SARK','SVIX','TBT','TBF','ABBV','BAC','WFC','NEE','DUK','EXC','SHY','SHYG','YINN','QYLD','RYLD','XYLD','NUSI','SCHD','DIVO','QLD','QID','SDS','USA','SHV','HYG','TIP','WBA','MMM','ULTA','MNST','BSV','SPXS','SH','STIP','CLIP','VGSH','VOO','JEPQ','COM','FAAR','FTLS','CCOR','EWA','EWG','EWP','EWQ','EWU','EWJ','EWI','EWN','UCO','SCO','BOIL','KOLD','EUO','YCS','YCL','ULE','DBA','DBB','URA','WOOD','GLL','RSP','RPV','QUAL','USDU','SSO','PSQ','SPXU','SPHB','VIXY','USD','CURE','TECS','EWZ','MVV','EPI','TNA','PUI','KMLM','FMF','CTA','WTMF','ROM','RXL','UCC','UJB','PPLT','GLTR','SUB','SPLV','SJB','NRGU','RLY','GAA','TRTY','GDMA','MNA','VAMO','GMOM','ICSH','UPW','TPOR','DIS','HD','GSY','SRTY','XENE','ARCT','CRSP','IMRX','NAMS','BPMC','IMUX','HOWL','AUTL','ETNB','IEO','ATXS','SERA','PNT','FUSN','PYXS','EXAI','ICVX','IOVA','CRBU','ROIV','CDTX','TRDA','CRVS','AKBA','EDC','SON','TWM','RWM','URTY','PBR','OIL','ROST','WMS','TSLQ','TSLS','ALGN','TPL','VLO','AA','BITI','HIBS','ACLS','EQT','MOS','AR','MU','CZR','UVIX','ENPH','AMEH','GNRC','BULZ','VCIT','AMD','TSLL','AEHR','TARK','QQQE','VOOG','VOOV','VTV','HIBL','VTIP','EDV','SPTL','IAU','VEA','UTSL','WEAT','CORN','DRN','PDBC','COMT','ESPO','PEJ','URE','VXX','DUST','JDST','JNUG','GUSH','PALL','AGQ','BAL','DBO','TAGS','CANE','REMX','COPX','SPDN','CHAD','DRIP','SPUU','INDL','BRZU','ERY','CWEB','CHAU','KORU','MEXX','EDZ','EURL','YANG','TZA','MIDU','TYO','LABU','LABD','RETL','DPST','DRV','PILL','FAZ','EWGS','ECC','NURE','VNQI','SOXX','WEBL','WEBS','UBT','PST','TLH','SQM','SD','DGRO','SGOL','DUG','TBX','VGIT','VGLT','LBAY','NRGD','PHDG','SPHD','COWZ','VIGI','NOBL','BITO','MORT','FNDX','RWL','VLUE','SPYG','VXUS','AAL','AEP','AFL','GM','INTC','MET','NWE','OXY','RTX','SNY','SO','TMUS','VZ','BA','CB','COKE','FDX','GE','LMT','MRK','NVEC','ORCL','PEP','DBE','SCHG','SGML','SLDP','ARKQ','AMZU','BAD','DDM','IYH','PM','IYK','DIG','FXE','FXY','EXG','VCSH','HTS','HT','ARKK','IBIT','GBTC']
        
        for equity in self.equities:
            self.AddEquity(equity,Resolution.Minute)
            self.Securities[equity].SetDataNormalizationMode(DataNormalizationMode.Adjusted)
        self.AddEquity('BIL',Resolution.Minute)
        self.Securities['BIL'].SetDataNormalizationMode(DataNormalizationMode.TotalReturn)

        # Base directory for strategies
        strategy_base_dir = "Strategies"
        
        # List of strategy names (you would populate this list dynamically)
        self.strategy_names = [
            "CombinedStrategy1",
            "CombinedStrategy2",
            # Add other strategy names here...
        ]

        # Get the absolute path of the current file (main.py)
        current_file_path = os.path.abspath(__file__)

        # Get the directory of the current file
        current_directory = os.path.dirname(current_file_path)

        # Construct the path to the Strategies folder
        strategies_directory = os.path.join(current_directory, "Strategies")

        # Dynamically import strategies and create instances
        self.strategies = {}

        # Generate setattr(self, f'HT...') from 1 to 3000
        for i in range(1, 3001):
            setattr(self, f'HT{i}', {str(j).zfill(2): 0 for j in range(1, 20)})
            setattr(self, f'HTS{i}', {str(j).zfill(2): [] for j in range(1, 20)})

        for strategy_name in self.strategy_names:
            strategy_module_name = f"Strategies.{strategy_name}.version1"
            strategy_module = importlib.import_module(strategy_module_name)

            # Get the source code of the strategy module
            strategy_module_source = inspect.getsource(strategy_module)

            # Find all occurrences of "class ...Strategy" in the source code
            strategy_class_names = re.findall(r'class\s+(\w+Strategy)', strategy_module_source)

            for strategy_class_name in strategy_class_names:
                # Get the strategy class from the module
                strategy_class = getattr(strategy_module, strategy_class_name)

                # Extract the assigned number from the strategy class name if available
                assigned_numbers = re.findall(r'\d+', strategy_class_name)
                if assigned_numbers:
                    assigned_number = int(assigned_numbers[0])
                else:
                    assigned_number = None

                # Create an instance of the strategy class, passing 'self' as the 'context' argument
                strategy_instance = strategy_class(self)

                # Store the strategy instance in the dictionary
                self.strategies[strategy_class_name] = strategy_instance

        self.PTMaster = 1

        self.days_history = 10
        self.number_to_pick = 37
        self.correlation_number = 0.01
        self.filter_value = 0.005
        self.buffer_pct = 0.02 #Rebalance

        self.initializePrevDayVariables(len(self.strategies), self.days_history)
        self.initializePrevDayReturnVariables(len(self.strategies), self.days_history)

        # Fixed strategies and their percentages
        self.fixed_strategies = {
            1: 0.20,  # Strategy 1 with 26%
            2: 0.10,  # Strategy 2 with 16%
            3: 0.05   # Strategy 3 with 7%
        }

        # Calculate the percentage for each dynamic strategy
        dynamic_strategy_percentage = (0.99 - sum(self.fixed_strategies.values())) / (self.number_to_pick - len(self.fixed_strategies))

        # Initialize PT variables for each strategy
        for i in range(1, len(self.strategies) + 1):
            if i in self.fixed_strategies:
                setattr(self, f'PT{i}', self.fixed_strategies[i] * self.PTMaster)
            else:
                setattr(self, f'PT{i}', dynamic_strategy_percentage * self.PTMaster)
                
        self.Schedule.On(self.DateRules.EveryDay("SPY"),
                self.TimeRules.BeforeMarketClose("SPY",2),
                self.FunctionBeforeMarketClose)

    def initializePrevDayVariables(self, strategy_count, days_history):
        for i in range(1, strategy_count + 1):
            for day in range(1, days_history + 1):
                setattr(self, f'prev_day_HT{i}_{day}', {str(j).zfill(2): 0 for j in range(1, 20)})
                setattr(self, f'prev_day_HTS{i}_{day}', {str(j).zfill(2): [] for j in range(1, 20)})

    def initializePrevDayReturnVariables(self, strategy_count, days_history):
        for i in range(1, strategy_count + 1):
            for day in range(1, days_history + 1):
                setattr(self, f'prev_day_return{i}_{day}', 0.0)

    def CumReturn(self,equity,period):
        history = self.History(equity,period,Resolution.Daily)
        closing_prices = pd.Series([bar.Close for bar in history])
        current_price = self.Securities[equity].Price
        closing_prices = pd.concat([closing_prices, pd.Series([current_price])])
        first_price = closing_prices.iloc[0]
        if first_price == 0:
            return None
        else:
            return_val = (current_price/first_price) - 1
            return return_val
            
    def OnData(self, data):
        # This function is called every time new data is received
        pass

    def FunctionBeforeMarketClose(self):
        # Execute all strategies stored in the dictionary
        for strategy_name, strategy in self.strategies.items():
            strategy.Execute()
        self.updatePrevDayVariables()
        #self.StrategyReturn()
        self.CalculateAndLogTopStrategies()
        self.ExecuteTrade()
        self.SetVarToZero()

    def ExecuteTrade(self):
        df_list = []

        # Process each top-performing strategy
        for strategy_number in self.FinalTickers:
            HTS_attr = getattr(self, f'HTS{strategy_number}')
            HT_attr = getattr(self, f'HT{strategy_number}')

            group = {
                'HTS': [HTS_attr[i][0] if len(HTS_attr[i]) == 1 else HTS_attr[i] for i in HTS_attr],
                'HT': [HT_attr[i]/1 for i in HT_attr]
            }
            df = pd.DataFrame(group)
            df_list.append(df)

        # Combine all dataframes
        df_combined = pd.concat(df_list)
        df_combined['HTS'] = df_combined['HTS'].astype(str)
        result = df_combined.groupby(['HTS']).sum().reset_index()
        # Dictionary with pairs
        pairs_dict = {'SOXL':'SOXS','TQQQ':'SQQQ','SPXL':'SPXS','WEBL':'WEBS','TECL':'TECS','UPRO':'SPXU','QQQ':'PSQ','SPY':'SH','TMV':'TMF','HIBL':'HIBS','BITO':'BITI','TSLA':'TSLS','AAPL':'AAPD','ERX':'ERY','BOIL':'KOLD','LABU':'LABD','JNUG':'JDST','ARKK':'SARK','IBIT':'BITI'}
        pairs_dict.update({v: k for k,v in pairs_dict.items()}) #ensure both directions are covered
        # Track selling and buying
        processed_pairs_selling = set()
        processed_pairs_buying = set()
        liquidated_equities = set()
        # Exclude symbols
        exclude_symbols = ['BIL','BSV','SHV','SHY','IEI','STIP','VCIT','LQD','VTIP','TLT','BND','IEF','TIP','VGIT','IYK']
        # dictionary
        symbol_dict = dict(zip(result.iloc[:,0],result.iloc[:,1]))
        # Log output
        output = "*****"
        for symbol, percentage in symbol_dict.items():
            output += "{}: {}% - ".format(symbol, round(percentage*100, 2))
        output = output.rstrip(" - ")
        self.Log(output)
        # Symbols to be transformed
        transform_symbols = ['PSQ','SH','USDU','SPXU','UPRO','QLD','QID','TSLS','ARKK','FNGU','IBIT']
        transform_mapping = {'PSQ':'SQQQ','SH':'SPXS','USDU':'UUP','SPXU':'SPXS','UPRO':'SPXL','QLD':'TQQQ','QID':'SQQQ','TSLS':'TSLQ','ARKK':'TARK','FNGU':'SOXL','GBTC':'BITO','IBIT':'BITO'}
        transform_ratios = {'PSQ':3,'SH':3,'USDU':1,'SPXU':1,'UPRO':1,'QLD':1.5,'QID':1.5,'TSLS':1,'ARKK':2,'FNGU':1,'GBTC':1,'IBIT':1}
        # Transform symbols
        for symbol in transform_symbols:
            if symbol in symbol_dict:
                new_symbol = transform_mapping[symbol]
                ratio = transform_ratios[symbol]
                new_percentage = symbol_dict[symbol]/ratio 
                # Adjust percentage allocation
                if new_symbol in symbol_dict:
                    new_percentage += symbol_dict[new_symbol]
                symbol_dict[new_symbol] = new_percentage
                # Remove transformed
                symbol_dict.pop(symbol, None)
        # Ensure updated equities list
        updated_equities = set(symbol_dict.keys())
        # Liquidate equities
        for equity in self.equities:
            if equity not in updated_equities and self.Portfolio[equity].HoldStock and equity not in liquidated_equities:
                self.Liquidate(equity)
                liquidated_equities.add(equity)
        # Iterate pairs selling
        for symbol1,symbol2 in pairs_dict.items():
            if symbol1 in symbol_dict and symbol2 in symbol_dict:
                offset_value = abs(symbol_dict[symbol1] - symbol_dict[symbol2])
                if symbol_dict[symbol1] >= symbol_dict[symbol2] and self.Portfolio[symbol2].HoldStock:
                    self.Liquidate(symbol2)
                elif symbol_dict[symbol1] <= symbol_dict[symbol2] and self.Portfolio[symbol1].HoldStock:
                    self.Liquidate(symbol1)
                # Mark processed selling
                processed_pairs_selling.add(symbol1)
                processed_pairs_selling.add(symbol2)
        # Iterate remaining selling
        for symbol,value in symbol_dict.items():
            if symbol not in processed_pairs_selling and not value == 0 and symbol not in exclude_symbols:
                if isinstance(symbol, str) and symbol.startswith("['") and symbol.endswith("']"):
                    symbol_list = eval(symbol)
                    percentage_equity = sum(self.Portfolio[s].HoldingsValue for s in symbol_list) / self.Portfolio.TotalPortfolioValue
                else:
                    percentage_equity = self.Portfolio[symbol].HoldingsValue/self.Portfolio.TotalPortfolioValue
                if value < percentage_equity and abs(value/percentage_equity - 1) > self.buffer_pct:
                    if isinstance(symbol, str) and symbol.startswith("['") and symbol.endswith("']"):
                        symbol_list = eval(symbol)
                        for s in symbol_list:
                            self.SetHoldings(s, value / len(symbol_list))
                    else:
                        self.SetHoldings(symbol,value)
        # Iterate pairs buying
        for symbol1,symbol2 in pairs_dict.items():
            if symbol1 in symbol_dict and symbol2 in symbol_dict and symbol1 not in processed_pairs_buying and symbol2 not in processed_pairs_buying:
                offset_value = abs(symbol_dict[symbol1] - symbol_dict[symbol2])
                if offset_value > self.filter_value:
                    if symbol_dict[symbol1] > symbol_dict[symbol2]:
                        if isinstance(symbol1, list):
                            for s in symbol1:
                                self.SetHoldings(s, offset_value / len(symbol1))
                        else:
                            self.SetHoldings(symbol1,offset_value)
                    else:
                        if isinstance(symbol2, list):
                            for s in symbol2:
                                self.SetHoldings(s, offset_value / len(symbol2))
                        else:
                            self.SetHoldings(symbol2,offset_value)
                else:
                    if isinstance(symbol1, list):
                        for s in symbol1:
                            if self.Portfolio[s].HoldStock:
                                self.Liquidate(s)
                    else:
                        if self.Portfolio[symbol1].HoldStock:
                            self.Liquidate(symbol1)
                    if isinstance(symbol2, list):
                        for s in symbol2:
                            if self.Portfolio[s].HoldStock:
                                self.Liquidate(s)
                    else:
                        if self.Portfolio[symbol2].HoldStock:
                            self.Liquidate(symbol2)
                # Mark as processed buying
                processed_pairs_buying.add(symbol1)
                processed_pairs_buying.add(symbol2)
        # Filter less than 1%
        updated_equities = {symbol for symbol, value in symbol_dict.items() if value >= self.filter_value}
        # Iterate remaining symbol_dict for buying
        for symbol,value in symbol_dict.items():
            if (symbol in updated_equities and 
                symbol not in processed_pairs_buying and 
                symbol not in exclude_symbols):
                if isinstance(symbol, str) and symbol.startswith("['") and symbol.endswith("']"):
                    symbol_list = eval(symbol)
                    percentage_equity = sum(self.Portfolio[s].HoldingsValue for s in symbol_list) / self.Portfolio.TotalPortfolioValue
                else:
                    percentage_equity = (self.Portfolio[symbol].HoldingsValue /
                                        self.Portfolio.TotalPortfolioValue)
                if value > percentage_equity and abs(percentage_equity/value - 1) > self.buffer_pct:
                    if isinstance(symbol, str) and symbol.startswith("['") and symbol.endswith("']"):
                        symbol_list = eval(symbol)
                        for s in symbol_list:
                            self.SetHoldings(s, value / len(symbol_list))
                    else:
                        self.SetHoldings(symbol,value)

    def SetVarToZero(self):
        for strategy_number in range(1, len(self.strategies) + 1):
            setattr(self, f'HT{strategy_number}', {str(j).zfill(2): 0 for j in range(1, 20)})
            setattr(self, f'HTS{strategy_number}', {str(j).zfill(2): [] for j in range(1, 20)})

    def CalculateDailyReturn(self, strategy_number, days, day_number):
        prev_day_HT = getattr(self, f'prev_day_HT{strategy_number}_{day_number}')
        prev_day_HTS = getattr(self, f'prev_day_HTS{strategy_number}_{day_number}')
        PT_value = getattr(self, f'PT{strategy_number}')  # Retrieve PT value for the strategy

        total_return = 0
        for key in prev_day_HTS:
            tickers = prev_day_HTS[key]
            weight = prev_day_HT[key]
            if tickers and weight != 0:
                if isinstance(tickers, list):
                    tickers_return = sum([self.CumReturn(ticker, days) if self.CumReturn(ticker, days) is not None else 0 for ticker in tickers])
                else:
                    tickers_return = self.CumReturn(tickers, days)
                total_return += tickers_return * weight

        # Normalize the return by the strategy's PT value
        return total_return / PT_value if PT_value != 0 else 0

    def updatePrevDayVariables(self):
        self.storeDailyReturns()

        for i in range(1, len(self.strategies) + 1):
            # Shift data for each day
            for day in range(self.days_history, 1, -1):
                setattr(self, f'prev_day_HT{i}_{day}', getattr(self, f'prev_day_HT{i}_{day - 1}').copy())
                setattr(self, f'prev_day_HTS{i}_{day}', {k: v.copy() for k, v in getattr(self, f'prev_day_HTS{i}_{day - 1}').items()})

            # Update day 1 with the current day's data
            current_day_HT = getattr(self, f'HT{i}')
            current_day_HTS = getattr(self, f'HTS{i}')
            setattr(self, f'prev_day_HT{i}_1', current_day_HT.copy())
            setattr(self, f'prev_day_HTS{i}_1', {k: v.copy() for k, v in current_day_HTS.items()})

    def storeDailyReturns(self):
        for i in range(1, len(self.strategies) + 1):
            current_return = self.CalculateDailyReturn(i, 1, 1)
            for day in range(self.days_history, 1, -1):
                prev_return = getattr(self, f'prev_day_return{i}_{day - 1}')
                setattr(self, f'prev_day_return{i}_{day}', prev_return)

            # Store the current day's return
            setattr(self, f'prev_day_return{i}_1', current_return)

    def GetStrategyHoldings(self, strategy_number):
        HT_attr = getattr(self, f'HT{strategy_number}')
        HTS_attr = getattr(self, f'HTS{strategy_number}')

        holdings_info = ', '.join([f"{ticker}: {round(HT_attr[key] * 100, 2)}%" 
                                   for key, tickers in HTS_attr.items() 
                                   if tickers 
                                   for ticker in (tickers if isinstance(tickers, list) else [tickers])])
        return holdings_info

    def CalculateDailyVolatility(self, strategy_number, days):
        returns = [getattr(self, f'prev_day_return{strategy_number}_{day}', 0) for day in range(1, days + 1)]
        if len(returns) < 2:
            return 0
        
        volatility = np.std(returns)
        return volatility

    def CalculateDailyMaxDrawdown(self, strategy_number, days):
        returns = [getattr(self, f'prev_day_return{strategy_number}_{day}', 0) for day in range(1, days + 1)]
        if len(returns) < 2:
            return 0
        
        cumulative_returns = np.cumsum(returns)
        peak = np.maximum.accumulate(cumulative_returns)
        drawdown = (cumulative_returns - peak) / (peak + 1e-8)
        max_drawdown = np.min(drawdown)
        
        return max_drawdown

    def CalculateAndLogTopStrategies(self):
        # Calculate the percentage for each dynamic strategy
        dynamic_strategy_percentage = (1 - sum(self.fixed_strategies.values())) / (self.number_to_pick - len(self.fixed_strategies))

        # Initialize dictionaries to store strategy metrics
        self.strategy_avg_returns = {}
        self.strategy_volatility = {}
        self.strategy_max_drawdown = {}

        # Calculate metrics for each strategy
        for strategy_number in range(1, len(self.strategies) + 1):
            daily_returns = [getattr(self, f'prev_day_return{strategy_number}_{day}', 0) for day in range(1, self.days_history+1)]
            self.strategy_avg_returns[strategy_number] = sum(daily_returns) / len(daily_returns)
            self.strategy_volatility[strategy_number] = self.CalculateDailyVolatility(strategy_number, self.days_history)
            self.strategy_max_drawdown[strategy_number] = self.CalculateDailyMaxDrawdown(strategy_number, self.days_history)
        # Exclude fixed strategies from the dynamic selection
        dynamic_strategies = [i for i in range(1, len(self.strategies) + 1) if i not in self.fixed_strategies]

        # Select the best strategies based on each criterion
        self.DynamicTickers = []
        self.DynamicTickers.extend(sorted(dynamic_strategies, key=lambda x: self.strategy_volatility[x])[:self.days_history])

        # Check if there are less than self.days_history max drawdown values different than 0
        non_zero_max_drawdown = [x for x in dynamic_strategies if self.strategy_max_drawdown[x] != 0]
        if len(non_zero_max_drawdown) < self.days_history:
            # Sort based on average returns if there are less than self.days_history max drawdown values different than 0
            self.DynamicTickers.extend(sorted(dynamic_strategies, key=lambda x: self.strategy_avg_returns[x], reverse=True)[:self.days_history])
        else:
            # Sort based on max drawdown if there are at least self.days_history max drawdown values different than 0
            self.DynamicTickers.extend(sorted(dynamic_strategies, key=lambda x: self.strategy_max_drawdown[x], reverse=True)[:self.days_history])

        self.DynamicTickers.extend(sorted(dynamic_strategies, key=lambda x: self.strategy_avg_returns[x], reverse=True)[:(self.number_to_pick - self.days_history * 2)])
        self.DynamicTickers = list(set(self.DynamicTickers))

        # Combine fixed and dynamic strategies
        self.FinalTickers = list(self.fixed_strategies.keys()) + self.DynamicTickers

        # Log the strategies, their percentages, holdings, and metrics
        self.Log("Strategies, Percentages, Holdings, and Metrics:")
        for index, strategy_number in enumerate(self.FinalTickers, start=1):
            if strategy_number in self.fixed_strategies:
                percentage = self.fixed_strategies[strategy_number] * 100
            else:
                percentage = dynamic_strategy_percentage * 100

            strategy_name = self.get_strategy_name(strategy_number)
            holdings_info = self.GetStrategyHoldings(strategy_number)
            avg_return = self.strategy_avg_returns[strategy_number]
            volatility = self.strategy_volatility[strategy_number]
            max_drawdown = self.strategy_max_drawdown[strategy_number]

            self.Log(f"Strategy {index}: {strategy_name}, Percentage: {round(percentage, 2)}%, Holdings: {holdings_info}, "
                    f"Avg Return ({self.days_history} Days): {avg_return:.4f}, Volatility: {volatility:.4f}, "
                    f"Max Drawdown: {max_drawdown:.4f}")

        self.Log("-" * 50)

    def get_strategy_name(self, strategy_number):
        for i, (strategy_name, strategy_instance) in enumerate(self.strategies.items(), start=1):
            if i == strategy_number:
                return type(strategy_instance).__name__
        return ""