Overall Statistics
Total Trades
4
Average Win
0%
Average Loss
-2.34%
Compounding Annual Return
11.544%
Drawdown
7.200%
Expectancy
-0.5
Net Profit
2.751%
Sharpe Ratio
0.721
Probabilistic Sharpe Ratio
42.918%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0
Alpha
-0.008
Beta
1.053
Annual Standard Deviation
0.12
Annual Variance
0.014
Information Ratio
-0.037
Tracking Error
0.101
Treynor Ratio
0.082
Total Fees
$2.00
Estimated Strategy Capacity
$4000.00
Lowest Capacity Asset
GOOCV VP83T1ZUHROL
Portfolio Turnover
0.92%
# region imports
from AlgorithmImports import *
# endregion

class LongStraddleAlgorithm(QCAlgorithm):

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

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

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

        # Find ATM options with the nearest expiry
        expiry = min([x.Expiry for x in chain])
        contracts = sorted([x for x in chain if x.Expiry == expiry],
            key=lambda x: abs(chain.Underlying.Price - x.Strike))
        
        if len(contracts) < 2:
            return

        # The first two contracts are the ATM Call and the ATM Put
        contracts = contracts[0:2]

        long_straddle = OptionStrategies.Straddle(self.symbol, contracts[0].Strike, expiry)
        self.Buy(long_straddle, 1)