Overall Statistics |
Total Orders 4 Average Win 0% Average Loss 0% Compounding Annual Return -8.130% Drawdown 0.700% Expectancy 0 Start Equity 100000 End Equity 99521 Net Profit -0.479% Sharpe Ratio -3.379 Sortino Ratio -3.833 Probabilistic Sharpe Ratio 12.854% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.071 Beta 0.032 Annual Standard Deviation 0.022 Annual Variance 0 Information Ratio -0.004 Tracking Error 0.06 Treynor Ratio -2.304 Total Fees $4.00 Estimated Strategy Capacity $180000.00 Lowest Capacity Asset GOOCV WJVVYXAVCD6U|GOOCV VP83T1ZUHROL Portfolio Turnover 0.13% |
# region imports from AlgorithmImports import * # endregion class LongButteflyOptionStrategy(QCAlgorithm): def initialize(self): self.set_start_date(2017, 4, 1) self.set_end_date(2017, 4, 23) self.set_cash(100000) option = self.add_option("GOOG", Resolution.MINUTE) self._symbol = option.symbol # set our strike/expiry filter for this option chain option.set_filter(lambda x: x.strikes(-5, +5).expiration(timedelta(0), timedelta(30))) def on_data(self, slice): if self.portfolio.invested: return # Get the OptionChain chain = slice.option_chains.get(self._symbol, None) if not chain: return # Select expiry expiry = max([x.expiry for x in chain]) # Separate the call and put contracts calls = [i for i in chain if i.right == OptionRight.CALL and i.expiry == expiry] puts = [i for i in chain if i.right == OptionRight.PUT and i.expiry == expiry] if not calls or not puts: return # Get the ATM and OTM strike prices atm_strike = sorted(calls, key = lambda x: abs(x.strike - chain.underlying.price))[0].strike otm_put_strike = min([x.strike for x in puts]) otm_call_strike = 2 * atm_strike - otm_put_strike iron_butterfly = OptionStrategies.iron_butterfly(self._symbol, otm_put_strike, atm_strike, otm_call_strike, expiry) self.buy(iron_butterfly, 1)