Overall Statistics |
Total Orders 2 Average Win 0% Average Loss 0% Compounding Annual Return 0.782% Drawdown 0.100% Expectancy 0 Start Equity 500000 End Equity 500327.5 Net Profit 0.066% Sharpe Ratio -3.007 Sortino Ratio -22.729 Probabilistic Sharpe Ratio 100.0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.004 Beta 0.002 Annual Standard Deviation 0.001 Annual Variance 0 Information Ratio -8.052 Tracking Error 0.058 Treynor Ratio -1.114 Total Fees $2.00 Estimated Strategy Capacity $2500000.00 Lowest Capacity Asset GOOCV 30HNN6TRH910M|GOOCV VP83T1ZUHROL Portfolio Turnover 0.02% |
from AlgorithmImports import * class BullPutSpreadStrategy(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2017, 2, 1) self.set_end_date(2017, 3, 5) self.set_cash(500000) option = self.add_option("GOOG", Resolution.MINUTE) self.symbol = option.symbol option.set_filter(self.universe_func) def universe_func(self, universe: OptionFilterUniverse) -> OptionFilterUniverse: return universe.include_weeklys().put_spread(30, 5) def on_data(self, slice: Slice) -> None: if self.portfolio.invested: return # Get the OptionChain chain = slice.option_chains.get(self.symbol, None) if not chain: return # Get the furthest expiration date of the contracts expiry = sorted(chain, key = lambda x: x.expiry, reverse=True)[0].expiry # Select the put Option contracts with the furthest expiry puts = [i for i in chain if i.expiry == expiry and i.right == OptionRight.PUT] if len(puts) == 0: return # Select the ITM and OTM contract strikes from the remaining contracts put_strikes = sorted([x.strike for x in puts]) otm_strike = put_strikes[0] itm_strike = put_strikes[-1] option_strategy = OptionStrategies.bull_put_spread(self.symbol, itm_strike, otm_strike, expiry) self.buy(option_strategy, 1)