Overall Statistics |
Total Orders 19 Average Win 0.47% Average Loss -0.26% Compounding Annual Return 22.234% Drawdown 1.500% Expectancy 1.159 Start Equity 1000000 End Equity 1036994 Net Profit 3.699% Sharpe Ratio 2.168 Sortino Ratio 2.516 Probabilistic Sharpe Ratio 93.507% Loss Rate 22% Win Rate 78% Profit-Loss Ratio 1.78 Alpha 0.097 Beta 0.019 Annual Standard Deviation 0.044 Annual Variance 0.002 Information Ratio 1.668 Tracking Error 0.125 Treynor Ratio 5.075 Total Fees $0.00 Estimated Strategy Capacity $57000.00 Lowest Capacity Asset SPXW 32PHWNBJTPKI6|SPX 31 Portfolio Turnover 0.11% |
# region imports from AlgorithmImports import * # endregion class ZeroDTEIndexOptionUniverseAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2025, 1, 1) self.set_cash(1_000_000) # Add 1DTE SPY contracts. index = self.add_index('SPX') self._option = self.add_index_option(index.symbol, 'SPXW') self._option.set_filter(lambda u: u.include_weeklys().expiration(1, 1).strikes(-3, 3)) # Create a member to track when the algorithm should trade. self._can_trade = False date_rule = self.date_rules.week_end(self._option.symbol, 1) self.schedule.on(date_rule, self.time_rules.at(15, 45), lambda: setattr(self, '_can_trade', True)) self.schedule.on(date_rule, self.time_rules.at(16, 15), lambda: setattr(self, '_can_trade', False)) def on_data(self, data): # Only process data between 3:45 PM and 4:15 PM on Thursdays. if not self._can_trade: return # Get the Option chain. chain = data.option_chains.get(self._option.symbol) if not chain: return # Select a contract (for example, the contract with the greatest open interest). contract = sorted(chain, key=lambda c: c.open_interest)[-1] # Place the trade. self.set_holdings(contract.symbol, -0.25)