开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

How to get the maintenance margin of one symbol, containing multiple STK and/or OPT positions


 

Hello friends,? I am quite excited to find the group here.? I am quite new to TWS API and so far I like it a lot.?

One task I am giving myself is to get the maintenance margin of one symbol, containing multiple STK and/or OPT positions.? I know this information is available on margin report, but I don't know a way to get it with the TWS api, nor with flex query api. This information is also "calculable" in the what-if navigator in TWS, by unchecking the position, refreshing the margin and calculating the difference.?

With the api, so far what I did is to use a combo order to close all positions of a symbol with whatIf marked to be true, then I can get the maintenance margin change in order state.? This is ok for most of my positions but not all.? For example I have a few HKG:0700 stocks, one short put and one short call.? The combo order to close all three positions cannot be submitted since it seems like that both guaranteed and non-guaranteed are not supported in this case.? ?I hope there are some other ways that I haven't found.??


 

I'm fighting with the same issue. I'd desperately need to get the margin for a basket of several orders. Simply running WHAT_IF on each leg and then adding altogether doesn't give the correct result since the margin of one position is depending also on the other positions you hold.


 

yes exactly.? For example closing the short call on a covered call position is actually increasing margin.? ?I can see the information with what-if window in TWS or from margin report, but so far I am not sure how to get the programatically.


 

I don't know if the API will be able to calculate what you're looking for.? It doesn't seem like a good sign if you are unsure about your margin/buying power while trying to open multiple stk/opt positions at once... Do all of these positions need to be opened simultaneously?? If done sequentially IB will tell you exactly what your margin requirements are for each trade.? I wonder if you might consider rethinking your strategy...

On Mon, Sep 6, 2021 at 7:14 AM <groups@...> wrote:
yes exactly.? For example closing the short call on a covered call position is actually increasing margin.? ?I can see the information with what-if window in TWS or from margin report, but so far I am not sure how to get the programatically.


 

thanks for the reply.? Actually I am no where near trading with API yet.? I am still too new for this.? ?What I am trying to do now is still "read-only".? In particular, now I want to know the maintenance margin for each symbol in my portfolio.? Is there any way to "read" out this information other than submitting an what-if order that close all positions of a symbol?