Trades

Real-time streaming updates of completed trades.

Receive real-time streaming updates regarding completed trades in your account through the WebSocket API.

Subscription Instructions

Feed Name

private.user.trades

Authentication required. Please refer to the WebSocket Authentication page here for more details.

Message Payload Values

ValueDescription

trade_id

The ID of the trade

order_id

The ID of the order that this trade is associated with

date_updated

The date and time the trade was completed

action

Buy or Sell

currency_pair

The currency pair this trade was executed on

quantity

The base currency quantity bought or sold in this trade

amount

The gross quote currency amount cost or proceeds from this trade

price

The fill price of this trade

fees

The fees charged on this trade (always in the quote currency)

net_amount

The net quote currency amount cost or proceeds from this trade (amount net fees)

Example Code & Order Message

Message payload will contain a list of one or more trade objects, each representing a unique, completed trade.

const WebSocket = require('ws')

const ws = new WebSocket('wss://ws.sfox.com/ws')

ws.on('open', function() {
  const authMessage = {
   type: 'authenticate',
   apiKey: '<API_KEY>'
  }
  
  ws.send(JSON.stringify(authMessage))
})

// After successful authentication, subscribe to trades feed
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['private.user.trades']
}

ws.send(JSON.stringify(subscribeMsg))

Last updated