Overall Statistics
Total Orders
4
Average Win
1.81%
Average Loss
0%
Compounding Annual Return
-15.030%
Drawdown
12.100%
Expectancy
-0.5
Start Equity
100000
End Equity
96035
Net Profit
-3.965%
Sharpe Ratio
-0.805
Sortino Ratio
-1.246
Probabilistic Sharpe Ratio
15.872%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0
Alpha
-0.024
Beta
-1.197
Annual Standard Deviation
0.141
Annual Variance
0.02
Information Ratio
-1.037
Tracking Error
0.182
Treynor Ratio
0.095
Total Fees
$2.00
Estimated Strategy Capacity
$360000.00
Lowest Capacity Asset
GOOCV VP83T1ZUHROL
Portfolio Turnover
1.00%
# 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]

        short_straddle = OptionStrategies.short_straddle(self.symbol, contracts[0].strike, expiry)
        self.buy(short_straddle, 1)