Exchange
Blockchain and crypto asset exchange
Academy
Blockchain and crypto education
Broker
Trading terminal solutions
Charity
Blockchain charity foundation
Cloud
Enterprise exchange solutions
DEX
Fast and secure decentralized digital asset exchange
Labs
Incubator for top blockchain projects
Launchpad
Token Launch Platform
Research
Institutional-grade analysis and reports
Trust Wallet
Binance's official crypto wallet
Buy Crypto
Markets
App StoreGoogle PlayAndroid
Scan to Download
Desktop
English/USD
Support Center
FAQ
Crypto Derivatives
Futures Contracts
Trading Rules
USDT-Margined Futures API Websocket User Data Stream Upgrade
Binance
2020-10-21 03:20
WEB SOCKET USER DATA STREAM
Important note: Binance Futures will conduct an upgrade to optimize the User Data Stream Websocket of USDT-margined futures contract API to provide a better service for our users. The upgrade is estimated to complete on 2020/11/09.

Please notice: new streamlined and optimized push rules on event ACCOUNT_UPDATE in USER-DATA-STREAM
1. When an asset of a user is changed:
  • Only this asset and its balance information will be pushed
  • Other assets and information will no longer be pushed even the balances may not be 0
  • If the asset change does not come with any position change, the position "P" will only return an empty []
2. When a position of a symbol is changed or the margin type of a symbol is changed:
  • "P" will push the details in the "BOTH" position of this symbol
  • If the change happens in "LONG" or "SHORT" position, the changed "LONG" or "SHORT" position of this symbol will be pushed
  • Initialized "LONG" or "SHORT" isolated position of this symbol will also be pushed
  • Position information of other symbols will no longer be pushed, even their positions may not be 0
3. In short, the full information of assets and positions should be obtained via the related rest endpoints(GET /fapi/v2/account and GET /fapi/v2/positionRisk), and the locally cached asset or position data can be updated via the event ACCOUNT_UPDATE in Websocket USER-DATA-STREAM with the information of changed asset or position.
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 upgradeAfter 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"
}
}
{
"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"
}
}
2. closes the ETHUSDT short position
Before upgradeAfter 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"
}
}
{
"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"
}
}
3. changes ETHUSDT from CROSS to ISOLATED mode
Before upgradeAfter 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"
}
}
{
"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"
}
}

Have more questions?submit a request
Related Articles
Futures API Trading Quantitative Rules