As of this writing this algo is ranked #1 and is in the top 1% of the community.
It's a crypto algo. GDAX charges high fees for 'takers', and there is no fee modelling. It will have to be appropriately converted to limit orders in order to take advantage of GDAX's zero fee for 'makers' fee model in order to actually be useful. Slippage is low on GDAX for the instruments in question so that shouldn't have too much of an impact.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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.
Mark hatlan
Yes, when SPY's closing price is less than the 200 Simple Moving Average sell all Leveraged ETFs (if long) and go to cash. The code I put went to plain cash when SPY<200SMA down in the "Else:" line.
You could go to SHY, IEF, TLT or AGG, or any combination of those to move into risk off positioning for example. The point is to have a bull/bear market timer to get you to a risk off position to preserve capital. Once the market changes, you can back to a full risk on position. This is where the 3x leverage will give you good alpha over time.
As for the market timer logic it doesn't have to be SPY<200SMA. There are lots of ways to determine a bull/bear cycle. If the 6 month percent return is less than 0%, the number of down days over the last few months is greater than the up days, etc. Look for some white papers that include market timer logic for more examples.
I'm a trader tying to learn to code, so I hacked this together, I'm not 100% certain this code is error free ;)
The 2 week rebalance is not as critical in Taylor's version, instead it keeps the allocation consistent. But when there is a market timer involved the rebalancing schedule becomes critical. If you were to only rebalance every Jan. 1, then you will get out of bear markets too late and get in bull markets too late, so you may not achieve any alpha. Daily rebalancing is too often in this case. However when you switch to weekly, bi-weekly, or even monthly, then you get in that sweet spot to get out of a bear market in time and get in a bull market early enough to capture those gains.
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.
Jack Pizza
You guys might find this interesting similiar idea without all the 3X for potentially issues.
https://www.quantopian.com/posts/new-strategy-in-and-outThe 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.
Derek Melchin
Hi Elsid,
Thanks for sharing. Since Quantopian is shutting down, users can proceed to this thread instead.
Best,
Derek Melchin
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.
Mark hatlan
Thanks. I'll check the in and out thread.
Also after looking at the above backtests I found that TVIX is not bought until the last few years, there may be a data problem.
So I've put this together with futures (a simple version without complex rolling code that is out of my skill for now). This allows the /VX to be used instead of TVIX. Interesting thing is that the futures version doesn't perform as well as just the plain TQQQ/TMF 50/50 model.
I've even tried using TQQQ/TMF with /VX to help with volatility, and it doesn't help either long or short /VX.
After looking at this original strategy more closely I take back my original comment about a risk off signal being needed, I do think that this strategy is hedged enough to not need a long volatility or a go to cash signal.
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.
Samuel Schoening
mark hatlan this is something I have found on previous renditions of this strategy. It is not buying TVIX or what is now UVXY because the data is not split adjusted. Therefore the price of those is over 1 billion dollars a share upon their inception lol. Also rip everyone using TLT and thinking that GLD was an inflation hedge. Last few months were absolutely brutal.
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.
Samuel Schoening
mark hatlan Feel free to check out my own exploration of this passive rebalancing concpet using the following hedges: SCO -2x oil, GLD (as inflation hedge *theoretically :( 2021), and TMF (3x long term treasuries). As equities we have QQQ, SPY, and IWM. It is a great plan long term but inflation poses biggest risk. I recommend a swap to UVXY or simply cash if you believe a high degree of inflation is coming.
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.
Mark hatlan
Yeah gold has been quite a ride the last 20 years. The recent commentary around how gold is not the inflation hedge it once used to be remains to be seen, at least if we ignore the last year and look ahead 10 years. If gold has truly changed its inflation correlation, then there has to be something large money managers are using to replace it. I haven't looked so I don't know what that could be.
Its interesting you have inverse oil in there, I haven't looked at that before as a hedge.
But why do you have SPY, QQQ and IWM? wouldn't it be simpler to have just 1? even if it was the one with the strongest upward trend.
Here is another example on stock and bond hedging using the last 100 days standard deviation, and using that as a timer to either be 100% in TQQQ or reduce TQQQ allocation and hedge with bonds. Really there are countless ways of putting in some sort of timer to hedge, I've only explored a handful.
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.
Mark Reeve
@Mark Hatlan, Be careful with your use of STD - I believe what you want to compare is the STD of RETURNS not the STD of Prices. Obvisouly comparing STD of prices is pointless as the STD of a higher priced stock will almost certainly be higher - irrespective of their respective volatilities (of returns).
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.
Mark hatlan
Yes you are right in that a straight comparison of STD between two differently priced data sets is not apples to apples. STD of the % return is certainly a good way of doing that. Do you have an example of this we could look at with this strategy? Seeing that code would be a great help to us lesser experienced with python.
My example above was not a normalized method of comparing STD, but just an example that if one wants to switch the allocation around with this portfolio with a bull/bear trigger there are unlimited ways of doing so, perhaps STD in some way can help improve this strategy generally as opposed to a static 50/50 or other ratio.
It would also be helpful if someone with better coding experience than myself could take a stab at using /VX futures for the long volatility hedge, it may prove better than the TVIX and VXX that have astronomical historical pricing in the backtests.
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.
Derek Melchin
Hi Mark,
To get the STD of historical returns, we can use IndicatorExtensions.
IndicatorExtensions.Of(StandardDeviation(100), self.ROC("QQQ", 100, Resolution.Daily))
We just need to ensure we increase our warmup period to accommodate.
self.SetWarmUp(200, Resolution.Daily)
See the attached backtest for reference.
For an example adding the VIX futures index, refer to this related thread.
Best,
Derek Melchin
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.
Mark hatlan
Thanks Derek, I didn't know about the indicator extentions. I'll check out the VIX thread too.
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!