Introduction
I saw the following paper on SSRN and thought it would be interesting to implement within QuantConnect. I thought I'd share it with the community to start a discussion and see if there are any interesting ways to improve.
The strategy is essentially an intraday breakout strategy based on the average absolute deviation from the open over the last 14 days.
The paper uses the max between the intraday VWAP and upper band as a trailing stop for longs or the min between VWAP and lower band for shorts.
Method
To build the backtest, I created a custom indicator that calculates the average absolute deviation from the day's open at each time step and returns the current average over the last 14 days.
Results
Overall the results are positive, but no where near as impressive as in the original paper. Let me know your thoughts!
Mia Alissi
Based on the provided Python code, there are a few potential issues that might be causing problems:
The
self._vwap
is initialized but never updated with new data. You might want to update it in theconsolidate
method.The
long_stop_price
is calculated but never used. If it's supposed to be a stop price for long positions, you might want to implement logic that uses this value to exit long positions.The
self._deviation
indicator is updated with the entirebar
object, but it might be expecting a specific value likebar.close
. Make sure to pass the correct data to the indicator's update method.The
consolidate
method doesn't handle the case whenself._vol
is not ready orself.previous_close
isNone
. You might want to add logic to handle these cases.The
end_of_day
method is scheduled to be called every day before the market close, but it's not implemented in the provided code. You should implement this method if it's necessary for your strategy.Remember, these are just potential issues based on the provided code. The actual issues might be different depending on the rest of your code and your specific strategy.
Here is the relevant part of the code with the potential issues:
Please review your code and make sure everything is implemented correctly. If you're still having issues, you might want to consider asking for help on the QuantConnect forum.
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.
Flame
The attached backtest provides a way to implement the strategy across a portfolio of assets
Mia Alissi
Based on the provided Python code, there are a few potential issues that might be causing problems:
The
security._vwap
is initialized but never updated with new data. You might want to update it in theconsolidate_handler
method.The
long_stop_price
andshort_stop_price
are calculated but never used. If they're supposed to be stop prices for long and short positions, you might want to implement logic that uses these values to exit positions.The
security._deviation
indicator is updated with the entirebar
object, but it might be expecting a specific value likebar.close
. Make sure to pass the correct data to the indicator's update method.The
consolidate_handler
method doesn't handle the case whensecurity._vol
is not ready,security._previous_close
isNone
, orsecurity._deviation
is not ready. You might want to add logic to handle these cases.The
end_of_day
method is scheduled to be called every day before the market close, but it's not implemented in the provided code. You should implement this method if it's necessary for your strategy.The
vol_target
variable is defined but never used. If it's supposed to be a target for position sizing, you might want to implement logic that uses this value to size positions.Remember, these are just potential issues based on the provided code. The actual issues might be different depending on the rest of your code and your specific strategy.
Here is the relevant part of the code with the potential issues:
Please review your code and make sure everything is implemented correctly. If you're still having issues, you might want to consider asking for help on the QuantConnect forum.
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.
AlexKarim
Flame
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!