Hello,
Is there a way to tweak this algorithm to make sure it only trades each stock once per day? I would like to make sure each stock is only bought a maximum of one time per day. Thanks!
QUANTCONNECT COMMUNITY
Hello,
Is there a way to tweak this algorithm to make sure it only trades each stock once per day? I would like to make sure each stock is only bought a maximum of one time per day. 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.
Mia Alissi
Here are logic and runtime/code-robustness bugs found in Digitall's code:
Iterating over self.active_securities.values instead of self.active_securities.values() in morning_scan will cause a runtime error, as .values is a method and must be called.
In morning_scan, calling self.add_equity repeatedly for symbols already in the algorithm may re-add the same securities. This is inefficient and could lead to unintended side effects.
If using finer than Daily resolution, multiple bars per symbol may be present in one time step, but the code only considers the last bar in on_data. If intraday moves or multiple signals matter, this could lead to missed trades/signals.
There is no prevention of multiple buys in the same symbol on a single day: after an exit (TAKE PROFIT/STOP LOSS), if price meets the condition again, the algorithm will re-enter. This violates the 'only trade a stock once per day' requirement.
Clearing _entry_prices in end_of_day_liquidation could result in state mismatches if a fill event is processed after midnight (rare but possible in live trading).
The on_securities_changed method is empty, so any addition/removal of securities from the universe is ignored. This might lead to state or data issues since internal lists and dictionaries are not updated accordingly.
Sources: E T F Constituent Universe Filter Function Regression Algorithm, Head & Shoulders TA Pattern Detection, Momentum Short Term Reversal Strategy, Algorithm Engine - QuantConnect.com, Debugging - QuantConnect.com
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.
Digitall
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!