Back

How would you program the following scenario on this platform?

I'm a little bit of a newbie and would like to know how to program the following scenario. I will use TQQQ, SQQQ and QQQ here, but it could be use with any very liquid leveraged pair.

1. At a given interval (based on time or volume), purchase SQQQ and TQQQ with the exact same amount of money (let's say $30k each).  Because both move in opposite directions, I would be neutral in the market. (or close enough)

2. If the price of TQQQ moves up by 5% (or some number of my liking), sell it at market and purchase QQQ immediately to rebalance the portfolio.

3. Decide at some point before the end of the day the best time to exit all positions without losing money.

4. I don't want to keep Leveraged ETFs overnight because of the decay factor. I could see scenarios where I can keep QQQ longer. 

5. I have done this manually and it has given me some decent results. However, I would like to automate this process. I trade commission free.

Thanks for any code or hints from experts.

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 Henri,

Feel free to check out our BootCamp, it is a great introductory resource for learning our API.

I've also attached a backtest with an implementation of the requests.

Best,
Shile Wen

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.


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