Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

OrderState.Unknown vs Order.IsTerminalState

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

    OrderState.Unknown vs Order.IsTerminalState

    The NT8 Help describes OrderState.Unknown as "An unknown order state. Default if broker does not report current order state.".

    Order.IsTerminalState is described as "A static method used to determine if the an order's OrderState is considered terminal and no longer active." and includes OrderState.Unknown in its determination.

    If the OrderState of an Order is OrderState.Unknown because the broker has not returned the OrderState, isn't it true that the Order could, in fact, still be "active", but not reported by the broker as such?

    If this is so, isn't declaring the Order (from its OrderState using Order.IsTerminalState) as "no longer active" inaccurate, at best? And doesn't it risk the Order consequentially being ignored and left "active" and therefore completely unmanaged by the trader, when in fact, it may be active and in loss (for example)?

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Unfortunately I don't have any specifics that I could provide detailing into how the IsTerminalState bool specifically becomes true in that situation. If you are currently seeing unknown state orders from a specific broker where the IsTermalState is true but the order remains open we could review that situation further and pass along the details to development. Because the unknown state happens for unknown order reasons I could only speculate that it may be possible that the order was still open but NinjaTrader is now unaware due to the connection providing an unknown state. Generally in that situation you would want to contact the broker to verify the account is flat and orders are managed.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, Jesse.

      This is a theoretical question -- I do not have any direct experience with Orders in OrderState.Unknown. It is the documented behaviour that I want to take into account as I write a large AddOn for commercial distribution.

      The Help says that Order.IsTerminalState is a "bool value which will return true when an OrderState is equal to OrderState.Cancelled, OrderState.Filled, OrderState.Rejected, OrderState.Unknown; otherwise false.". Given the Help for OrderState.Unknown says it is the "Default if broker does not report current order state", I would query if including OrderState.Unknown in the test for Order.IsTerminalState makes sense. Since, by definition, the Order state is unknown, it could just as easily be "alive and active" as "terminal and no longer active".

      To presume an unknown Order state is "terminal and no longer active" would seem to be the least desirable approach, since the possibility of it remaining alive and active is just as real as not. My own view would be that the state should not be included in the Order.IsTerminalState determination, and it should be documented along the lines of "test again as soon as possible, and if still unknown, contact the broker as the Order may be alive and active".

      I would recommend reconsidering how this all works to try to ensure that if a broker does not return information, the more conservative and cautious approach is taken, rather than assuming the Order is "all good because it's terminated". Of course, I can take this approach in my own code, but a more responsible approach is, I think, to reconsider how it works for all NT users.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Unless you are seeing that specifically come up as a situation I would not suggest to try and peruse adding handling for that case. You could potentially log it in case this is a script that is used across multiple connections to see if any user ever hits an unknown state order. That is mostly just a catch all for unknown or unmapped responses for the order state. Unfortunately I couldn't provide much guidance beyond that in regard to that state.



        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by AveryFlynn, Today, 04:57 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Max238, Today, 01:28 AM
        4 responses
        37 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by r68cervera, Today, 05:29 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by timko, Today, 06:45 AM
        2 responses
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X