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

How to determine the current data provider

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

    How to determine the current data provider

    Hello

    I am using NT 8.0.18.0 64-bit.

    I have a Continuum account and a TD Ameritrade account, and will be adding other accounts with other providers.

    In my custom strategy, is there a way to programmatically determine which provider is currently providing data to the strategy?

    I have tried various options using Account.Connection syntax, but have been only able to return information from the primary (first) connection.

    Thank you

    #2
    Hello Zigfried,

    From the strategies Account object you would not be able to tell as the strategy can only be applied to a single account at once. The Accounts connection would be reported here.

    You could loop over the active connections, however if you add more and they are not associated with the strategy that still won't really help:

    Code:
    foreach (Connection connection in Connection.Connections)
    {
          Print(connection.Options.Provider.ToString());
    }
    In more advanced situations where you may have an account with one provider and then get data from another, that is not really apparent from the strategies point of view as it only knows about the trading account it is applied to. What is the use case where knowing the connection is required? Perhaps there is a different way to approach the task.

    As a side note, there is a new update available.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse

      I want to terminate the Strategy under 2 conditions:
      1) Preferred Connection/Fallback - the Strategy is not started with the preferred connection, or falls back to a non-preferred provider
      2) Configuration Error - the User configures the Strategy to trade a TD Ameritrade account, and to modify orders in a manner that is not compatible with TD Ameritrade. This question is different from my first one - How to tell the account provider for the account being traded, without using Account.Name?

      Thank you

      Comment


        #4
        Hello Zigfried,

        Thank you for the additional details.

        For the first situation, you may be able to utilize the OnConnectionStatusUpdate override for situations where a connection changes/fails. For identifying that the strategy was started with the right connections would really only be possible to check the accounts connection directly. Otherwise to the strategy it would only know you are connected to some providers, they are not specifically linked to your strategy. You could potentially use the connection collection to loop over the connections however if you had two fallback connections it would be up to your logic to know the difference or if the strategy should work based on that info.



        For the second question you have already provided the way to do that, you would just need the .Options.Provider part:

        Code:
         Print(connection.Options.Provider.ToString());
        or
        Account.Connection.Options.Provider

        The Provider enum can be used to match providers however they are not named pretty so you would need to Print the loop of connections to find out what provider names you have, this will report something similar to Provider7.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SightCareAubetter, Today, 12:55 PM
        0 responses
        3 views
        0 likes
        Last Post SightCareAubetter  
        Started by traderqz, Today, 12:06 AM
        8 responses
        15 views
        0 likes
        Last Post traderqz  
        Started by SightCareAubetter, Today, 12:50 PM
        0 responses
        1 view
        0 likes
        Last Post SightCareAubetter  
        Started by Mongo, Today, 11:05 AM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Skifree, Today, 03:41 AM
        5 responses
        14 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Working...
        X