Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-10.609%
Drawdown
1.000%
Expectancy
0
Start Equity
100000
End Equity
99153.5
Net Profit
-0.846%
Sharpe Ratio
-3.086
Sortino Ratio
-1.768
Probabilistic Sharpe Ratio
2.165%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.095
Beta
0.054
Annual Standard Deviation
0.029
Annual Variance
0.001
Information Ratio
-2.631
Tracking Error
0.066
Treynor Ratio
-1.693
Total Fees
$4.00
Estimated Strategy Capacity
$8100000.00
Lowest Capacity Asset
GOOCV 30JDODO6600CM|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.29%
# region imports
from AlgorithmImports import *
# endregion

class ProtectiveCollarOptionStrategy(QCAlgorithm):

    def initialize(self):
        self.SetStartDate(2017, 4, 1)
        self.SetEndDate(2017, 4, 30)
        self.SetCash(100000)

        self.UniverseSettings.Asynchronous = True
        self.equity_symbol = self.AddEquity("GOOG").Symbol

        option = self.AddOption("GOOG", Resolution.Minute)
        self.option_symbol = option.Symbol
        option.set_filter(lambda universe: universe.include_weeklys().box_spread(30, 5))

        self.invest_ever = False

    def on_data(self, slice: Slice):
        if self.invest_ever: return

        # Get the OptionChain
        chain = slice.option_chains.get(self.option_symbol, None)
        if not chain: return

        # Select an expiry date
        expiry = sorted(chain, key = lambda x: x.expiry)[-1].expiry

        # Select the strike prices of the contracts
        ordered_contracts = sorted(chain, key = lambda x: x.strike)
        higher_strike = ordered_contracts[-1].strike
        lower_strike = ordered_contracts[0].strike

        box_spread = OptionStrategies.short_box_spread(self.option_symbol, higher_strike, lower_strike, expiry)
        self.buy(box_spread, 1)

        self.invest_ever = True

    def on_end_of_day(self, symbol):
        if symbol == self.equity_symbol:
            self.Log(f"{self.time}::{symbol}::{self.securities[symbol].price}")