Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I respond properly to different kinds of order rejections?

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

    How do I respond properly to different kinds of order rejections?

    So when I submit an Order in my Add On, it is possible to get back an OrderEventArgs where:

    OrderEventArgs.Error == ErrorCode.OrderRejected

    The most common cause for this is trying to enter on the wrong side of the price. But I noticed today there are other situations, such as "Rejected by Broker" if you try to short a ticker that cannot be shorted, like SGOV.

    Questions:

    1) Is there a way to differentiate the different kinds of rejections without parsing the error message in OrderEventArgs.Comment? (This seems ugly and error prone, obviously.)

    2) Is there a list somewhere of all the possible error messages that I would need to parse, if I have to go that route?

    Cheers.

    #2
    Hello canitron,

    Thank you for your post.

    In your Add On, you could subscribe to OrderUpdate events as shown in the example on this page:


    Then, for OrderEventArgs e you could check for e.Error. There are not as many possible errors as you might think. The possible error codes are listed on the help guide page for OnOrderUpdate() when used in a strategy here:


    With that information, you should be able to trap certain error codes and have your Add On take a different action based on the error. For example:

    Code:
    private void OnOrderUpdate(object sender, OrderEventArgs e)
    {
    if (e.Error == ErrorCode.OrderRejected)
    {
    // order was rejected, do something about it here
    }
    }
    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      I do all that. That's not the question I'm asking here. I'm saying that in the case where I am responding to OrderRejected, how do I further determine which rejections are b/c the order is on the wrong side of the price vs more serious rejections like the Broker won't accept this type of order, period. OrderEventArgs.OrderState and OrderEventArgs.Error do not contain sufficient information to subdivide out the different OrderRejected cases. OrderEventArgs.Comment contains different bits of text, depending on which OrderRejected case we are dealing with, but parsing error text is not a great way to code, and I'm not sure what all of the different possible Comments values could be. This is where I need help. Cheers.

      Comment


        #4
        Hello carnitron,

        Thank you for the clarification.

        The comment is a string that represents the error message provided directly by the broker. These messages are not generated by NinjaTrader, they are received from the broker. This means that the different possible values could vary and is ultimately up to your broker. There aren't any NinjaScript-specific resources related to possible rejection messages from a broker. You could consider reaching out to your broker, though even for NinjaTrader Brokerage I am not aware of any resources such as a list of possible reasons for rejections.

        Thank you for your time and patience.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Ok. So if I am hearing you correctly here, I have to parse the text I get back, based on the broker I am connected to. There aren't any additional enum types or numerical rejection ids/codes that enable me to differentiate rejections based on any kind of established numerical values.

          That's a tiny bit awkward in the case I'm dealing with, though I guess I can see how the industry arrived here, which is basically "the order was rejected, who cares why". 99.99% of trades and traders don't care why.

          Regardless, thank you for your help. Cheers.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X