Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to test order rejection handling in sim?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to test order rejection handling in sim?

    When I have an order rejected (because the price has moved past my stop) I want my strategy to resubmit the order as a market order. Toward that end, I have RealtimeErrorHandling set to IgnoreAllErrors and I'm trying to test it in sim by deliberately placing orders where the stop is in the wrong place.

    But when I run it, the orders are ignored, not rejected. So that approach to testing doesn't work.

    I have 3 questions:
    1. Do you have any example strategies for using IgnoreAllErrors (and resubmitting an order) in an unmanaged strategy?
    2. Do you have any suggestions for how to test this in sim, hopefully without having to wait for an actual rejection?
    3. Are rejections handled the same way in sim as in live trading (asking this because it is my understanding that sim orders never leave my computer, and therefore cannot be rejected by a broker).

    Thanks in advance.

    #2
    Hello bsmith,

    The only correct way to test order rejections on sim would be to allow them to natively happen while the market is moving and your logic is running. That is so you are not artificially creating a rejection that is unlike what you regular logic would experience.

    There are not any specific samples for order rejection that I can suggest and there are no ways to force rejections to happen with any NinjaScript methods. Rejections on sim are a generalization of what you may see on a live broker. All brokers have specific rules and produce unique rejections so in reality you would need to make note of any rejections that you hit on your live account and then add logic to handle those items. Rejection handling is as an advanced topic due to the limitations of testing and that all brokers can have different rejections for different reasons.

    Comment


      #3
      Thanks Jesse,

      I'll write a strategy that takes frequent tight stop orders on a 1 minute chart & run it in sim. While that won't test my real strategy, I can at least develop my understanding of how to handle the situation programmatically.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X