Okay. As I mentioned before, I use this for an account in which I only trade futures, not stocks or options. So I haven't verified it for anything else but futures. I usually have about 25~30 open positions at any time, in about 3~4 different currencies.
Step 1. Get the account overview, including all open positions and all cash positions in any currency. Use reqAccountUpdates(), updatePortfolio(), updateAccountValue() and accountDownloadEnd().
Step 2. For each position in my portfolio: determine the maintenance margin for one contract, and for the current position size. Place a what-if order to do this. Use the current account total maintenance margin as starting point (this was obtained in step 1). Use placeOrder() to buy 1 contract, and receive the new account maintenance margin via openOrder(). The absolute value of the difference between the two values is the maintenance margin for one contract expressed in the BASE currency of your account. You can convert this to the instrument's currency by getting the latest exchange rate. I already have that exchange rate stored on my computer, so don't need to request that separately. Multiply by the position size to get the maintenance margin of the position.
Step 3. Find the maintenance margin per currency. Loop through your positions to make a list of all currencies involved. For each currency: collect the instruments which quote in that currency, and collect the maintenance margin of these positions. At step 1 you received your cash positions in any currency you may have. Compare for each currency the cash position versus the maintenance margin for these positions. If your cash amount is less than the maintenance margin for those positions you will get a debit interest line in your monthly IB statement.
I wrote this software in Java. It is not fast, it takes about 10~20 seconds, but speed is not a requirement for me. I built it as I wanted to be able to monitor whether I was incurring debit interest in any currency. It helps me to determine whether I should do some money conversions, from a currency into another currency.