Hi QC Community,
Attached, a simple Daily Price Action Long / Short SPY ETF Algo for you to build on. Uses only 1 daily bar / candle to predict the next day.
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Simple SPY ETF algo using daily price action for long/short positions.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Price Action Long Short SPY ETF Algo
Sheikh Pancham | July 2021
Hi QC Community,
Attached, a simple Daily Price Action Long / Short SPY ETF Algo for you to build on. Uses only 1 daily bar / candle to predict the next day.
QuantConnectâ„¢ 2025. All Rights Reserved
Louis Szeto
Hi Sheikh,
Thank you for sharing this awesome algorithm. To further improve, we suggest you use minute resolution for more accurate filling prices, with daily checking conditions updated by daily consolidator.
Also, we would suggest using trade bar data: data.Bars.ContainsKey("SPY") and data.Bars["SPY"].Close in the original backtest to avoid error using only data["SPY"] if no bar data received. Please check docs for details.
Best,
Louis Szeto
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.
Sheikh Pancham
Thanks Louis! I only work on Daily strategies so I will go through what I have and update them with this method of using a daily consolidator on minute data. Also, I'm glad you suggested it as this might be the way for me to develop daily Futures strategies using Futures minute data. Cool.
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.
Sheikh Pancham
Hi Louis, as mentioned I am going back and changing my daily algos to use the method you suggested of consolidating the minute data into daily bars. This algo, code below, is running very slowly and outputting a minute equity curve, rather than daily. There are a couple of indicators also, so I was wondering how to get the indicators to use the daily bars consolidated from the minute data rather than straight from the Resolution.Daily data? The strategy is also using multiple crypto symbols so can you kindly check if I am implementing multiple symbols correctly? Thanks very much for your help!
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.
Louis Szeto
Hi Sheikh
It is very slow as you're running Update on alpha every minute. You may use a timestamp variable to avoid very close updating. We've attached a backtest for your reference.
Few more things to mention:
We also helped you do some simplification, hope it helps you!
Best,
Louis Szeto
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.
Sheikh Pancham
Thanks Louis, greatly appreciated!
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.
Sheikh Pancham
Hello Mr. Louis Szeto,
I am trying to add a ‘Close’ rolling window to an ML algo (attached) using the minute resolution consolidation to daily data method that you suggested previously for an algo that had indicators. Do you mind taking a look when you have a moment and show me how to do it for a rolling window pls? I made an attempt but not sure if this is the right way to get the rolling window to use the consolidated data.
Thanks.
Sheikh
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.
Louis Szeto
Hi Sheikh
It is glad to see you getting more familiar with the platform and we appreciate your sharing. Just a few adjustments:
Best,
Louis Szeto
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.
Sheikh Pancham
Thanks very much, Louis! Always appreciated.
I am getting a slew of 'insufficient buying power errors. I reviewed this post but not sure how to apply the solution. I tried, but no luck resolving:
Full code below. Kindly have a look when you get a chance. Thanks again.
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.
Sheikh Pancham
Sorry, attached is the code / algo. Thanks.
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.
Ruming Jiang
Guys,
Thanks for sharing! I learned something from it.
I have some questions regarding this advice:
When would such error (no bar data is received) happen?
In the doc they look the same, but I guess maybe in live trade transmission error might be the problem?
Thanks
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.
Varad Kabade
Hi Sheikh, Ruming Jiang,
Sheikh, to resolve the issue we recommend using the cash buffer of the algorithm. Add the following code snippet in the initialize method and refer to this backtest.
self.Settings.FreePortfolioValuePercentage = 0.1
Ruming Jiang,,Sometimes, the current slice object contains data about a symbol, but it is non-trade(Splits, Dividends, Delistings) data instead of a trade bar or quote bar. Refer to the attached backtest, for example.
Best,
Varad Kabade
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!