Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Target hit while connection lost

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

    Target hit while connection lost

    I have an Unmanaged strategy that was running fine with IB until the following situation:

    Pre connection loss:
    Strategy was Long with a Target and Stop (oco).

    During connection loss:
    Target was filled. So my broker account was Flat.

    After re-connection:
    NT knows nothing about the Target being hit. So strategy incorrectly reports MarketPosition.Long, and will not do anything because it just waits for an update from either the Stop or Target orders.
    Looking at the NT Orders I see it has marked the Target and Stop orders with Status (OrderState)=Unknown.

    Question: Is there any way I can force (preferably in code) the NT Target and Stop order objects to resync from the correct status on the Broker's server?

    #2
    Hi DaveE,

    Thank you for your post.

    Can you please send me your log and trace to support by going to Help -> Mail to Support
    Put ATTN Cal in the subject and reference this thread in the body.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I've done some more testing.
      Summary:
      Problem 1: Target and Stop hit at broker during disconnection, are not updated on NT, after reconnection, to correct status from the server, but both get set to OrderState.Unknown.
      This problem occurs regardless of whether Managed or Unmanaged strategy is used.

      Problem 2: If Unmanaged=true then OnPositionUpdate is not called after reconnection (even though the position did change at server during disconnect due to either Target or Stop being hit). So the strategy does not work correctly after reconnection since it thinks its in a different MarketPosition to reality.
      This problem does not occur in a Managed strategy since OnPositionUpdate does get called after reconnect, so position of strategy correctly reflects server after reconnect.

      Since Problem 2 is the most serious. What I really need is some code (I dont care if its unsupported/undocumented) that will force Position to be resync'd from the server.

      Has anyone who runs an Unmanaged strategy on IB found a solution to this problem?

      Comment


        #4
        DaveE,

        The paper trading account has a random interval for when it sends position updates to NinjaTrader. This is limitation with the paper account
        I tested out the concept on a different account and connection and got the expected results of the strategy.

        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hi Cal,

          When you say a "different account" do you mean a Live IB account?
          When you say "got the expected results" do you mean that Position was updated correctly on a Live IB account after reconnect (even for an Unmanaged strategy)?
          Do you also mean that the OrderState for the Target and Stop IOrder objects get set correctly after reconnect on a Live IB account (rather than being set to Unknown)?

          It would still be useful to know how to call 'PositionUpdate' from code (whatever function it is that NT reconnection calls), because I cant test on my Live account and I cant reliably backtest a strategy that uses Target and Stop at the same time (because of lack of information in historical bars).

          Comment


            #6
            DaveE,

            I tested the strategy with a different demo account from a different broker.

            When I say got expected results, I mean that when I tested the disconnection and reconnected the strategy called the position update as expected from the broker I was using.

            The strategy will always call OnPositionUpdate() when you get reconnected but that doesn't mean there was a position update from the broker side with the IB demo account as it is a random event with the demo account.

            There is no way to force the code to call OnPositionUpdate with manually disconnecting and reconnecting.
            Cal H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,229 views
            0 likes
            Last Post xiinteractive  
            Started by andrewtrades, Today, 04:57 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            7 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            441 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            12 views
            0 likes
            Last Post FAQtrader  
            Working...
            X