Hello everybody!
My preliminary submission to the Alpha Market is almost ready. Unfortunately, there are some problems that should be addressed. In particular, I need to figure out how to ensure that my DelayedExecutionModel Execute function is firing every minute between 3 PM and 4 PM whenever there are portfolio targets that need to be met. As I understand it the Execute function might only fire when there are updates to the portfolio targets. I'm using the equal weighting portfolio construction model for now. My DelayedExecutionModel spreads out the insight order over time so large accounts can be catered to. Also, I want the algo to wait until the Insight is truly expired before selling, not sell early if a security has been removed from the dynamic universe. If you want to give me any pointers on those problems that would be great. If not, no problem, I'll keep working on it. Here's my preliminary algorithm description...
The Observer algorithm is an exercise in observation-based intelligence. It attempts to overcome the computational inefficiency of many machine learning techniques by focusing on observation of the data at hand. Many machine learning techniques are not computationally efficient as they repeatedly guess at an answer without any observation of the historical data. Many backtested algorithms are built in a similar fashion, a few observations might be made by the algo developer, a model is envisioned and coded, and then the algorithm is tweaked in the hopes of making it a profitable algorithm. The Observer algorithm makes many observations of the data through the use of the speed of the computer. It then searches for the best trades given the data at the present moment.
Warren
Here's some screenshots of the preliminary results.
Alexandre Catarino
Hi Warren,
Of course, we can give you some pointers!
The EqualWeightingPortfolioConstructionModel returns a PortfolioTarget with zero quantity for securities that are removed from the universe, so we need to create a new portfolio construction model that changes this behavior. It can be done with a simple method override:
// In Initialize: SetPortfolioConstruction(new CustomPortfolioConstructionModel()); private class CustomPortfolioConstructionModel : EqualWeightingPortfolioConstructionModel { public override void OnSecuritiesChanged(QCAlgorithmFramework algorithm, SecurityChanges changes) { } }
On the part of ensuring that my DelayedExecutionModel Execute function is firing every minute between 3 PM and 4 PM, we would need to know which orders should be placed by it. Is it all orders? If so, the alpha model shouldn't emit insights before 3 pm and after 4 pm and should set the insights expiry time to 4 pm. If not, at least, the insights expiry should be set to a date/time between 3 and 4 pm.
The Execute method of the ExecutionModel is called every time iteration (new data/Slice). We can also control the time with algorithm.Time:
public override void Execute(QCAlgorithmFramework algorithm, IPortfolioTarget[] targets) { if (algorithm.Time.TimeOfDay > TimeSpan.FromHours(15) && algorithm.Time.TimeOfDay < TimeSpan.FromHours(16)) { } }
Warren Harding
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!