Overall Statistics
Total Orders
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Start Equity
100000
End Equity
100000
Net Profit
0%
Sharpe Ratio
0
Sortino Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-3.713
Tracking Error
0.083
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
Drawdown Recovery
0
from AlgorithmImports import *

class BasicIndexOptionAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2025,8,1)
        self.set_end_date(2025,8,22)
        self.set_cash(100_000)
        # Subscribe to the option chain.
        self._option = self.add_index_option("SPX", "SPXW")
        # Filter the option universe to only select 0DTE options.
        self._option.set_filter(lambda u: u.include_weeklys().expiration(0, 0).strikes(-1, 1))
        # Filter the option universe by Delta. The last set_filter call prevails.
        # self._option.set_filter(lambda option_filter_universe: option_filter_universe.delta(0.25, 0.75))
        self.contract = None

    def on_data(self, slice: Slice) -> None:
        if self.portfolio.invested:
            return
        # Get the option chain data.
        chain = slice.option_chains.get(self._option.symbol)
        if not chain:
            return
        # Sorted the call Option contracts according to their strike prices.
        calls = sorted([contract for contract in chain if contract.right == OptionRight.CALL], key=lambda x: x.strike)
        if not calls:
            return
        
        if self.contract != calls[0].symbol:
            self.contract = calls[0].symbol
            self.debug(f"{str(self.time)} New SPX 0DTE {self.contract}")