• 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

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 fredfred, Today, 03:41 AM
                2 responses
                6 views
                0 likes
                Last Post fredfred  
                Started by TraderYoda, Today, 03:33 AM
                0 responses
                0 views
                0 likes
                Last Post TraderYoda  
                Started by pjsmith, Today, 02:56 AM
                0 responses
                2 views
                0 likes
                Last Post pjsmith
                by pjsmith
                 
                Started by ntbone, Yesterday, 08:10 PM
                0 responses
                10 views
                0 likes
                Last Post ntbone
                by ntbone
                 
                Started by chrislou, 08-28-2015, 03:27 AM
                14 responses
                2,882 views
                0 likes
                Last Post nkhoi
                by nkhoi
                 
                Working...
                X