Overall Statistics
Total Orders
3
Average Win
0%
Average Loss
0%
Compounding Annual Return
-7.673%
Drawdown
0.600%
Expectancy
0
Start Equity
100000
End Equity
99549
Net Profit
-0.451%
Sharpe Ratio
-4.106
Sortino Ratio
-4.934
Probabilistic Sharpe Ratio
9.844%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.079
Beta
-0.115
Annual Standard Deviation
0.017
Annual Variance
0
Information Ratio
0.046
Tracking Error
0.066
Treynor Ratio
0.611
Total Fees
$3.00
Estimated Strategy Capacity
$12000000.00
Lowest Capacity Asset
GOOCV 30JDODO6600CM|GOOCV VP83T1ZUHROL
Portfolio Turnover
4.17%
# region imports
from AlgorithmImports import *
# endregion

class ReverseConversionOptionStrategy(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
        reverse_conversion = OptionStrategies.reverse_conversion(self.symbol, strike, expiry)
        self.buy(reverse_conversion, 1)

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