Overall Statistics
Total Orders
4
Average Win
0%
Average Loss
0%
Compounding Annual Return
-11.143%
Drawdown
1.000%
Expectancy
0
Start Equity
100000
End Equity
99108.5
Net Profit
-0.892%
Sharpe Ratio
-3.838
Sortino Ratio
-2.464
Probabilistic Sharpe Ratio
0.208%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.098
Beta
0.036
Annual Standard Deviation
0.025
Annual Variance
0.001
Information Ratio
-2.728
Tracking Error
0.065
Treynor Ratio
-2.623
Total Fees
$4.00
Estimated Strategy Capacity
$14000000.00
Lowest Capacity Asset
GOOCV 30JDODO6600CM|GOOCV VP83T1ZUHROL
Portfolio Turnover
0.29%
# region imports
from AlgorithmImports import *
# endregion

class BoxSpreadStrategy(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2017, 4, 1)
        self.set_end_date(2017, 4, 30)
        self.set_cash(100000)

        self.universe_settings.asynchronous = True

        option = self.add_option("GOOG", Resolution.MINUTE)
        self._symbol = option.Symbol
        option.set_filter(lambda universe: universe.include_weeklys().box_spread(30, 5))

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

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

        # Select an expiry date
        expiry = max([x.expiry for x in chain])

        # Select the strike prices of the contracts
        contracts = [x for x in chain if x.expiry == expiry]
        higher_strike = max([x.strike for x in contracts])
        lower_strike = min([x.strike for x in contracts])

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

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