Introduction
Long volatility means that the value of your portfolio increases when the volatility goes up. Short volatility means that you make money when the volatility goes down. The simplest example of volatility selling involves the sale of put and call contracts. Traders often long volatility by holding the long position of put or call Options for hedging purpose. In contrast, the short volatility strategy expects to earn the systematic risk premium by selling Options. This algorithm will explore the risk premium effect in volatility selling.
Method
This short volatility algorithm first prescreens the Option contracts by the expiry and the strike. To include the weekly contract, we use the universe function.
def initialize(self):
option = self.add_option("GOOG", Resolution.MINUTE)
option.set_filter(self.universe_func)
def universe_func(self, universe):
return universe.include_weeklys().strikes(-20, 20).expiration(timedelta(0), timedelta(31))
The algorithm selects contracts with one month until maturity so we choose a small range for expiration.
In OnData(), we divide the OptionChain into put and call Options. Then we select the closest expiration date.
The algorithm needs three Option contracts with one month to the maturity: one ATM call, one ATM put to contruct the ATM straddle,
one 15% OTM put. As it's difficult to find the contract with the specified days to maturity and strikes,
we use sorted
to find the most closest contract.
# Get the nearest expiration date of the contracts
expiry = sorted(chain, key = lambda x: x.expiry)[0].expiry
# Select the call Option contracts
puts = [i for i in chain if i.expiry == expiry and i.right == OptionRight.PUT]
if len(puts) == 0: return
# Select the ATM strike price from the remaining contracts
underlying_price = chain.underlying.price
atm_strikes = sorted([x.strike for x in puts], key=lambda x: abs(x - underlying_price))[0]
From the above expiration date and strike price, we pick three Option contracts. We can use OptionStrategies.STRADDLE
to order the multi-leg positions.
option_strategy = OptionStrategies.straddle(self.symbol, atm_strikes, expiry)
# Select 15% OTM put
otm_put = sorted(puts, key=lambda x: abs(x.strike - 0.85*underlying_price))[0]
self.buy(option_strategy, 1)
self.sell(otm_put.symbol, 1)
In trading, we sell the ATM straddle by selling one ATM call and one ATM put. Then we buy an OTM put Option as insurance against a market crash. Then we wait until the expiration and sell the underlying positions after Option exercise and assignment. The portfolio is rebalanced once a month.
Derek Melchin
See the attached backtest for an updated version of the algorithm in PEP8 style.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jing Wu
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!