How to use the bfx-api-node-models.PublicTrade.unserialize function in bfx-api-node-models

To help you get started, we’ve selected a few bfx-api-node-models examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitfinexcom / bitfinex-api-node / lib / transports / ws2.js View on Github external
_handleTradeMessage (msg, chanData) {
    const eventName = msg[1] === 'te' ? 'trade-entry' : 'trades'
    let payload = getMessagePayload(msg)

    if (!Array.isArray(payload[0])) {
      payload = [payload]
    }

    const data = this._transform ? PublicTrade.unserialize(payload) : payload
    const internalMessage = [chanData.chanId, eventName, data]
    internalMessage.filterOverride = [chanData.symbol]

    this._propagateMessageToListeners(internalMessage, chanData, false)
    this.emit('trades', chanData.pair, data)
  }