Back

Trying to build a synthetic short LETF rebalancing algorithm

Hi, 

I feel somewhat sorry for asking as I'm a true novice at this and yet I'm attempting something difficult here.

I am trying to build an algo that does the following:
- Determine the current price of 2 equities (SPXL en SPXS)
- Use these prices to determine the needed amount of options of both to buy for the portfolio (in a 2:1 ratio)
- Buy Put options on both and sell calls on both

This should end up with a portfolio with a 67% synthetic short in SPXS and 33% in SPXL.

It should rebalance the options whenever the total weigth in the synthetic short positions surpasses 10% from the weight (so <23 or >43% in position 1). 

I keep getting errors with my code. I'm trying to use the code from the tutorial on getting equity prices (in order to determine # of contracts), but this uses the onData (self data) instead of the onData (self slice) used by the sample option algorithms. 

Could you please help me? 

Much appreciated!

Igor

However, I keep hitting roadblocks.

Update Backtest








0

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.


Hi Igor. It is possible to achieve a similar result by short selling the two leveraged ETFs, SPXU and SPXL and rebalancing the portfolio. You can use Setholdings() to rebalance the portfolio each day, using a target holding percentage for both ETFs: def OnData(self, data):
# Rebalance portfolio daily
for symbol in self.tickers:
if symbol=="SPXS":
self.SetHoldings(symbol,-2/3)
else:
self.SetHoldings(symbol,-1/3)

I've attached a backtest where I demonstrate the above.

1

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.


You didn't ask but this is a community and I would like to weigh in on the fundamentals of your trading strategy. You will have extremely high negative delta if you by 2 puts and sell 2 calls. You could have like 100-200 delta.  Would you not rather by 3 puts. 1 with 60 day expiration and 2 with 30 day expiration? I am using a similar strategy now. I don't go by the contract though because its almost impossible to allocate the exact number you picked of 67% of buying power to an option contract. Because the contracts are a fixed price. Unlike forex where i can do strange percentages like 3.61 of my account buying EURJPY. So since febuary i have been like 75 Delta on the SPXS and 25 Delta on the SPXL. Hedging like this isn't working out too well. so i actually sold my spxl put today and used the money to by more spxs. 

0

Halldor Andersen 

@Halldor , thank you for you answer! 

However, there is some issue with balancing between the equities themselves. Leveraged ETFs tend to have very high fees for shorting them. This will in practice deteriorate most profit. Therefore I'm trying to find a way doing this with synthetic short stock (selling atm call and buying atm put). Although you pay cost of carry, this may be lower than the shorting fee and you fix the amount paid. I suspect running this strategy with the options the furthest away may obtain good results. 

I can definitely use the Setholdings() function for rebalancing, thanks for that. Do you also know how I can combine the slice and data arguments in the onData function? to determine the number of option contracts I need to get the price info first which requires the onData(self, data) function..

0

@ Apollos Hill 

Thanks for your suggestion! The rebalancing due to the contract size shouldn't be too much of an issue for now as I want to confirm the expected results through backtesting first (with like a 100k portfolio so I can get reasonably close to 33:67). Using 33:67 short on both SPXL and SPXS, you gain a net exposure of 1x to the underlying S&P. Through the effects of leverage decay/beta slippage, I expect the strategy to perform better than the S&P itself, however, through traditional shorting, the edge is mostly eaten away by the borrowing fee for those shares. I hope to circumvent some of that through options. Buying puts only will leave the portfolio exposed to significant vega as well, I hope to surpass that by selling calls as well, essentially hedging my put long vol exposure. 

By you example, did you mean you own puts on SPXS summing to -75 delta? (And -25 for SPXL puts?) That would definitely be similar to what I'm trying to do (except for not selling calls).

0

Hi yes right now I have 3 July 2019 puts for spxs. To me there is no point in selling calls against spxl. Can you explain the beta and leverage deviation that would make selling calls attractive? Delta is delta and they are inverse so selling a call on spxl = buying a put on spxs. Except when long a put the profit is unlimited but selling calls Caps profits and provides unlimited risk.

0

Apollos Hill 

The point I want to make is to sell calls on both SPXS and SPXL and be long puts on both as well. Reason is that both ETFs are toxic in the long run and lose money, but you do not want any vega exposure on a short position. By selling calls you hedge the vol exposure. 

Leverage deviation is best explained as this: If SPXL and SPXS provide 3x and -3x returns respectively on the SP500, and the underlying moves like this day1 :+25%, -20% day2, $1 invested in the S&P would still be $1 after those moves. With SPXL you would have 3x the return so +75% on day1 and -60% day 2, resulting in a portfolio of 0.7, a loss of 0.3 due to compounding leverage. Also, for the SPXS you would be left with only 0.4 on the last day. 

Of course this is an extreme example, but you get the point. Especially in high volatile environments, the Leveraged etfs drop in value quickly. 

0

Update Backtest





0

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.


Loading...

This discussion is closed