Overall Statistics
Total Trades
22
Average Win
3.21%
Average Loss
-0.03%
Compounding Annual Return
-0.075%
Drawdown
17.900%
Expectancy
8.015
Net Profit
-0.157%
Sharpe Ratio
0.056
Loss Rate
92%
Win Rate
8%
Profit-Loss Ratio
107.18
Alpha
-0.079
Beta
4.278
Annual Standard Deviation
0.123
Annual Variance
0.015
Information Ratio
-0.107
Tracking Error
0.123
Treynor Ratio
0.002
Total Fees
$79.18
import numpy as np
import datetime

class SellInMayBuyInNov(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2017,1, 1)  #Set Start Date
        self.SetEndDate(2019,2,1)    #Set End Date
        self.SetCash(1000000)           #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        self.AddEquity("SPY", Resolution.Daily,Leverage=1,fillDataForward = True, extendedMarketHours = False)
        self.SetRunMode(RunMode.Series)
        

    def OnData(self, data):
        if self.Time.month == 5:
            if self.Portfolio.Invested:
                self.SetHoldings("SPY", -1)
                self.Debug("Sell In May " + str(self.Time.year))
        elif self.Time.month  == 11:
            if not self.Portfolio.Invested:
                self.SetHoldings("SPY", 1)
                self.Debug("Buy In Nov " + str(self.Time.year))