• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recovering from crash

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

    Recovering from crash

    Hi!

    I am trying to figure out how to handle crash recovery. Suppose, as my situation today is, that I have some running strategy and NT crashes while the strategy has an open position. I am using IB, so when I restart NT and reconnect to IB, NT actually knows about my orders and positions with IB (you can see them in the control center).

    As per a post by NT staff, a strategy would not know about the fact that the position is its own position, and indeed, the control center orders tab does not show the strategy on the open stop order, does not show the position on the strategies tab, confirming that the connection between the position, the orders and the strategy is entirely lost.

    However, if we maintain the assumption that I have at most one strategy active per symbol (this is something that I can control), then theoretically, the strategy can scan the account positions and discover the existing position and decide to manage it going forward. I don't know whether I can somehow discover the open stop order, as the Orders collection has nothing in it.

    So these are my questions (under the assumption listed above):
    1. Is there any way for a strategy to recover open (working) orders from the account?
    2. Is there any way that a strategy, having discovered a position, can "take it over"? That is to say, can it reestablish the connection between the position and the strategy. so that the managed API will do the right thing? (it is my understanding that is I simply issue an ExitLong() while having a "disconnected position" that was left over from the crashed process, then what the API will actually do is start a short position...
    3. Alternatively, can the strategy temporarily switch to an unmanaged mode, issue a Sell() when it wants to exit the "orphan position" and then return to managed mode so that further transactions will use the managed API as normal? Would that do "the right thing"?

    #2
    Hello arnonmoscona,
    Thanks for writing in and I am happy to assist you.

    1. The strategy can recover orders but only if it’s a 100% match.
    2. You can set Sync position true in the strategy parameter box to sync the account position and the strategy position. Please refer here to know more about sync position http://www.ninjatrader.com/support/h..._positions.htm
    3. Unfortunately you cannot mix Managed and Unmanaged code.

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you. This is helpful. Can I get some further clarification though?

      1. Assuming the NT crashed or was otherwise terminated but I didn't touch the existing positions and working stops, and assuming that I configured NT like so: Immediately submit live working historical orders, Sync account position = true

      then should the match be successful even though some of the information (like the link to the strategy) was lost. I assume from what I read that the answer to this is "yes".

      2. Is there any way to set this combination programatically from the strategy (rather than interactively from the UI). I sometimes have lots of instances of the strategy (tens of them on multiple instruments). I realize that I have the alternative to code a single multi-instrument strategy, but that is more complicated and error prone than a single instrument strategy. It would work if I don't have to make manual (read: error prone) UI adjustments. So I prefer my current setup, as long as I can manage these settings from the code...

      Comment


        #4
        Hello arnonmoscona,
        1. Yes, as long as the order matches 100% (order price and quantity is same)

        2. Unfortunately there is no way to set it via code. You need to specify it when starting the strategy.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thanks.

          As for (2) I noticed that StrategyBase has a property SyncAccountPosition - I thought maybe I could set that in the Initialize method. Is this just undocumented stuff I should avoid?

          Comment


            #6
            Hello arnonmoscona,
            We only recommend assigning the value via the UI only.

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Oh, one more thing. If I had a partial fill of a stop, then I understand all bets are off. There is no chance for the strategy to sync the position properly. Am I correct?

              Comment


                #8
                Hello arnonmoscona,
                Yes, you are correct.

                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jrobin747, Today, 02:37 PM
                2 responses
                11 views
                0 likes
                Last Post bltdavid  
                Started by Gav_G, Today, 01:23 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by webus, Today, 01:05 PM
                2 responses
                23 views
                0 likes
                Last Post webus
                by webus
                 
                Started by Wick Wrangler, Today, 12:42 AM
                1 response
                22 views
                0 likes
                Last Post NinjaTrader_Kate  
                Started by pman777, 04-15-2020, 05:09 AM
                5 responses
                49 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X