Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-27.901%
Drawdown
2.000%
Expectancy
0
Start Equity
100000
End Equity
98164.8
Net Profit
-1.835%
Sharpe Ratio
-3.669
Sortino Ratio
-2.411
Probabilistic Sharpe Ratio
0.220%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.222
Beta
-0.01
Annual Standard Deviation
0.06
Annual Variance
0.004
Information Ratio
-1.77
Tracking Error
0.084
Treynor Ratio
23.209
Total Fees
$5.20
Estimated Strategy Capacity
$3100000.00
Lowest Capacity Asset
GOOCV 30JDODNXWB9VQ|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.65%
# 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.include_weeklys().iron_condor(30, 5, 10))

    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) < 2 or len(put_contracts) < 2:
            return

        # Select the strategy legs
        near_call = call_contracts[0]
        far_call = call_contracts[1]
        near_put = put_contracts[1]
        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)