Skip to content

Invalid API Key on cancel orders #3

@NeilDuToit92

Description

@NeilDuToit92

I am trying to set up a function to cancel all orders as follows, I have API key and secret that has full access to my account, which is configured on my Node-Red, but I get an auth failed error when I try to run it.

Maybe I am doing something wrong, if I am, it would be nice to have an example of what it should look like.

Bitfinex function node:

const ws = bfx.ws(2)

ws.on('error', (err) => console.log(err))
ws.on('open', ws.auth.bind(ws))

ws.onOrderSnapshot({}, (orders) => {
  if (orders.length === 0) {
    console.log('no open orders')
    return
  }

  console.log('recv ${orders.length} open orders')

  ws.cancelOrders(orders).then(() => {
    console.log('cancelled orders')
  })
})

ws.open()

Error:

Error: auth failed: apikey: invalid (FAILED)
    at WSv2._handleAuthEvent (/config/node-red/node_modules/bitfinex-api-node/lib/transports/ws2.js:1114:19)
    at WSv2._handleEventMessage (/config/node-red/node_modules/bitfinex-api-node/lib/transports/ws2.js:1042:19)
    at WSv2._onWSMessage (/config/node-red/node_modules/bitfinex-api-node/lib/transports/ws2.js:590:12)
    at WebSocket.emit (events.js:315:20)
    at Receiver._receiver.onmessage (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/WebSocket.js:141:47)
    at Receiver.dataMessage (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/Receiver.js:389:14)
    at Receiver.getData (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/Receiver.js:330:12)
    at Receiver.startLoop (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/Receiver.js:165:16)
    at Receiver.add (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/Receiver.js:139:10)
    at TLSSocket.<anonymous> (/config/node-red/node_modules/bitfinex-api-node/node_modules/ws/lib/WebSocket.js:138:22)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at TLSSocket.Readable.push (_stream_readable.js:212:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions