Overall Statistics |
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 6.010% Drawdown 0.200% Expectancy 0 Net Profit 0.492% Sharpe Ratio 6.48 Probabilistic Sharpe Ratio 98.518% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.006 Beta 0.098 Annual Standard Deviation 0.008 Annual Variance 0 Information Ratio -8.051 Tracking Error 0.053 Treynor Ratio 0.536 Total Fees $2.00 Estimated Strategy Capacity $170000000.00 Lowest Capacity Asset GOOCV 30HNN7PDAXNLY|GOOCV VP83T1ZUHROL |
from AlgorithmImports import * class BullPutSpreadStrategy(QCAlgorithm): def Initialize(self) -> None: self.SetStartDate(2017, 2, 1) self.SetEndDate(2017, 3, 5) self.SetCash(500000) option = self.AddOption("GOOG", Resolution.Minute) self.symbol = option.Symbol option.SetFilter(self.UniverseFunc) def UniverseFunc(self, universe: OptionFilterUniverse) -> OptionFilterUniverse: return universe.IncludeWeeklys().Strikes(-15, 15).Expiration(timedelta(0), timedelta(31)) def OnData(self, slice: Slice) -> None: if self.Portfolio.Invested: return # Get the OptionChain chain = slice.OptionChains.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.BullPutSpread(self.symbol, itm_strike, otm_strike, expiry) self.Buy(option_strategy, 1)