Hi everyone, I start use QC couple of days ago and meet an issue with GoodTilDate limit order property on BybitOrderProperties.
I want to set up limit long orders every minute and if it not executed - cancel it, thought that GoodTilDate should do this automatically, but in backtest result see a lot of orders that close at 19:00:00. What I doing wrong? Moreover orders that have filled status, were filled more than 1 minute time period

Mia Alissi
Reviewing 'Александр's' Python code, there are a few potential issues that could be causing the observed behavior with the
GoodTilDatelimit order property on BybitOrderProperties not functioning as expected:TimeInForce.GoodTilDateis set to expire 2 minutes after the order is placed. This might not be sufficient time for the order to be executed, especially in fast-moving or low-liquidity markets. Consider extending the duration to ensure the order has enough time to be filled.Order Cancellation Time: The observed issue where orders close at 19:00:00 might be related to the exchange's or the brokerage model's specific behavior rather than the algorithm itself. It's important to check Bybit's documentation or QuantConnect's brokerage model for Bybit to understand how orders are managed and when they are automatically canceled.
Order Fill Time: If orders that have a status of filled were filled more than 1 minute after being placed, it could be due to market conditions, the specific limit price set, or the liquidity of the asset. Ensure that the limit price is competitive and consider market conditions when placing orders.
Order Size Calculation: The order size is calculated based on a fixed value (50) divided by the long order price. Ensure that this calculation aligns with your trading strategy and account size. Also, verify that the
lotsizevariable, although declared, is not used in the order size calculation. If the intention was to use it, ensure it's incorporated correctly.Use of RollingWindow: Ensure that the logic for calculating
percentile_down_windowcorrectly represents the market condition you're trying to capture. The use of percentiles to determine order prices is a valid strategy, but ensure the logic accurately reflects your strategy's intent.Error Handling in OnOrderEvent: The
OnOrderEventmethod only processes filled orders. If there's an issue with orders not being filled as expected, additional logging or error handling might help diagnose the problem. Consider logging order events other than fills to gain more insight into order behavior.Time Zone Considerations: Ensure that the time zone used in the algorithm matches the market's time zone you're trading in. Time zone mismatches can lead to unexpected behavior in order execution and timing.
Brokerage Model Settings: Verify that the brokerage model settings (e.g., leverage, margin requirements) align with the strategy's needs and the specific behavior of limit orders on Bybit.
Addressing these points may help in resolving the issue with the
GoodTilDatelimit order property not functioning as expected in 'Александр's' algorithm.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!