Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
-2.29%
Compounding Annual Return
13.038%
Drawdown
7.100%
Expectancy
-0.5
Start Equity
100000
End Equity
103091
Net Profit
3.091%
Sharpe Ratio
0.664
Sortino Ratio
0.632
Probabilistic Sharpe Ratio
44.310%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0
Alpha
0.003
Beta
1.051
Annual Standard Deviation
0.123
Annual Variance
0.015
Information Ratio
0.065
Tracking Error
0.104
Treynor Ratio
0.078
Total Fees
$2.00
Estimated Strategy Capacity
$180000.00
Lowest Capacity Asset
GOOCV VP83T1ZUHROL
Portfolio Turnover
0.92%
# region imports
from AlgorithmImports import *
# endregion

class LongStraddleAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2017, 4, 1)
        self.set_end_date(2017, 6, 30)
        self.set_cash(100000)
        
        option = self.add_option("GOOG")
        self.symbol = option.symbol
        option.set_filter(lambda universe: universe.include_weeklys().straddle(30))

    def on_data(self, slice: Slice) -> None:
        if self.portfolio.invested:
            return

        chain = slice.option_chains.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)