Overall Statistics
Total Orders
227
Average Win
2.19%
Average Loss
-1.51%
Compounding Annual Return
5.070%
Drawdown
15.100%
Expectancy
0.499
Start Equity
10000
End Equity
20847.69
Net Profit
108.477%
Sharpe Ratio
0.309
Sortino Ratio
0.202
Probabilistic Sharpe Ratio
2.308%
Loss Rate
39%
Win Rate
61%
Profit-Loss Ratio
1.45
Alpha
0
Beta
0.246
Annual Standard Deviation
0.064
Annual Variance
0.004
Information Ratio
-0.527
Tracking Error
0.112
Treynor Ratio
0.08
Total Fees
$227.00
Estimated Strategy Capacity
$600000.00
Lowest Capacity Asset
OEF RZ8CR0XXNOF9
Portfolio Turnover
3.96%
# 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)