| Overall Statistics |
|
Total Trades 94 Average Win 1.62% Average Loss 0% Compounding Annual Return -33.403% Drawdown 25.700% Expectancy 0 Net Profit -18.223% Sharpe Ratio -1.102 Probabilistic Sharpe Ratio 2.348% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha -0.17 Beta 0.235 Annual Standard Deviation 0.208 Annual Variance 0.043 Information Ratio 0.089 Tracking Error 0.258 Treynor Ratio -0.973 Total Fees $0.00 Estimated Strategy Capacity $170000.00 Lowest Capacity Asset SPXW 31Y4A5PK3G3YM|SPX 31 Portfolio Turnover 0.63% |
# region imports
from AlgorithmImports import *
# endregion
class SmoothBlackKangaroo(QCAlgorithm):
def Initialize(self) -> None:
self.SetStartDate(2022, 1, 1)
self.SetEndDate(2022, 3, 30)
self.SetCash(1000000)
self.underlying = self.AddIndex("SPX", Resolution.Minute, fillForward=False)
options = self.AddIndexOption(self.underlying.Symbol, "SPXW", Resolution.Minute)
options.SetFilter(lambda u: u.IncludeWeeklys().Strikes(-1, 1).Expiration(6, 8))
self.symbol = options.Symbol
self.leverage = 2
self.Securities[self.symbol].SetBuyingPowerModel(NullBuyingPowerModel()) # Ignore buying power restrictions
def OnData(self, slice: Slice) -> None:
# Only on Fridays at 3:30pm
if slice.Time.weekday() == 4 and slice.Time.hour == 15 and slice.Time.minute == 30:
#if self.underlying.Symbol in slice.Bars:
#trade_bar = slice.Bars[self.underlying.Symbol]
#value = trade_bar.Value
# Get the OptionChain
chain = slice.OptionChains.get(self.symbol.Canonical)
if not chain:
return
# Select an expiration date
expiry = sorted(chain, key=lambda contract: contract.Expiry, reverse=True)[0].Expiry
# Select the ATM strike price
sorted_options = sorted(chain, key=lambda contract: abs(contract.Greeks.Delta - 0.5))
strike = sorted_options[0].Strike
quantity = int(self.Portfolio.TotalPortfolioValue*self.leverage/strike/100)
option_strategy = OptionStrategies.Straddle(self.symbol, strike, expiry)
self.Sell(option_strategy, quantity)