Overall Statistics
Total Trades
4
Average Win
0%
Average Loss
-0.92%
Compounding Annual Return
96.758%
Drawdown
1.300%
Expectancy
-1
Net Profit
5.264%
Sharpe Ratio
5.383
Probabilistic Sharpe Ratio
96.479%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.582
Beta
0.426
Annual Standard Deviation
0.116
Annual Variance
0.013
Information Ratio
4.437
Tracking Error
0.118
Treynor Ratio
1.465
Total Fees
$2.00
Estimated Strategy Capacity
$2800000.00
Lowest Capacity Asset
GOOCV WJVVXYW5VKH2|GOOCV VP83T1ZUHROL
# region imports
from AlgorithmImports import *
# endregion

class SmoothBlackKangaroo(QCAlgorithm):

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

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

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

        # Select an expiration date
        expiry = sorted(chain, key=lambda contract: contract.Expiry, reverse=True)[0].Expiry

        # Select the OTM call strike
        strikes = [contract.Strike for contract in chain if contract.Expiry == expiry]
        call_strikes = [contract.Strike for contract in chain 
            if contract.Expiry == expiry 
            and contract.Right == OptionRight.Call
            and contract.Strike > chain.Underlying.Price]
        if len(call_strikes) == 0: return
        call_strike = min(call_strikes)

        # Select the OTM put strike
        put_strikes = [contract.Strike for contract in chain 
            if contract.Expiry == expiry 
            and contract.Right == OptionRight.Put
            and contract.Strike < chain.Underlying.Price]
        if len(put_strikes) == 0: return
        put_strike = max(put_strikes)

        option_strategy = OptionStrategies.Strangle(self.symbol, call_strike, put_strike, expiry)
        self.Buy(option_strategy, 1)