Overall Statistics |
Total Trades 158 Average Win 1.80% Average Loss -5.13% Compounding Annual Return 5.829% Drawdown 32.300% Expectancy 0.033 Net Profit 8.232% Sharpe Ratio 0.295 Probabilistic Sharpe Ratio 15.716% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 0.35 Alpha 0 Beta 0 Annual Standard Deviation 0.238 Annual Variance 0.056 Information Ratio 0.295 Tracking Error 0.238 Treynor Ratio 0 Total Fees $128.00 Estimated Strategy Capacity $0 Lowest Capacity Asset SPY 327TQB8RG3OQU|SPY R735QTJ8XC9X Portfolio Turnover 6.90% |
# weekend effect of the selling options # open - Fri 15:55 # close - Mon 9:45 # delta - 0.5 # 1 contract / account size 100,000 USD import pandas as pd import talib as ta import numpy as np from AlgorithmImports import * class BasicTemplateSPXWeeklyIndexOptionsAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2022,1, 1) #self.SetEndDate(2022, 1, 10) self.SetCash(15000) self.SetTimeZone(TimeZones.NewYork) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage,AccountType.Margin) self.spy = self.AddEquity("SPY", Resolution.Minute) self.SetBenchmark("SPX") # weekly option SPX contracts spyw = self.AddOption("SPY") # set our strike/expiry filter for this option chain spyw.SetFilter(lambda u: (u.Strikes(-1, 1) .Expiration(7,7) .IncludeWeeklys())) self.spyw_option = spyw.Symbol self.Schedule.On(self.DateRules.Every(DayOfWeek.Wednesday), self.TimeRules.At(11, 0), self.Start) self.trade_run = 0 def OnData(self,slice): if self.trade_run == 0: return else: quantity = 1 delta =0.5 self.chain = slice.OptionChains.GetValue(self.spyw_option) if self.chain is None: return put = [x for x in self.chain if x.Right == OptionRight.Put] # we sort the contracts to find contract with the right delta put_contract = sorted(put,key = lambda x: abs(x.Greeks.Delta - delta)) self.Debug(self.trade_run) if len(put_contract) == 0: return else: self.put_ = put_contract[0] self.MarketOrder(self.put_.Symbol, -quantity) self.trade_run = 0 def OnOrderEvent(self, orderEvent): self.Debug(str(orderEvent)) def Start(self): self.Liquidate() self.trade_run = 1