sFOX API
Sign InOpen Account
Connect API
Connect API
  • Introduction
    • Welcome
    • Getting Started
    • Resources
      • Terminology
      • Systems & Operations
      • Integration Options
    • Guides
      • End User Onboarding & KYC
        • Individuals
        • Businesses
        • Enhanced Due Diligence
  • REST API
    • REST Endpoints
    • Authentication
    • End Users
      • Create End User Account
      • Request Verification Code
      • Confirm Verification Code
      • Create User Auth Token(s)
      • Get End User(s)
      • Get EDD Requests
      • Get EDD Prompts
      • Create EDD Responses
        • Uploading Files as Responses
      • Submit Documents
      • Deactivate User
    • Payments
      • Create Bank Account (Plaid)
      • Create Bank Account
      • Get Bank Account
      • Get Plaid Processors
      • Amend Plaid Processors
      • Verify Bank Account
      • Delete Bank Account
      • Get Wire Instructions
      • Get ACH Agreement Status
      • Request ACH Onboarding
      • Get ACH Deposit Limit
    • Withdrawals
      • Confirm Withdrawal
      • Resend Confirmation Code
      • Cancel Withdrawal
    • Transfers
      • Create Transfer
      • Confirm Transfer
      • Resend Confirmation Code
      • Cancel Transfer
      • Get Transfer Permissions
      • Get Transfer History
    • Monetization
      • Create Setting
      • Update Setting
      • Delete Setting
      • Get Settings
      • Get Permissions
      • Get Monetization History
  • WebSocket API
    • Connecting
    • Authentication
    • Subscribing & Unsubscribing
    • Message Format
    • End Users
      • Onboarding
      • Balances
      • Orders
      • Trades
    • Market Data
      • Order Book
      • Trades
      • Ticker
  • Single Sign-On
    • Overview
      • IdP Initiated SSO
    • IdP Data
    • SAML Response Data
  • Errors
    • Error Codes
Powered by GitBook
  1. WebSocket API
  2. End Users

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))
import asyncio
import json
import websockets
import os

async def main(uri):
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "type": "authenticate",
            "apiKey": f"{os.environ['ENTERPRISE_API_KEY']}",
            "enterprise": "true"
        }))

        # After successful authentication message, subscribe to the users feed
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": ["private.enterprise.users"]
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
{
    "sequence": 22,
    "recipient": "private.enterprise.users.trades",
    "timestamp": 1710367225302228171,
    "payload": {
        "user_id": "test3",                        //Unique shared ID you generated for the End User account
        "updates": [
            {
                "trade_id": 830151520,
                "order_id": 759514460,
                "date_updated": "2024-02-22T19:28:06.000Z",
                "action": "Sell",
                "currency_pair": "compusd",
                "quantity": "1.65911629",
                "amount": "99.47066469",
                "price": "59.954004",
                "fees": "0.04973533",
                "net_amount": "99.42092936"
            }
        ]
    }
}

PreviousOrdersNextMarket Data

Last updated 11 months ago