Overall Statistics
Total Orders
229
Average Win
2.19%
Average Loss
-1.51%
Compounding Annual Return
4.933%
Drawdown
15.200%
Expectancy
0.483
Start Equity
10000
End Equity
20523.35
Net Profit
105.234%
Sharpe Ratio
0.291
Sortino Ratio
0.191
Probabilistic Sharpe Ratio
1.969%
Loss Rate
39%
Win Rate
61%
Profit-Loss Ratio
1.45
Alpha
-0.001
Beta
0.245
Annual Standard Deviation
0.064
Annual Variance
0.004
Information Ratio
-0.555
Tracking Error
0.112
Treynor Ratio
0.076
Total Fees
$229.00
Estimated Strategy Capacity
$710000.00
Lowest Capacity Asset
OEF RZ8CR0XXNOF9
Portfolio Turnover
3.98%
# https://quantpedia.com/strategies/option-expiration-week-effect/
#
# Investors choose stocks from the S&P 100 index as his/her investment universe (stocks could be easily tracked via ETF or index fund).
# He/she then goes long S&P 100 stocks during the option-expiration week and stays in cash during other days.

from AlgorithmImports import *

class OptionExpirationWeekEffect(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010, 1, 1)
        self.SetCash(10000)

        self.symbol = self.AddEquity("OEF", Resolution.Minute).Symbol
        
        option = self.AddOption("OEF")
        option.SetFilter(-3, 3, timedelta(0), timedelta(days = 60))       

        self.SetBenchmark("OEF")
        self.near_expiry = datetime.min
        
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday, DayOfWeek.Monday), self.TimeRules.AfterMarketOpen(self.symbol, 1), self.Rebalance)

    def OnData(self, slice):
        if self.Time.date() == self.near_expiry.date():
            self.Liquidate()

    def Rebalance(self):
        calendar = self.TradingCalendar.GetDaysByType(TradingDayType.OptionExpiration, self.Time, self.EndDate)
        expiries = [i.Date for i in calendar]
        if len(expiries) == 0: return

        self.near_expiry = expiries[0]

        if (self.near_expiry - self.Time).days <= 5:
            self.SetHoldings(self.symbol, 1)