Overall Statistics
Total Trades
4
Average Win
0.77%
Average Loss
0%
Compounding Annual Return
-52.972%
Drawdown
7.500%
Expectancy
-0.5
Net Profit
-5.558%
Sharpe Ratio
-3.45
Probabilistic Sharpe Ratio
0.053%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0
Alpha
-0.37
Beta
-0.397
Annual Standard Deviation
0.119
Annual Variance
0.014
Information Ratio
-3.491
Tracking Error
0.146
Treynor Ratio
1.033
Total Fees
$2.00
Estimated Strategy Capacity
$250000.00
Lowest Capacity Asset
GOOCV WJVVXYW5VKH2|GOOCV VP83T1ZUHROL
Portfolio Turnover
3.02%
# region imports
from AlgorithmImports import *
# endregion

class ShortStrangleAlgorithm(QCAlgorithm):

    def Initialize(self) -> None:
        self.SetStartDate(2017, 4, 1)
        self.SetEndDate(2017, 4, 30)
        self.SetCash(100000)
        
        option = self.AddOption("GOOG")
        self.symbol = option.Symbol
        option.SetFilter(-5, 5, 0, 30)

    def OnData(self, slice: Slice) -> None:
        if self.Portfolio.Invested:
            return

        # Get the OptionChain
        chain = slice.OptionChains.get(self.symbol)
        if not chain:
            return

        # Find options with the nearest expiry
        expiry = max([x.Expiry for x in chain])
        contracts = [contract for contract in chain if contract.Expiry == expiry]
     
        # Order the OTM calls by strike to find the nearest to ATM
        call_contracts = sorted([contract for contract in contracts
            if contract.Right == OptionRight.Call and
               contract.Strike > chain.Underlying.Price],
            key=lambda x: x.Strike)
        if not call_contracts:
            return
        
        # Order the OTM puts by strike to find the nearest to ATM
        put_contracts = sorted([contract for contract in contracts
            if contract.Right == OptionRight.Put and
               contract.Strike < chain.Underlying.Price],
            key=lambda x: x.Strike, reverse=True)
        if not put_contracts:
            return

        call_strike = call_contracts[0].Strike
        put_strike = put_contracts[0].Strike

        short_strangle = OptionStrategies.ShortStrangle(self.symbol, call_strike, put_strike, expiry)
        self.Buy(short_strangle, 1)