Overall Statistics
Total Trades
44
Average Win
2.32%
Average Loss
-1.87%
Compounding Annual Return
0.362%
Drawdown
7.500%
Expectancy
0.222
Net Profit
8.651%
Sharpe Ratio
0.12
Probabilistic Sharpe Ratio
0.000%
Loss Rate
45%
Win Rate
55%
Profit-Loss Ratio
1.24
Alpha
0.001
Beta
0.02
Annual Standard Deviation
0.023
Annual Variance
0.001
Information Ratio
-0.406
Tracking Error
0.158
Treynor Ratio
0.137
Total Fees
$78.46
Estimated Strategy Capacity
$410000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
from datetime import datetime,timedelta


class ScheduledEventsAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(1999, 1, 1)  # Set Start Date
        self.SetEndDate(2021, 12, 6) # Set end date
        self.SetCash(50000)  # Set Strategy Cash
        self.symbol="SPY"
        self.spy = self.AddEquity(self.symbol, Resolution.Daily)
        self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
        self.SetWarmUp(timedelta(7))
        self.x=2
      
    
    def OnData(self, data):
        if self.IsWarmingUp:
                return
             
        if self.Time.month==1 and self.Time.day>4:
             self.Liquidate()

        if not self.Portfolio.Invested and self.Time.month==12 and self.Time.day>25:
            self.SetHoldings(self.symbol, 1)