Incomplete repayment with AUTO_REPAY


I am having an issue with my bot trading on isolated margin accounts. I have done some debugging and I think it might be a problem on the binance side (but I might be wrong).

Sometimes, when closing a short position using a market buy order with “AUTO_REPAY”, the original loan is not repaid fully, but only part of it.

Here is a recent example. I am reporting screenshots from my binance history pages of the initial borrow+sell order and of the repayment+buy order. I can only post one image as I am a new user, so bear with me for this collage.

This is the initial borrow from the Borrowing history

As you can see, I am buying 2148 VITE in the VITE/USDT isolated account, but only ~1931 get repaid.

Because the repayment is incomplete, the account is left with some amount still shown as borrowed, triggering a bunch of errors in my code.

One idea I have is that it just takes some time for the repayment to complete and I should wait longer. Is that possible, or is there a bug from the binance side?

What’s the best way to check the repayment has gone through?

Hi @pistello, are you sure you had enough amount for the full repayment?
If you think your calculation looks right, I would recommend reaching out to the customer support on Binance’s website for a more detailed research and analysis, as we’re limited on this side because don’t have access to user’s data and trading history.

I have done further investigation into this issue and I have noticed that it can take some time for the loan to get repaid after the “AUTO_REPAY” order gets sent.

So, I think I might have an answer and I leave it here in case it may help anyone in the future. My bot was clearing any remaining quote and base currency from the isolated margin account after 30 seconds, but it was not checking if the loan repayment had gone through. Now I am clearing the account only after the borrowed amount gets changed to zero and I have not seen the issue appearing again so far.

1 Like