Overall Statistics |
Total Trades 4 Average Win 0.71% Average Loss -0.11% Compounding Annual Return 5.002% Drawdown 0.200% Expectancy 2.618 Net Profit 0.451% Sharpe Ratio 5.624 Probabilistic Sharpe Ratio 97.411% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 6.24 Alpha 0.005 Beta 0.099 Annual Standard Deviation 0.008 Annual Variance 0 Information Ratio -6.764 Tracking Error 0.052 Treynor Ratio 0.45 Total Fees $2.00 Estimated Strategy Capacity $140000000.00 Lowest Capacity Asset GOOCV 30HNN6TY3EEZQ|GOOCV VP83T1ZUHROL |
from AlgorithmImports import * class BullPutSpreadStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 2, 1) self.SetEndDate(2017, 3, 6) self.SetCash(500000) option = self.AddOption("GOOG", Resolution.Minute) self.symbol = option.Symbol option.SetFilter(self.UniverseFunc) def UniverseFunc(self, universe): return universe.IncludeWeeklys().Strikes(-15, 15).Expiration(timedelta(0), timedelta(31)) def OnData(self, data): # avoid extra orders if self.Portfolio.Invested: return # Get the OptionChain of the self.symbol chain = data.OptionChains.get(self.symbol, None) if not chain: return # sorted the optionchain by expiration date and choose the furthest date expiry = sorted(chain, key = lambda x: x.Expiry, reverse=True)[0].Expiry # filter the put options from the contracts which expire on the furthest expiration date in the option chain. puts = [i for i in chain if i.Expiry == expiry and i.Right == OptionRight.Put] if len(puts) == 0: return # sort the put options with the same expiration date according to their strike price. put_strikes = sorted([x.Strike for x in puts]) # select the strike prices for forming the option legs # the ITM put option with the lowest strike price (short) and the OTM put with the highest strike price (long). otm_strike = put_strikes[0] itm_strike = put_strikes[-1] option_strategy = OptionStrategies.BullPutSpread(self.symbol, itm_strike, otm_strike, expiry) # We open a position with 1 unit of the option strategy self.Buy(option_strategy, 1)