Overall Statistics |
Total Orders 272 Average Win 12.73% Average Loss -11.02% Compounding Annual Return -49.502% Drawdown 94.900% Expectancy -0.097 Start Equity 100000 End Equity 5227.4 Net Profit -94.773% Sharpe Ratio -1.46 Sortino Ratio -0.604 Probabilistic Sharpe Ratio 0.000% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 1.16 Alpha -0.393 Beta 0.195 Annual Standard Deviation 0.258 Annual Variance 0.067 Information Ratio -1.554 Tracking Error 0.295 Treynor Ratio -1.928 Total Fees $7334.60 Estimated Strategy Capacity $6000.00 Lowest Capacity Asset QQQ 32GUNU5C4K2JQ|QQQ RIWIV7K5Z9LX Portfolio Turnover 8.45% |
# region imports from AlgorithmImports import * from datetime import timedelta import pandas as pd # endregion class SimpleStraddleBacktest(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 1) self.set_end_date(2024, 6, 1) self.set_cash(100_000) # Setting up asset and equity self._option = self.add_option("QQQ", Resolution.MINUTE) self._symbol = self._option.symbol self._option.set_filter(timedelta(7), timedelta(7)) # Schedule liquidate self.schedule.on(self.date_rules.every_day(self._symbol), self.time_rules.at(9,33), self.liquidate_positions) def on_data(self, data:Slice): # Start the strategy at 3:58 PM if self.time.hour == 15 and self.time.minute == 38: # Find the list of contracts chain = data.option_chains.get(self._symbol) if chain is None: return calls = [x for x in chain if x.right == OptionRight.CALL] puts = [x for x in chain if x.right == OptionRight.PUT] straddles = [[call, put] for call in calls for put in puts if call.strike == put.strike] self.cheapest_straddle = sorted(straddles, key=lambda straddle: straddle[0].last_price + straddle[1].last_price)[0] self.log(f"Cheapest straddle contracts: {self.cheapest_straddle[0].symbol.value, self.cheapest_straddle[1].symbol.value}") # Set leverage self.securities[self.cheapest_straddle[0].symbol].set_leverage(1) self.securities[self.cheapest_straddle[1].symbol].set_leverage(1) if not self.portfolio.invested: # Buying straddle self.set_holdings(self.cheapest_straddle[0].symbol, .5) self.set_holdings(self.cheapest_straddle[1].symbol, .5) def liquidate_positions(self): self.liquidate()