Hello QC community,
i took the code from the long straddles but I have to use straddles that are delta neutral… Does somebody know how to do this? Either you try to match the different contents in the chain to give delta zero or you just check the delta and try to add from the other one as much as it needs to give zero. But because you cant buy 1.112 options I really dont know how to do this.
def TradeOptions(self,chains):
if chains is None: return
expiry = sorted(chains,key = lambda x: x.Expiry, reverse=False)[0].Expiry
# filter the call and put contract
call = [i for i in chains if i.Expiry == expiry and i.Right == OptionRight.Call]
put = [i for i in chains if i.Expiry == expiry and i.Right == OptionRight.Put]
# sorted the contracts according to their strike prices
call_contracts = sorted(call,key = lambda x: x.Strike)
if len(call_contracts) == 0: return
self.call = call_contracts[0]
for i in put:
if i.Strike == self.call.Strike:
self.put = i
self.Buy(self.call.Symbol, 1)
self.Buy(self.put.Symbol ,1)
Thanks in advance!
Derek Melchin
Hi Nico,
To make the overall position delta-neutral, supplement the position with long or short holdings in the underlying asset.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Nico Xenox
Hey Derek Melchin,
thank you for responding.
So Delta tends to increase as we get closer to expiration for  at-the-money options. How much is that and on what timeframe?
I'm asking that because I construct straddles with a filter of 30, 63 days and an atm strike price. Also I'm trading them for a max of 30 days before an earnings announcement. Is it enough for this timeframe to hedge them one time or does this need to happen every day?
Is it enough and the delta will not move more than lets say 0.05 for this timeframe then I simply could setholdings after buying the options. But if that isnt the case and the Delta moves beyond that or even more I will have to adjust it each day…
In short:
Â
The problem is that I cant access the Delta. I checked the documentation and the way Greeks are saved is: OptionChains > Symbol > Contracts > Values > Greeks > Delta.
I'm not sure how to access the Delta, I also tried using self.Portfolio[symbol] but htat didnt work.
What am I doing wrong?
Nico Xenox
So I think I was able to access the delta but I have one more question. Is this done the right way? Also you mentioned holdings, should I use that instead of a market order and what about the quantity?Â
Thanks in advance!
Nico Xenox
SO I'm still asking myself if this is right. I changed a few things but by using set holdings and a lot of symbols I get errors that I dont have enough money. How should I change this to make it work?
Derek Melchin
Hi Nico,
Instead of adjusting the hedge on a set schedule, it's common to just set a threshold delta value that's acceptable. When the threshold is breached, increase/decrease the underlying position to make the overall position delta-neutral again.
We should use manual orders instead of using the SetHoldings method since the net delta of the overall position tells us the exact number of shares to buy/sell.Â
See the attached backtest for reference.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Nico Xenox
Thank you Derek Melchin, this will help me tremendously!Â
Im currently not at home so I can’t backtest this. I looked for this hedging method on the internet and I didn’t found a RULE to follow. Could you provide me the theory behind this or lead me to the right direction?Â
Thanks in advance!
Â
Â
Nico Xenox
Hey Derek Melchin, I implemented your example in my own code. I changed a few things because I had different symbols.
I added a picture of the results:
Do these results look right? I'm asking because normally positive results would be connected to buying randomly a lot of shares. Btw AAPL indicator is the only one that gets updated at least daily. Also if it does delta-hedging why does the net_delta value not change when trying the same approach but commenting the market order.
Buy-Sell(hedge):
Â
No buying or selling:
Newoptionz
So Nico Xenox are u trying to implement stratergies as described atÂ
Nico Xenox
Hey Derek Melchin and Newoptionz,
I understand it the following way: the objective is to bring delta down to a minimum. For that we have to meassure delta of the used options:
to make it easier we multiply that by the option multiplier. Then we add the underlying delta, which is the stock. Every stock has a delta of 1 thats why we can just use the quantity. At the end we check if the addition is bigger then a threshold.Â
Also shouldn't the quantity be like this (negative)?
positive q:
negative q:
didnt finish the backtestÂ
As you can see the values in the negative quantity are between -100 and 100 while the other one is between -2k and 1k.
I'm asking because if I let the quantity be positive it always has Insufficient buying power to complete orders.
Derek Melchin
Hi Nico,
The order quantity should be -1 * the net delta.
Refer to the attached backtest above.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Nico Xenox
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!