Hi,
So thanks to Jing's expert guidance i have made some changes to the algorim.
It is running quite well on hour frequency however i am still getting errors that i dont have
enough money to complete the trades.
I am not sure where i am going wrong.
Jing Wu would you be able to advise.
Many thanks,
Best,
Andrew
Andrew Czeizler
Attached another example, from my understanding this algorithm rebalances everyday?
Many thanks,
Best,
Andrew
Andrew Czeizler
The error is -
Backtest Handled Error: Order Error: id: 40, Insufficient buying power to complete order (Value:97865.1104), Reason: Id: 40, Initial Margin: 48935.575203376, Free Margin: 19948.036555804
Best,
Andrew
Andrew Czeizler
Backtest Handled Error: Order Error: id: 38, Insufficient buying power to complete order (Value:95411.8614), Reason: Id: 38, Initial Margin: 47709.595703431, Free Margin: 20786.686379447
Andrew Czeizler
Another backtest attached.
I doubt the algorithm is correct as the portfolio weigthts of the instruments is not very balanced.
Running a report, states that most of the weight is in the XLK instrument (98.2%).
Also i was wondering if this regression is a rolling regression per day based on the look back period?
Many thanks,
Andrew
Jack Simonson
Hi Andrew,
Yes, this regression is a rolling regression using a 750-day lookback window. The first self.Schedule.On() call in Initialize(self) ensures that the regression and signal generation is performed every day at market open. As for the algorithm itself, the signal generation and trading signals are working properly. However, given that there aren't any event handlers for encountering margin constraints in the algorithm itself, what happens is that some market orders are invalid and dropped, specifically the last order for QQQ in this algorithm. Then, at the time the algorithm ends almost all of the non-cash value of the portfolio is in XLK and the resulting asset-allocation chart in the backtest report reflects this uneven distribution of the portfolio equity. This isn't the weighting scheme throughout most of the algorithm, just once the margin requirements are no longer met in order to place orders for both assets. You can see this in the attached backtest and view the logs and trade report.
Andrew Czeizler
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!