I am trying to calculate those balances that remain when opening or closing purchase and sale operations, the problem I have is the following in the image you can see that my balance in the ETHUSDT pair is $200 USDT when trying to open a purchase operation I see that I am I have exceeded my balance by $0.001672 as seen in the second image with the response of the purchase operation in the cummulativeQuoteQty field, my logic tells me that if I have $200 USDT balance in my account and if I exceeded $0.001672 USDT then binance I borrowed that amount, however, when reviewing the marginBuyBorrowAmount field, I see that the amount borrowed is $0.00168872, which exceeds $0.00001672 of the $0.001672 that was the original surplus, I review the result of the operation in the app and see that the pair remains a balance of $0.00001672 and that is where I no longer understand why that balance was in USDT, because binance decided not to use the total of the $200 that I have in balance, I don’t know what calculation it uses for To determine that you will only use a part of $200 and leave me that small balance, I need an explanation
The other problem that I am seeing is how it calculates the interest, before it had not taken importance, only towards the query and saved the data and at the time of closing the operation I only multiplied that interest by the hours to know how much I had to pay, now I check and I see that the interest does not match the formula proposed by Binance, according to Binance the interest is calculated with the following formula
The calculation formula: I (interest) = P (borrowed money) * R (daily interest 0.02%/24) * T (in hours)
Returning to the second image at the bottom is the response to the query to obtain the interest data of the operation that was opened there we see that the daily interest is 0.0002 in the interestRate field, if my borrowed amount is $0.00168872 then the calculation would be
0.00168872 * (0.0002 / 24)
Where the result would be 1.4e-8 but in field of interest it has 2e-8, what is happening then? how did binance get that result
I’d appreciate your help