Overall Statistics
Total Trades
8
Average Win
0.00%
Average Loss
-0.19%
Compounding Annual Return
-6.528%
Drawdown
0.800%
Expectancy
-0.749
Net Profit
-0.566%
Sharpe Ratio
-2.856
Probabilistic Sharpe Ratio
6.842%
Loss Rate
75%
Win Rate
25%
Profit-Loss Ratio
0.00
Alpha
-0.05
Beta
0.043
Annual Standard Deviation
0.016
Annual Variance
0
Information Ratio
-0.766
Tracking Error
0.159
Treynor Ratio
-1.081
Total Fees
$13.29
Estimated Strategy Capacity
$860000.00
Lowest Capacity Asset
NWSVV VHJF6S7EZRL1
class WellDressedYellowCat(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2015, 9, 1)  # Set Start Date
        self.SetEndDate(2015, 10, 1) # Set End Date
        self.SetCash(100000)  # Set Strategy Cash
        
        self.AddRiskManagement(TrailingStopRiskManagementModel(0.03))
        
        tickerList = ['STX','QRVO','BIG','THC','DV','FDO','VRTX','FTNT','PLL','RRD','ENDP','RX','MKTX','SE','R','WFM','KEYS','JNPR','PCL','NKTR','AVB','GNW','HRS','STE','COV','AV','DPS','LNT','WST','GOOGL','LIFE','DISCK','AMCR','MLM','HP','CBE','BXLT','WFR','EVRG','BLK','NYX','BRO','BRCM','POM','FMC','URBN','ZBRA','SBL','NFX','RCL','SNI','SBAC','NAVI','SYF','FRC','GMCR','CPGX','SWY','RAD','ALB','UNM','QEP','MMI','ARNC','EMC','APOL','MJN','VTR','MEE','PBCT','RMD','LEH','KBH','EW','CFG','EP','X','CRM','FII','MPC','HCBK','AMZN','ICE','EK','SCG','XLNX','CPWR','HCA','CPRI','JOY','ESV','CA','PETM','MNK','CRL','CEG','LDW','GGP','ANSS','NOV','AME','ROST','WRB','ALK','AOS','FSLR','NDSN','ABS','LRCX','CHK','DRE','NCLH','MOLX','MXIM','GME','HRB','TECH','WCG','SEDG','FTR','BR','SAI','CMG','PBI','GAS','NYT','GPN','ITT','XRX','GENZ','BMS','PSX','RAI','PTC','WIN','TMUS','FRE','DXCM','VRSK','DELL','JKHY','RJF','DISH','ACAS','FDC','EQIX','UA','LYV','CSC','TRB','DJ','GR','CHD','SRCL','ILMN','AJG','LO','FB','LLL','CBOE','MTCH','GRMN','WPX','DYN','MAC','LDOS','SIG','TER','AKS','ROL','XL','CDAY','LSI','PCS','AYI','TFX','IEX','HRL','TTWO','TLAB','TYL','FLS','EXPE','HBI','FANG','GNRC','OMX','NE','QTRN','SGP','JCP','PDCO','KHC','MPWR','CTX','MAT','LYB','COG','ALLE','KMI','JDSU','MHK','CSRA','JNS','ANR','ULTA','AMD','PNR','BHF','MAA','NOVL','LXK','BTU','PAYC','KSS','AN','AWK','CIEN','DD','AYE','MON','GLK','DF','DAL','MUR','ANET','JEC','JBL','NOW','UDR','KG','KFT','HSP','BCR','GPS','DO','PYPL','DXC','FTI','PRGO','LVLT','ETSY','ALTR','APC','HOG','ADS','TSCO','LUK','NXPI','ADT','BWA','KRFT','PKG','JNY','DLR','IPGP','RSH','CTVA','LKQ','ABMD','HNZ','LEG','ESRX','INCY','OI','SLR','ESS','JWN','CELG','IDXX','SHLD','CMCSK','PTV','NFLX','CDNS','PCG','DWDP','HII','RE','PCP','PVH','ALGN','NSM','COL','SLM','T','STI','ABBV','JEF','HSIC','USL','NWS','TRMB','ETFC','ATI','SWN','CHTR','MWW','TRIP','STJ','TSS','DNR','SIVB','TYC','COTY','CARR','OTIS','TDC','ALXN','BEAM','STR','KSU','TIE','MOS','TWTR','FDS','SII','CXO','SLE','FLR','EXR','ZTS','FTV','CCI','AMG','M','MRNA','AAP','WAB','COO','UAL','UHS','VAR','XEC','REG','DOW','FAST','MTD','GT','NBR','HOT','TGNA','MSCI','ANF','CPT','AIV','YHOO','CVH','BC','FRT','WU','CAM','HOLX','FHN','CEPH','TEG','TDY','SUN','PCLN','ENPH','FFIV','REGN','FOX','EQT','CCE','TE','DLTR','NBL','RIG','CPRT','KMX','AET','RDC','TIF','STZ','FL','MFE','SIAL','ATVI','TWX','CDW','MI','VIAB','BBBY','TEL','GHC','ARE','DFS','SMS','DLPH','FLIR','FLT','SLG','BS','EPAM','ARG','CVC','CB','WLTW','AA','BIO','FNM','SNPS','HLT','SBNY','ACE','RHT','TSLA','ABK','KORS','DTV','POOL','LM','IR','JBHT','S','TDG','MHS','ACN','FOSL','LW','VNT','GRA','RTN','ATO','PENN','CE','INFO','NCR','TSG','CNC','HFC','INTU','XYL','CERN','NVLS','V','TWC','CLF','AAL','O','HPE','CZR','MOH','AGN','SWKS','LLTC','RRC','IGT','SNDK','DPZ','CTLT','SBUX','MGM','CCK','HAR','LVS','SPLS','FOXA','ODP','GM','MBI','URI','CFN','OGN','DG','FRX','DNB','UAA','NVR','WYN','TSO','HWM','ANDV','EVHC','CVG','MNST','KSE','FBHS','IT','Q','CNX','XTO','BMC','BJS','PGN','AVGO','AVP','MIL','NLSN','ODFL','WB','SVU']
        for ticker in tickerList:
            self.AddEquity(ticker, Resolution.Hour)
        
        self.change = self.AddData(SPXChange, "change", Resolution.Hour).Symbol


    def OnData(self, data: Slice):
        if self.change in data:
            targets = []
            for ticker in data[self.change].Added:
                if ticker in data:
                    targets.append(PortfolioTarget(ticker, 0.1))
            for ticker in data[self.change].Removed:
                if ticker in data:
                    targets.append(PortfolioTarget(ticker, -0.05))
            self.SetHoldings(targets)


class SPXChange(PythonData):

    def GetSource(self, config, date, isLive):
        source = "https://www.dropbox.com/s/7nl66xfh1jukgma/SPYChangesWiki.csv?dl=1"
        return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile);

    def Reader(self, config, line, date, isLive):
        if not (line.strip() and line[0].isdigit()):
            return None
        
        data = line.split(',')
        change = SPXChange()

        try:
            change.Symbol = config.Symbol
            change.Time = datetime.strptime(data[0], '%Y-%m-%d') + timedelta(hours=11) # - timedelta(days=5)
            
            change.Value = 0
            change["Added"] = str(data[1]).split(" ")
            change["Removed"] = str(data[2]).split(" ")

        except ValueError:
            return None
        
        return change