Hello Everyone,
This is the first algorithm I wrote, and I aimed to keep it simple. The strategy is based on recommendations from Jim Cramer, the host of the TV show "Mad Money" on CNBC. I use Custom Data to upload the show's recommendations. Since the show airs at 6:00 pm after the market closes, the recommendations are processed and executed as market open transactions the next day. The strategy is short term and holds positions for self.holding_period (e.g., 3 days) before liquidating them.
The weight of each position is determined by the number of recommendations on that day and the holding period. For instance, if the holding period is 5 days, the weight for all recommendations of each day is 20%, which is then divided among the day's recommendations.
I think the strategy can be improved, and I am open to suggestions to make it more realistic.
Mia Alissi
Based on the provided code and the constraints of the question, it seems that 'Ali' has a well-structured algorithm. However, there are a few areas that could be improved or might cause issues:
Handling of Recommendations: In the
on_data
method, the algorithm processes buy and sell recommendations. However, it doesn't seem to do anything with these recommendations after fetching them. The algorithm should include logic to act on these recommendations, such as placing trades.Universe Selection: The
FundamentalSelectionFunction
is used to select a universe of stocks based on certain criteria. However, this universe doesn't seem to be used anywhere else in the algorithm. If 'Ali' intends to use this universe for trading, he should include logic to handle these securities.Liquidation Logic: The algorithm keeps track of entry dates for trades and liquidates them after a certain holding period. However, it doesn't seem to account for weekends or holidays when the market is closed. This could lead to holding positions longer than intended.
Here's a suggestion on how to handle the recommendations:
This code will equally distribute the portfolio among the buy recommendations and liquidate any securities that are in the sell recommendations. The entry date for each bought security is also tracked for the holding period logic.
Please note that this is just a suggestion and might need to be adjusted based on 'Ali's' specific strategy and risk tolerance.
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.
Jared Broad
It looks great, @ali-rouhghalandari!
Where do you source the data? Are you sure it doesn't have a look-ahead bias? If it's daily data from, say, Quiver Quant, ensure that you add 24 hours to the release timestamp to reflect when the data becomes available.
I don't think you need the fundamental data - you could add the assets you need from Crammer's reports.
You could simplify the code a lot if you used the algorithm framework to emit insights for the signals, and the portfolio systems will automatically rebalance/execute for you.
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.
Ali Rouhghalandari
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!