Trades

Receive real-time streaming updates regarding completed trades across your users' accounts.

An update from this feed will include the user_id of the user to identify which user's account the update is for as well as the information for 1 or more trades that have completed in the account.

Subscription Instructions

Feed Name

private.enterprise.users.trades

Value
Description

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

const WebSocket = require('ws')

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

ws.on('open', function() {
  const authMessage = {
   type: 'authenticate',
   apiKey: `${process.env.ENTERPRISE_API_KEY}`,
   enterprise: 'true'
  }
  
  ws.send(JSON.stringify(authMessage))
})

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

ws.send(JSON.stringify(subscribeMsg))

Last updated