Still learning the ropes.
What I'm trying to achieve is to buy an equity whenever current price is 10% higher than the opening price of the day, then sell it at end day. To clarify, at anytime during the normal trading hours, if an equity's price reaches more than 10% of the opening price, there should be a market order placed.
Below shows the starting few lines of the logs. As seen, only one order is made. And instead of selling, it would appear I am buying stocks at end day.
2022-01-03 09:32:00 : [2022-01-03 09:32:00] STER XS22WUTNTYSL: openPrice: 20.6 buyingPrice: 22.99
2022-01-03 15:50:00 : End day. Liquidating!
2022-01-03 15:50:00 : Count: 1
2022-01-03 15:50:00 : [2022-01-03 15:50:00] AFIB XGSEQC44B4O5: openPrice: 3.49 buyingPrice: 3.91
2022-01-03 15:50:00 : [2022-01-03 15:50:00] LIVK XB6K364IMGRP: openPrice: 4.8 buyingPrice: 5.29
Nico Xenox
Hey qctrial,
you're investing only in one stock because before buying other stocks you check if the portfolio is invested and if it is, you return. The other problem is that even though you liquidate all your positions new positions keep opening after the liquidation because you didn't set a statement (ex. stop investing after liquidating)
I attached a backtest that solves these issues.
Best,
Nico
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!