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

Sim Account - "Buying Power", "Cash Value", "Initial Margin" don't seem quite right

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

    Sim Account - "Buying Power", "Cash Value", "Initial Margin" don't seem quite right

    Hello-

    I've noticed some odd behavior out of the sim accounts. In this case, I'm trying to run a number of strategies which use variable position sizing, based on the amount of buying power currently available in an account.

    Here, I've set the accounts up as you'd see in the attachment. Then, I use code that determines whether or not this is a "live" trade (i.e. not a backtest), and will query the buying power available to the account in calculations to determine position size:

    Code:
    positionSize = liveOnly ? (int)Convert.ToDouble((GetAccountValue(AccountItem.BuyingPower) * KellySizingCriterion())/(Instrument.MasterInstrument.Margin)): (int)Convert.ToDouble((localAccountSize * KellySizingCriterion())/(Instrument.MasterInstrument.Margin));
    Now, I've attached two additional screenshots - first, of the strategies running, and then a shot of the accounts.

    You can see here that even though this is a $250k account, somehow the logic managed to accumulate $556,875k worth of initial margin (I should note that every instrument has the correct margin requirements all set independently via Instrument Manager). Instead of saying "Zero" buying power, apparently I have 3 times the buying power that my account is even worth, even though I'm holding on to futures contracts whose required margin is twice the size of my portfolio.

    Is this a problem with sim accounts? Is there a setting I'm using incorrectly here?
    Attached Files

    #2
    Hello cgeorgan,

    Is this inquiry specific to the GetAccountValue call with Buying Power and this is not matching the Buying Power that is shown on the Accounts tab of the Control Center?

    Or are you asking a general question about how performance is calculated and why the Buying Power on the Control Center is much higher than the current cash balance?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Is this inquiry specific to the GetAccountValue call with Buying Power and this is not matching the Buying Power that is shown on the Accounts tab of the Control Center?
      Actually, the buying power in the accounts tab clearly isn't the buying power. I can get the account value, get the buying power, etc. That isn't the issue. It's the values that are being produced.

      How can a $250k account holding securities that require $550k in initial margin have over $750k in buying power, while still having almost $100k of excess equity?

      Comment


        #4
        Hi cgeorgan,

        Thank you for confirming that this inquiry is not related to script development but is instead about the backend of the Simulation Engine and how this calculates the Buying Power.

        When it comes to the performance calculated by the Simulation Engine, if you feel that this is calculated incorrectly, and you have a formula you would like implemented instead, we can submit a feature request to do this.
        Please let me know if you would like to submit an alternate formula for use with the Buying Power calculation on the Simulation Engine.

        The Buying Power is the cash balance plus the maximum margin available (leverage). If you were with a broker, this would be the amount that the broker would be allowing you to trade up to.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hi cgeorgan,

          Thank you for confirming that this inquiry is not related to script development but is instead about the backend of the Simulation Engine and how this calculates the Buying Power.

          When it comes to the performance calculated by the Simulation Engine, if you feel that this is calculated incorrectly, and you have a formula you would like implemented instead, we can submit a feature request to do this.
          Please let me know if you would like to submit an alternate formula for use with the Buying Power calculation on the Simulation Engine.

          The Buying Power is the cash balance plus the maximum margin available (leverage). If you were with a broker, this would be the amount that the broker would be allowing you to trade up to.
          So in this case, since we're dealing with futures contracts only (no equities or spot FX), the broker has decided how much I can trade by providing the initial and overnight margin figures. For example, if I have a $10k account and overnight margin is $5k per contract, then my buying power is 2 contracts. If I own two contracts already, my buying power is now zero. It isn't complex.

          I actually can't even tell what's going on here with NT, but I can take a guess: I think that NT offsetting long/short margin (as one might do in a long/short equity book). I say that because you can see from my example how the $250k account somehow has a cash value of over $350k even though it has $550k in securities (that's $550k worth of initial margin in securities already held). There's no way to explain how a $250k account with those holdings can have a buying power of over $750k - the securities held should not act as any sort of collateral to allow you to margin even more securities.

          I don't think we need an alternative way to calculate account values when trading futures - simply the correct way of doing it. You guys (NT) have the tools; they're just being calculated incorrectly.

          Comment


            #6
            Hello cgeorgan,

            Are you able to demonstrate with a calculation that this is incorrect?

            If so, we can submit this as a bug report to our development.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello cgeorgan,

              Are you able to demonstrate with a calculation that this is incorrect?

              If so, we can submit this as a bug report to our development.
              I honestly thought that sort of thing was common knowledge regarding the trading of futures.

              Anyways, here's a brief description at Interactive Brokers:

              Note that for commodities including futures, single-stock futures and futures options, margin is the amount of cash a client must put up as collateral to support a futures contract. For securities, margin is the amount of cash a client borrows.

              Comment


                #8
                Hello cgeorgan,

                If you would like a bug report submitted about this, you would need to demonstrate that the values are being calculated incorrectly by showing the correct calculations.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello cgeorgan,

                  If you would like a bug report submitted about this, you would need to demonstrate that the values are being calculated incorrectly by showing the correct calculations.
                  So in the examples provided, there were the following positions (with the margin I use from Interactive Brokers on a per-contract basis):

                  - Short 18 6A (margin is $2,656) = $47,808 in cash tied up
                  - Short 10 6B (margin is $5,656) = $56,560 in cash
                  - Short 28 6C (margin is $2,607) = $72,996 in cash
                  - Short 13 CL (margin is $4,760) = $61,880 in cash
                  - Long 30 DX (margin is $3,702) = $111,060 in cash

                  So to have these positions in a futures account, I would need $350,304 in cash - far in excess of the $250k in cash I would have. I certainly don't have $758,747 in buying power (I actually have negative $100,304 in buying power). I absolutely don't have $379,373 in excess cash (I should have zero excess cash). I don't at all know how you guys are calculating initial margin, because it isn't the $556,875 I showed you in the picture - it's $350,304 that I calculated above).

                  So yes, please submit a bug fix request. Thank you!

                  Comment


                    #10
                    Another Example

                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello cgeorgan,

                    If you would like a bug report submitted about this, you would need to demonstrate that the values are being calculated incorrectly by showing the correct calculations.
                    Here's another example with just one contract.

                    I'm short 12 CL (margin is $4,760), so $57,120 is tied up. You can see that in the account page.

                    My original cash value of the account was $250k; I have $19,873 in net profits. However, what NT is doing is taking my $57,120 in tied up margin and adding it back to my account cash value, which (in addition to the $19,873 in PnL) is now calling my cash value $326,993.

                    The real calculation should be:

                    - Initial margin $57,120 (regardless of if I'm long or short, the initial margin is always additive);
                    - Buying Power of $212,753 (that's for futures only), which represents my $250k initial value, the $19,873 in profits, minus the $57,120 in margin;
                    - Cash Value should be $271,044, which is my initial value of $250k; profit of $19,873k, plus the mark-to-market profit on the 12 CL i'm short ($1,171.20).

                    Excess equity isn't very applicable to a futures trading account.
                    Attached Files

                    Comment


                      #11
                      Hello cgeorgan,
                      Thanks for your reply.
                      This has been improved upon in NinjaTrader 8. NinjaTrader 8 is currently still in beta, however you can download and test it from the link below if you would like.
                      BrandonNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by swestendorf, Today, 11:14 AM
                      2 responses
                      5 views
                      0 likes
                      Last Post NinjaTrader_Kimberly  
                      Started by xiinteractive, 04-09-2024, 08:08 AM
                      4 responses
                      13 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Mupulen, Today, 11:26 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post Mupulen
                      by Mupulen
                       
                      Started by Sparkyboy, Today, 10:57 AM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by TheMarlin801, 10-13-2020, 01:40 AM
                      21 responses
                      3,917 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Working...
                      X