Overall Statistics
Total Orders
3
Average Win
0%
Average Loss
0%
Compounding Annual Return
-8.407%
Drawdown
0.700%
Expectancy
0
Start Equity
100000
End Equity
99504
Net Profit
-0.496%
Sharpe Ratio
-2.807
Sortino Ratio
-2.191
Probabilistic Sharpe Ratio
12.949%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.063
Beta
0.172
Annual Standard Deviation
0.027
Annual Variance
0.001
Information Ratio
-0.04
Tracking Error
0.054
Treynor Ratio
-0.438
Total Fees
$3.00
Estimated Strategy Capacity
$87000000.00
Lowest Capacity Asset
GOOCV 30JDODO6600CM|GOOCV VP83T1ZUHROL
Portfolio Turnover
4.19%
# region imports
from AlgorithmImports import *
# endregion

class ConversionOptionStrategy(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2017, 4, 1)
        self.set_end_date(2017, 4, 23)
        self.set_cash(100000)
        
        equity = self.add_equity("GOOG", Resolution.MINUTE)
        option = self.add_option("GOOG", Resolution.MINUTE)
        self.symbol = option.symbol

        # set our strike/expiry filter for this option chain
        option.set_filter(lambda universe: universe.include_weeklys().conversion(30, -5))

    def on_data(self, data):
        # avoid extra orders
        if self.portfolio.invested: return

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

        # choose the furthest expiration date within 30 days from now on
        expiry = sorted(chain, key = lambda x: x.expiry)[-1].expiry
        
        # select ATM strike price
        strike = sorted(chain, key = lambda x: abs(x.Strike - chain.underlying.price))[0].strike

        # Order Strategy
        conversion = OptionStrategies.conversion(self.symbol, strike, expiry)
        self.buy(conversion, 1)

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