Overall Statistics |
Total Orders 5 Average Win 0.28% Average Loss -0.60% Compounding Annual Return 142.977% Drawdown 1.000% Expectancy -0.262 Start Equity 100000 End Equity 106961 Net Profit 6.961% Sharpe Ratio 7.651 Sortino Ratio 101.94 Probabilistic Sharpe Ratio 99.949% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 0.48 Alpha 0.812 Beta 0.7 Annual Standard Deviation 0.114 Annual Variance 0.013 Information Ratio 7.382 Tracking Error 0.107 Treynor Ratio 1.243 Total Fees $3.00 Estimated Strategy Capacity $45000.00 Lowest Capacity Asset GOOCV WJVVXYXTEWYU|GOOCV VP83T1ZUHROL Portfolio Turnover 3.01% |
# region imports from AlgorithmImports import * # endregion class ProtectiveCollarOptionStrategy(QCAlgorithm): def initialize(self): self.set_start_date(2017, 4, 1) self.set_end_date(2017, 4, 30) self.set_cash(100000) equity = self.add_equity("GOOG", Resolution.MINUTE) option = self.add_option("GOOG", Resolution.MINUTE) self.symbol = option.symbol # set our strike/expiry filter for this option chain option.set_filter(-5, +5, timedelta(0), timedelta(30)) def on_data(self, data): # avoid extra orders if self.portfolio.invested: return # Get the OptionChain of the self.symbol chain = data.option_chains.get(self.symbol, None) if not chain: return # choose the furthest expiration date within 30 days from now on expiry = sorted(chain, key = lambda x: x.expiry)[-1].expiry # filter the call options contracts call = [x for x in chain if x.right == OptionRight.CALL and x.expiry == expiry] # filter the put options contracts put = [x for x in chain if x.right == OptionRight.PUT and x.expiry == expiry] if not call or not put: return self.otm_call = sorted(call, key = lambda x: x.strike)[-1] self.otm_put = sorted(put, key = lambda x: x.strike)[0] self.sell(self.otm_call.symbol, 1) # sell the OTM call self.buy(self.otm_put.symbol, 1) # buy the OTM put self.buy("GOOG",100) # buy 100 shares of the underlying stock