Bug in the position returned by ACCOUNT_UPDATE

Hi, there is currently a bug in the API where the account_update positions return “ZERO” instead of the actual number, only on round hours. (minute and seconds = 0)

sub_client.subscribe_user_data_event(listen_key, UserDataCallback, error)

In this section:
elif data_type == SubscribeMessageType.PAYLOAD:
if(event.eventType == “ACCOUNT_UPDATE”):

You can see here that position was .639, then ZERO at 12:00:00 and then .649 again after the next update
2020/05/18 11:59:52 - BTCUSDT: 0.649 ,
2020/05/18 11:59:54 - BTCUSDT: 0.639 ,
2020/05/18 12:00:00 - BTCUSDT: 0
2020/05/18 12:00:22 - BTCUSDT: 0.649 ,
2020/05/18 12:00:33 - BTCUSDT: 0.659 ,

and Here:
2020/05/17 11:59:26 - BTCUSDT: 0.17
2020/05/17 11:59:32 - BTCUSDT: 0.18
2020/05/17 12:00:00 - BTCUSDT: 0
2020/05/17 12:00:15 - BTCUSDT: 0.17
2020/05/17 12:00:18 - BTCUSDT: 0.16

…and here:
2020/05/17 19:57:29 - BTCUSDT: 0.59 ,
2020/05/17 19:57:30 - BTCUSDT: 0.58 ,
2020/05/17 19:57:45 - BTCUSDT: 0.57 ,
2020/05/17 20:00:00 - BTCUSDT: 0
2020/05/17 20:00:16 - BTCUSDT: 0.56 ,
2020/05/17 20:00:17 - BTCUSDT: 0.55 ,

…and here !
2020/05/18 03:59:45 - BTCUSDT: 0.36
2020/05/18 03:59:54 - BTCUSDT: 0.35
2020/05/18 04:00:00 - BTCUSDT: 0
2020/05/18 04:00:15 - BTCUSDT: 0.34
2020/05/18 04:00:20 - BTCUSDT: 0.35

This bug could really mess up some bots algorithms!!

Oh, one more thing. The Entry Price is ALSO reporting 0 instead of the actual entry price.

thanks for the feedback. As I can see the position data with 0 is when time closing to funding fee updates, so I think this recent changes related to this:

Please notice: event ACCOUNT_UPDATE in USER-DATA-STREAM will be pushed with only account balance or relative position when “FUNDING FEE” occurs.

Please check the details at:
https://binance-docs.github.io/apidocs/futures/en/#change-log

So during the FUNDING FEE event, the position will NOT be pushed in crossed position. And will NOT push the position data in isolated position mode if the position is not related.

This is clearly a bug and cannot be differentiated from the developer perspective.
Here’s some options:

  1. Add another field in the event which defines that it is a funding fee event type
  2. Make a different event instead of using ACCOUNT_UPDATE (ex: FUNDING_FEE_UPDATE)

Please either
-Provide an approved, future proof code example, which differentiate between normal and funding fee account update.
-Upgrade/identify the events with additional field.
-Reverse this change.

There is no bug here.

when the funding fee changes (once where 8 hours):

  • if you have crossed position, you will receive the message like

{"e":"ACCOUNT_UPDATE","T":1590998400222,"E":1590998400230,"a":{"B":[{"a":"USDT","wb":"94783.96827324","cw":"94772.03771908"}],"P":[]}}

it’s up to you how to handle the message, but you shouldn’t consider this is position change.
a) we gave the state of this special message.


b) if the account update due to position closed, there still has the position data with pa = 0, like:


{"e":"ACCOUNT_UPDATE","T":1591000932875,"E":1591000932877,"a":{"B":[{"a":"USDT","wb":"94770.00008054","cw":"94758.09341508"},{"a":"BNB","wb":"0","cw":"0"}],"P":[{"s":"BTCUSDT","pa":"0","ep":"0.00000","cr":"812.96542000","up":"0","mt":"cross","iw":"0","ps":"BOTH"},{"s":"BTCUSDT","pa":"0","ep":"0.00000","cr":"-2122.26880000","up":"0","mt":"cross","iw":"0","ps":"LONG"},{"s":"BTCUSDT","pa":"0","ep":"0.00000","cr":"-442.64799999","up":"0","mt":"cross","iw":"0","ps":"SHORT"}]}}
  • if you have isolated position, you will receive the message like:
{"e":"ACCOUNT_UPDATE","T":1590998400825,"E":1590998400827,"a":{"B":[{"a":"USDT","wb":"94783.94438454","cw":"94772.03771908"}],"P":[{"s":"XRPUSDT","pa":"1","ep":"0.20510","cr":"0","up":"0","mt":"isolated","iw":"0.01015245","ps":"BOTH"},{"s":"XRPUSDT","pa":"0","ep":"0.00000","cr":"0","up":"0","mt":"isolated","iw":"0","ps":"LONG"},{"s":"XRPUSDT","pa":"0","ep":"0.00000","cr":"0","up":"0","mt":"isolated","iw":"0","ps":"SHORT"}]}}

a) you should receive the position from the funding fee event
b) if you see pa=0, that’s mean you don’t have the position in that margin mode.

I don’t see anything can be confused here. And that’s it.

1 Like

ACCOUNT_UPDATE event now has a m field that can has types:

  • DEPOSIT
  • WITHDRAW
  • ORDER
  • FUNDING_FEE
  • WITHDRAW_REJECT
  • ADJUSTMENT
  • INSURANCE_CLEAR
  • ADMIN_DEPOSIT
  • ADMIN_WITHDRAW
  • MARGIN_TRANSFER
  • MARGIN_TYPE_CHANGE
  • ASSET_TRANSFER
  • OPTIONS_PREMIUM_FEE
  • OPTIONS_SETTLE_PROFIT