Overall Statistics
Total Orders
4
Average Win
2.03%
Average Loss
0%
Compounding Annual Return
-12.545%
Drawdown
11.400%
Expectancy
-0.5
Start Equity
100000
End Equity
96725
Net Profit
-3.275%
Sharpe Ratio
-0.697
Sortino Ratio
-1.141
Probabilistic Sharpe Ratio
17.618%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0
Alpha
-0.006
Beta
-1.194
Annual Standard Deviation
0.138
Annual Variance
0.019
Information Ratio
-0.954
Tracking Error
0.179
Treynor Ratio
0.08
Total Fees
$2.00
Estimated Strategy Capacity
$9000.00
Lowest Capacity Asset
GOOCV VP83T1ZUHROL
Portfolio Turnover
1.02%
# 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(-1, 1, 30, 60)

    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)