Overall Statistics
Total Orders
51
Average Win
9.88%
Average Loss
-8.57%
Compounding Annual Return
5.782%
Drawdown
36.600%
Expectancy
0.723
Start Equity
100000
End Equity
429750.87
Net Profit
329.751%
Sharpe Ratio
0.213
Sortino Ratio
0.154
Probabilistic Sharpe Ratio
0.014%
Loss Rate
20%
Win Rate
80%
Profit-Loss Ratio
1.15
Alpha
0
Beta
0.503
Annual Standard Deviation
0.112
Annual Variance
0.013
Information Ratio
-0.209
Tracking Error
0.112
Treynor Ratio
0.048
Total Fees
$305.64
Estimated Strategy Capacity
$0
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
0.54%
# https://quantpedia.com/strategies/market-seasonality-effect-in-world-equity-indexes/
#
# Be invested in global equity markets during November – April period, stay in cash during May-October period (alternatively go
# long in stocks from countries from northern hemisphere during winter period and long in stocks from countries from southern hemisphere
# during summer period; alternatively go long in cyclical companies during winter period and short defensive stocks and switch positions
# during the summer period)

from AlgorithmImports import *

class SeasonalityInEquitiesAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(1999, 1, 1)  
        self.set_cash(100000) 

        self.symbol: Symbol = self.add_equity("SPY", Resolution.DAILY).symbol
        
        self.schedule.on(self.date_rules.month_start(self.symbol), self.time_rules.after_market_open(self.symbol), self.rebalance)
        
    def rebalance(self) -> None:
        if self.time.month == 5:
            self.liquidate(self.symbol)
        
        if self.time.month == 11:
            self.set_holdings(self.symbol, 1)