* Used as part of the user data websockets callback * @param {object} data - user data callback data type * @return {undefined}
(data: any)
| 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 |
no test coverage detected