I plan to do local backtest with LEAN on Taiwan stocks. Taiwan Stock Exchange has a price limit of 10%. That is, if a stock closed at 100 dollars Monday, the highest and lowest prices it can be traded at on Tuesday are 110 and 90 dollars, respectively.
When doing backtests, the price limit raises a problem about stocks' liquidities. In many real cases, stocks were traded at the down limit price all day long. Many selling orders queued up to sell, while almost nobody wanted to buy. In reality almost none of the selling orders would be filled. But LEAN's fill model would still fill selling orders when backtesting these situations.
I came up with two ideas to solve this problem:
1. To implement a new class EquityWithPriceLimitFillModel, which inherits the EquityFillModel, and with all the XxxxFill() methods taking the price limit into consideration.
2. To generate QuoteBars for the historical prices instead of TradeBars. For example, during the "down limit days", The open/high/low/close price of the Ask bar were all set at the down limit price, while those of the Bid bar were all set at 0 (or any other price lower than the down limit price), meaning there's nobody wanted to buy, so the selling order would not be filled. In this way I don't have to implement a fill model, so this looked easier than Idea 1.
Anybody experienced in this problem? Any opinion is welcomed!
Derek Melchin
Hi 謝永德,
We recommend creating a custom fill model to achieve this functionality. Refer to our documentation here.
Best,
Derek Melchin
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.
謝永德
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!