MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / userDataHandler

Method userDataHandler

src/node-binance-api.ts:3011–3042  ·  view source on GitHub ↗

* Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined}

(data: any)

Source from the content-addressed store, hash-verified

3009 * @return {undefined}
3010 */
3011 userDataHandler(data: any) {
3012 let eventData = data;
3013 if (data.subscriptionId !== undefined && data.event) {
3014 eventData = data.event;
3015 }
3016
3017 const type = eventData.e;
3018
3019 // Handle event stream termination
3020 if (type === 'eventStreamTerminated') {
3021 this.Options.log('User Data Stream terminated at ' + eventData.E);
3022 if (this.Options.all_updates_callback) this.Options.all_updates_callback(eventData);
3023 return;
3024 }
3025
3026 if (this.Options.all_updates_callback) this.Options.all_updates_callback(eventData);
3027
3028 if (type === 'outboundAccountInfo') {
3029 // XXX: Deprecated in 2020-09-08
3030 } else if (type === 'executionReport') {
3031 if (this.Options.execution_callback) this.Options.execution_callback(eventData);
3032 } else if (type === 'listStatus') {
3033 if (this.Options.list_status_callback) this.Options.list_status_callback(eventData);
3034 } else if (type === 'outboundAccountPosition' || type === 'balanceUpdate') {
3035 if (this.Options.balance_callback) this.Options.balance_callback(eventData);
3036 } else if (type === 'externalLockUpdate') {
3037 // Handle external lock updates (e.g., when balance is locked for margin collateral)
3038 if (this.Options.balance_callback) this.Options.balance_callback(eventData);
3039 } else {
3040 this.Options.log('Unexpected userData: ' + type);
3041 }
3042 }
3043
3044 /**
3045 * Used as part of the user data websockets callback

Callers 1

Calls 1

logMethod · 0.80

Tested by

no test coverage detected