Examples for Futures websocket ACCOUNT_UPDATE event upgrade

Futures will perform an upgrade on the ACCOUNT_UPDATE event. Please find more details in the Change Log section from the API documentation: https://binance-docs.github.io/apidocs/futures/en/#change-log

To better understand the upgrade, you can find some different scenario examples below:

Considering 94.89888561 USDT and 0.01575839 BNB in a user’s futures wallet and the user holds 0.01 BTCUSDT in the LONG position and -0.01 ETHUSDT in the SHORT position. If the user:

  1. transfers 0.01 BNB into the futures account.
  • Before upgrade
{
  "e": "ACCOUNT_UPDATE",
  "T": 1603093193280,
  "E": 1603093193284,
  "a": {
    "B": [
      {
        "a": "USDT",
        "wb": "94.91018561",
        "cw": "93.70831461"
      },
      {
        "a": "BNB",
        "wb": "0.02575839",
        "cw": "0"
      }
    ],
    "P": [
      {
        "s": "BTCUSDT",
        "pa": "0",
        "ep": "0.00000",
        "cr": "-147.28880096",
        "up": "0",
        "mt": "isolated",
        "iw": "0",
        "ps": "BOTH"
      },
      {
        "s": "BTCUSDT",
        "pa": "0.010",
        "ep": "11445.71000",
        "cr": "-23.20024001",
        "up": "0.17770",
        "mt": "isolated",
        "iw": "1.20187100",
        "ps": "LONG"
      },
      {
        "s": "BTCUSDT",
        "pa": "0",
        "ep": "0.00000",
        "cr": "-6.04296000",
        "up": "0",
        "mt": "isolated",
        "iw": "0",
        "ps": "SHORT"
      },
      {
        "s": "ETHUSDT",
        "pa": "0",
        "ep": "0.00000",
        "cr": "-0.00057000",
        "up": "0",
        "mt": "cross",
        "iw": "0",
        "ps": "BOTH"
      },
      {
        "s": "ETHUSDT",
        "pa": "0",
        "ep": "0.00000",
        "cr": "-385.79173997",
        "up": "0",
        "mt": "cross",
        "iw": "0",
        "ps": "LONG"
      },
      {
        "s": "ETHUSDT",
        "pa": "-0.010",
        "ep": "375.74000",
        "cr": "-0.19160000",
        "up": "0.00149",
        "mt": "cross",
        "iw": "0",
        "ps": "SHORT"
      }
    ],
    "m": "DEPOSIT"
  }
}
  • After upgrade
{
  "e":"ACCOUNT_UPDATE",
  "T":1603093193280,
  "E":1603093193284,
  "a":{
    "B":[
      // USDT is not pushed as there is not balance change
       {
        "a":"BNB", // BNB is pushed as the balance is updated.
        "wb":"0.02575839",
        "cw":"0"
      }    
    ],
    "P":[], // NO position data is pushed as there is no position change.
    "m":"DEPOSIT"
  }
}


  1. closes the ETHUSDT short position
  • Before upgrade
{
  "e":"ACCOUNT_UPDATE",
  "T":1603093588546,
  "E":1603093588553,
  "a":{
    "B":[
      {
        "a":"USDT",
        "wb":"94.91428561",
        "cw":"93.71241461"
      },
      {
        "a":"BNB",
        "wb":"0.02571331",
        "cw":"0"
      }
    ],
    "P":[
      {
        "s":"BTCUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-147.28880096",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"BOTH"
      },
      {
        "s":"BTCUSDT",
        "pa":"0.010",
        "ep":"11445.71000",
        "cr":"-23.20024001",
        "up":"0.13910",
        "mt":"isolated",
        "iw":"1.20187100",
        "ps":"LONG"
      },
      {
        "s":"BTCUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-6.04296000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"SHORT"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.00057000",
        "up":"0",
        "mt":"cross",
        "iw":"0",
        "ps":"BOTH"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-385.79173997",
        "up":"0",
        "mt":"cross",
        "iw":"0",
        "ps":"LONG"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.18750000",
        "up":"0",
        "mt":"cross",
        "iw":"0",
        "ps":"SHORT"
      }
    ],
    "m":"ORDER"
  }
}

  • After upgrade
{
  "e":"ACCOUNT_UPDATE",
  "T":1603093588546,
  "E":1603093588553,
  "a":{
    "B":[
      {
        "a":"USDT", // USDT is pushed because it's changed by realized PNL.
        "wb":"94.91428561",
        "cw":"93.71241461"
      },
      {
        "a":"BNB",  // BNB is pushed because it's changed by BNB trading free burn.
        "wb":"0.02571331",
        "cw":"0"
      }
    ],
    "P":[  // Only changed position of ETHUSDT is pushed.
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.00057000",
        "up":"0",
        "mt":"cross",
        "iw":"0",
        "ps":"BOTH" // BOTH position always be pushed.
      },
      // LONG position is not pushed because it's not initialised yet.
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.18750000",
        "up":"0",
        "mt":"cross",
        "iw":"0",
        "ps":"SHORT" // SHORT position is pushed as it's changed from this event.
      }
    ],
    "m":"ORDER"
  }
}


  1. changes ETHUSDT from CROSS to ISOLATED mode
  • Before upgrade
{
  "e":"ACCOUNT_UPDATE",
  "T":1603094890011,
  "E":1603094890017,
  "a":{
    "B":[
      {
        "a":"USDT",
        "wb":"94.90282656",
        "cw":"93.71241461"
      },
      {
        "a":"BNB",
        "wb":"0.02571331",
        "cw":"0"
      }
    ],
    "P":[
      {
        "s":"BTCUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-147.28880096",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"BOTH"
      },
      {
        "s":"BTCUSDT",
        "pa":"0.010",
        "ep":"11445.71000",
        "cr":"-23.20024001",
        "up":"0.03240",
        "mt":"isolated",
        "iw":"1.19041195",
        "ps":"LONG"
      },
      {
        "s":"BTCUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-6.04296000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"SHORT"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.00057000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"BOTH"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-385.79173997",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"LONG"
      },
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.18750000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"SHORT"
      }
    ],
    "m":"MARGIN_TYPE_CHANGE"
  }
}

  • After upgrade
{
  "e":"ACCOUNT_UPDATE",
  "T":1603094890011,
  "E":1603094890017,
  "a":{
    "B":[
      {
        "a":"USDT", // USDT is pushed because it's margin asset.
        "wb":"94.90282656",
        "cw":"93.71241461"
      }
    ],
    "P":[  // only ETHUSDT pushed as it has mode change ( CROSS to ISOLATED).
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.00057000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"BOTH" // BOTH position always be pushed.
      },
      // LONG position is not pushed because it's not initialised yet.
      {
        "s":"ETHUSDT",
        "pa":"0",
        "ep":"0.00000",
        "cr":"-0.18750000",
        "up":"0",
        "mt":"isolated",
        "iw":"0",
        "ps":"SHORT" // SHORT is pushed as it's been initialised.
      }
    ],
    "m":"MARGIN_TYPE_CHANGE"
  }
}
2 Likes

Q: When will this upgrade go on production?
A: ETA 2020-11-09.

Q: Will the testnet has the same upgrade?
A: Yes, It’s already live on testnet. https://testnet.binancefuture.com/en/futures/BTCUSDT

Q: Which futures will have the upgrade?
A: Both USDT-Ⓜ Futures and COIN-Ⓜ Futures will have this upgrade.

1 Like