Created with Highcharts 12.1.2Equity201020112012201320142015201620172018201920202021202220232024202520268k10k12k14k16k18k20k22k24k
Overall Statistics
Total Orders
233
Average Win
2.21%
Average Loss
-1.56%
Compounding Annual Return
4.853%
Drawdown
15.100%
Expectancy
0.459
Start Equity
10000
End Equity
20531.55
Net Profit
105.316%
Sharpe Ratio
0.271
Sortino Ratio
0.177
Probabilistic Sharpe Ratio
1.710%
Loss Rate
40%
Win Rate
60%
Profit-Loss Ratio
1.42
Alpha
-0.002
Beta
0.246
Annual Standard Deviation
0.064
Annual Variance
0.004
Information Ratio
-0.546
Tracking Error
0.112
Treynor Ratio
0.07
Total Fees
$233.00
Estimated Strategy Capacity
$1100000.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)