| Overall Statistics |
|
Total Orders 4 Average Win 0% Average Loss 0% Compounding Annual Return -13.460% Drawdown 1.000% Expectancy 0 Start Equity 100000 End Equity 99184.8 Net Profit -0.815% Sharpe Ratio -3.479 Sortino Ratio -2.86 Probabilistic Sharpe Ratio 6.453% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.115 Beta -0.038 Annual Standard Deviation 0.032 Annual Variance 0.001 Information Ratio -0.578 Tracking Error 0.068 Treynor Ratio 2.943 Total Fees $5.20 Estimated Strategy Capacity $29000.00 Lowest Capacity Asset GOOCV WJVVXYXTEWYU|GOOCV VP83T1ZUHROL Portfolio Turnover 0.19% |
# region imports
from AlgorithmImports import *
# endregion
class LongIronCondorOptionStrategy(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 or not self.is_market_open(self._symbol):
return
chain = slice.option_chains.get(self._symbol)
if not chain:
return
# Find put and call contracts with the farthest expiry
expiry = max([x.expiry for x in chain])
chain = sorted([x for x in chain if x.expiry == expiry], key = lambda x: x.strike)
put_contracts = [x for x in chain if x.right == OptionRight.PUT]
call_contracts = [x for x in chain if x.right == OptionRight.CALL]
if len(call_contracts) < 3 or len(put_contracts) < 3:
return
# Select the strategy legs
near_call = call_contracts[-3]
far_call = call_contracts[-1]
near_put = put_contracts[2]
far_put = [x for x in put_contracts if x.Strike == near_put.strike - far_call.strike + near_call.strike][0]
iron_condor = OptionStrategies.iron_condor(
self._symbol,
far_put.strike,
near_put.strike,
near_call.strike,
far_call.strike,
expiry)
self.buy(iron_condor, 2)