Trades

This channel sends a trade message whenever a trade occurs at Bitfinex. It includes all the pertinent details of the trade, such as price, size and the time of execution. The channel can send funding trade data as well.

const ws = require('ws')
const w = new ws('wss://api-pub.bitfinex.com/ws/2')

w.on('message', (msg) => console.log(msg))

let msg = JSON.stringify({ 
  event: 'subscribe', 
  channel: 'trades', 
  symbol: 'tBTCUSD' 
})

w.on('open', () => w.send(msg))
wscat -c wss://api-pub.bitfinex.com/ws/2
{ "event": "subscribe",  "channel": "trades",  "symbol": "tBTCUSD" }
ws = websocket.WebSocketApp('wss://api-pub.bitfinex.com/ws/2')

ws.on_open = lambda self: self.send('{ "event": "subscribe", "channel": "trades", "symbol": "tBTCUSD"}')

ws.on_message = lambda self, evt:  print (evt)
// request
{ 
  event: "subscribe", 
  channel: "trades", 
  symbol: SYMBOL 
}

// response Trading
{
  event: "subscribed",
  channel: "trades",
  chanId: CHANNEL_ID,
  symbol: "tBTCUSD"
  pair: "BTCUSD"
}

{"event":"subscribed","channel":"trades","chanId":19111,"symbol":"tBTCUSD","pair":"BTCUSD"}

// response Funding
{
  event: "subscribed",
  channel: "trades",
  chanId: CHANNEL_ID,
  symbol: "fUSD"
}

{"event":"subscribed","channel":"trades","chanId":339521,"symbol":"fUSD","currency":"USD"}
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    [
      ID,
      MTS,
      AMOUNT,
      PRICE
    ],
    ...
  ]
]

[17470,[[401597393,1574694475039,0.005,7244.9],[401597392,1574694470503,-0.01,7245.3]]]  

// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    [
      ID,
      MTS,
      AMOUNT,
      RATE,
      PERIOD
    ],
    ...
  ]
]
  
[339521,[[133323072,1574694245478,-258.7458086,0.0002587,2],[133323071,1574694245368,-1932.20263916,0.0002587,2]]]
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  <"te", "tu">,
  [
    ID,
    MTS,
    AMOUNT,
    PRICE
  ]
]

[17470,"te",[401597395,1574694478808,0.005,7245.3]]
[17470,"tu",[401597395,1574694478808,0.005,7245.3]]

// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  <"fte", "ftu">,
  [
    ID,
    MTS,
    AMOUNT,
    RATE,
    PERIOD
  ]
]

[337371,"fte",[133323543,1574694605000,-59.84,0.00023647,2]]
[337371,"ftu",[133323543,1574694605000,-59.84,0.00023647,2]]

Request Fields

FieldsTypeDescription
SYMBOLStringTrading pair or funding currency

Stream Fields

FieldsTypeDescription
CHANNEL_IDintIdentification number assigned to the channel for the duration of this connection.
IDintTrade ID
MTSintmillisecond time stamp
±AMOUNTfloatAmount bought (positive) or sold (negative).
PRICEfloatPrice at which the trade was executed
RATEfloatFunding rate of the trade
PERIODintFunding offer period in days

The order that causes the trade (the taker) determines if it is a buy or a sell.