Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating positions based on account statistics

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

    Calculating positions based on account statistics

    Hi, is there a way to calculate how much capital is currently invested long and short based on the account information available? I'm interested only in equities, and only interested in the Kinetick Sim101 account and Interactive Brokers. Thanks!

    Here's what's going on. I'd like to restrict the strategy to only get into a certain number of positions at one time. Long positions decrease the cash value and short positions increase the cash value, but not by the cash value of the positions because of margins. It appears that the Sim101 account has 2x leverage and IB has 4x leverage, but the calculations don't work with multiple positions. I'm missing something, and that something might be really obvious.

    I only need this calculation as a stopgap until NinjaTrader can provide a more holistic view of the portfolio from within a strategy.

    #2
    Egan857, for your calcs you could access those account items - http://www.ninjatrader.com/support/h...ghtsub=account

    Please keep in mind this would not work for historical data though, here a figure of 0 would be returned for the above method.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand, but what I'm looking for is a little more detailed. GetAccountData gives me three pieces of the puzzle (buying power, cash value, realized profit), but I still need to put the pieces together. Assuming I know the buying power at the start of the day and the account's leverage, plus the current buying power and current cash value from GetAccountData, is there any way to figure out how much capital I have invested long and short?

      Comment


        #4
        For your individual strategy, you could either keep track of filled trades / positons for the day to calculate net exposure or access the realtimetime collection from the Performance class - http://www.ninjatrader.com/support/h...erformance.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks, but I'm not concerned at all with closed positions for one strategy. I'm looking for open positions for all strategies combined.

          Comment


            #6
            That's unfortunately not accessible, but covered on our feedback list with your other thread / suggestion. For now you could exchange the info needed across strategies via txt files for example or a global variable, but that would be something we could not really support coding wise.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              That's unfortunately not accessible, but covered on our feedback list with your other thread / suggestion. For now you could exchange the info needed across strategies via txt files for example or a global variable, but that would be something we could not really support coding wise.
              I'm assuming a global variable would be accessed and computed faster then a text file? I need this global variable, please help me via PM or email or something. I think it could solve the inter-strategy communication shortcomings I'm facing. I just need to know what file to declare it in and any precautions to be aware of.

              Thanks!

              Comment


                #8
                waynewright33, generally this would not be a supported concept, however you might find those code snippets helpful in this quest - https://www.bigmiketrading.com/ninja...njatrader.html
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                213 views
                1 like
                Last Post PaulMohn  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                4 responses
                544 views
                0 likes
                Last Post PaulMohn  
                Started by GLFX005, Today, 03:23 AM
                0 responses
                3 views
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                12 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                7 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Working...
                X