Skip to navigation

Test Order Impact (WhatIf)

View as MarkdownOpen in Claude

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.

If WhatIf is set to true the order will undergo a credit check for the expected post-trade margin requirement without executing an order. The estimated post-trade margin requirement is returned to the IBApi.OrderState object in the EWrapper.openOrder callback.

This is equivalent to creating a order ticket in TWS, clicking “Preview”, and viewing the information in the “Margin Impact” panel.

This returns an OrderState Object containing details about initial and maintenance margin impact. This also defines commission and fees for order submission.