Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
6.361%
Drawdown
0.600%
Expectancy
0
Start Equity
100000
End Equity
100485.5
Net Profit
0.486%
Sharpe Ratio
1.073
Sortino Ratio
1.026
Probabilistic Sharpe Ratio
75.361%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.005
Beta
-0.104
Annual Standard Deviation
0.025
Annual Variance
0.001
Information Ratio
1.681
Tracking Error
0.138
Treynor Ratio
-0.257
Total Fees
$2.00
Estimated Strategy Capacity
$5100000.00
Lowest Capacity Asset
GOOCV Y6URRG5V0U06|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.03%
# region imports
from AlgorithmImports import *
# endregion

class HyperActiveOrangeHippopotamus(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2023, 2, 3)
        self.set_end_date(2023, 3, 3)
        self.set_cash(100000)
        option = self.add_option("GOOG", Resolution.MINUTE)
        self.symbol = option.symbol
        option.set_filter(lambda universe: universe.strikes(-10, 10).expiration(30, 45))

        self.itm_call = None
        self.otm_call = None

    def on_data(self, data: Slice):
        # Get the OptionChain
        chain = data.option_chains.get(self.symbol, None)
        if not chain: return

        if self.itm_call is None:
            # Get the furthest expiry date of the contracts
            expiry = sorted(chain, key = lambda x: x.expiry, reverse=True)[0].expiry
            # Select the ITM call with the lowest strike
            itm_calls = [c for c in chain if c.expiry == expiry and c.right == OptionRight.CALL and c.strike < chain.underlying.price]
            if len(itm_calls) == 0: return
            self.itm_call = sorted(itm_calls, key=lambda x: x.strike)[0]
            # Sell an ITM call
            self.market_order(self.itm_call.symbol, -1)
        
        if self.otm_call is None and self.time.day > 13:
            # Select the OTM call with the highest strike
            otm_calls = [c for c in chain if c.expiry == self.itm_call.expiry and c.right == OptionRight.CALL and c.strike > chain.underlying.price and c.strike > self.itm_call.strike]
            if len(otm_calls) == 0: return
            self.otm_call = sorted(otm_calls, key=lambda x: x.strike)[-1]
            # Buy an OTM call
            self.market_order(self.otm_call.symbol, 1)