• 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

Interactive Brokers Margin Check

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

    Interactive Brokers Margin Check

    Hi,

    I'm trying to figure out a way to check IB margin requirements through script, or to place a "What If" order as described below through the IB API so that I can see if a trade is possible before execution, and resize accordingly. The issue is that IB changes its margin constantly and if an order is rejected, the script basically just shutsdown without an ability to resize that I can see.

    Thanks!

    From IB:

    https://interactivebrokers.github.io...pi/margin.html

    Checking Margin Changes

    From the API it is possible to check how a specified trade execution is expected to change the account margin requirements for an account in real time. This is done by creating an Order object which has the IBApi.Order.WhatIf flag set to true. By default the whatif boolean in Order has a false value, but if set to True in an Order object with is passed to IBApi.EClient.placeOrder, instead of sending the order to a destination the IB server it will undergo a credit check for the expected post-trade margin requirement. The estimated post-trade margin requirement is returned to the IBApi.OrderState object.
    This is equivalent to creating a order ticket in TWS, clicking "Preview", and viewing the information in the "Margin Impact" panel.
    See also: TWS Margin Impact



    #2
    Hello RandanAL,

    The only margin related items available through supported NinjaScript is with the AccountItemUpdate event.
    https://ninjatrader.com/support/help...itemupdate.htm

    With this you can get the AccountItem values for margin such as the InitialMargin that are shown on the Accounts tab of the Control Center.
    https://ninjatrader.com/support/help...ccountitem.htm


    Below is a link to the account values returned by each connection type. See the heading 'Account Values Supported by Provider'.
    https://ninjatrader.com/support/help...TheAccountsTab

    If the value you need is outside of this, it may be necessary to use unsupported code to interface directly to Interactive Brokers API.
    Last edited by NinjaTrader_ChelseaB; 08-21-2019, 12:10 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Please have you sample code to use IBAPI directly ?

      thank you

      Comment


        #4
        Hello oceanis400,

        I do not have any examples that directly interface with the Interactive Brokers API.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mtamaku, Today, 09:19 AM
        0 responses
        13 views
        0 likes
        Last Post mtamaku
        by mtamaku
         
        Started by traderMNQ, Today, 09:00 AM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by jransom, Today, 09:08 AM
        0 responses
        6 views
        0 likes
        Last Post jransom
        by jransom
         
        Started by Irukandji, Today, 08:27 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by brunoviveiros, Today, 08:18 AM
        0 responses
        5 views
        0 likes
        Last Post brunoviveiros  
        Working...
        X