I want to know the exact buying power with margin for “TQQQ” to avoid putting Invalid Order and rejected by InteractiveBrokers.

I want to know what's maximum margin available with Live trading at InteractiveBrokers with margin account and have been tested, but I couldn't figure it out clearly.

I got the following:

buyingPower= 1302.79, cash= 33.00, holding= 2539.58, Total Value= 2572.58

Got the buying power with: _buyingPower = self.Portfolio.GetBuyingPower(self.myStock.symbol)|

 

I put order with the quantity manually calculated with 95% (lowering -0.05% up to 75%) of the buying power and got order rejected with the following error:

YOUR ORDER IS NOT ACCEPTED. IN ORDER TO OBTAIN THE DESIRED POSITION YOUR EQUITY WITH LOAN VALUE [2569.14 USD] MUST EXCEED THE INITIAL MARGIN [2811.21 USD]. Origin: [Id=46] IBPlaceOrder: TQQQ (STK TQQQ USD Smart NASDAQ 0 )

Then, I lowered the quantity with 55% of the buying power, it worked. Log is:

2023-05-17 15:00:02 :buyingPower= 1306.66, cash= 33.00, holding= 2547.32, Total Value= 2580.322023-05-17 15:00:02 :TQQQ, Filled , Qty=24.0, Price= 29.64, Total= 711.30, TotalPortfolioValue= 2578.90, TotalHoldingsValue= 3258.20, TotalMarginUsed = 1629.10, TotalFees=1.0, Cash=-679.30, UnsettledCash= 0.00  2023-05-17 15:02:00 :buyingPower= 951.95, cash=-679.30, holding= 3262.49, Total Value= 2583.19