sFOX API
Sign InOpen Account
sFOX API
sFOX API
  • Introduction
    • Welcome
    • Getting Started
    • Systems & Operations
    • Rate Limits
  • REST API
    • REST Endpoints
    • Authentication
    • Rate Limits
    • Account Management
      • Get All Balances
      • Get All Currencies
      • Get All Currency Pairs
      • Get All Transactions
      • Get Fees
    • Orders
      • Order Types
      • Create Order
      • Cancel Order
      • Cancel Multiple Orders
      • Cancel All Orders
      • Amend Order
      • Get Single Order
      • Get All Open Orders
      • Get All Done Orders
      • Get All Trades
    • Request for Quote (RFQ)
    • Post-Trade Settlement (PTS)
      • Get Account Risk Metrics
      • Get All Positions
      • Get All Funding Transactions
      • Get All Funding Rates
      • Get All Risk Modes
      • Create Transfer
    • Shorting
      • Get Account Risk Metrics
      • Get All Positions
    • Transfers
      • Get All Deposit Addresses
      • Get Single Deposit Address
      • Create Deposit Address
      • Deposit From Bank Account
      • Withdraw From Account
      • Get Single Withdrawal Fee
      • Create Transfer
    • Custody (sFOX SAFE)
      • Get Whitelisted Addresses
      • Add Whitelisted Address
      • Delete Whitelisted Address
      • Get Approval Rules
      • Create Approval Rule
      • Edit Approval Rule
      • Get Approval Requests
      • Respond to Approval Request
    • Staking
      • Get Staking Currencies
      • Get All Staking Transactions
      • Create Stake
      • Cancel Stake
      • Unstake
    • Market Data
      • Get Candlesticks
      • Get Volume Analytics
      • Get Order Estimate
      • Get Order Book
    • Reporting
      • Get Orders Report
      • Get Monthly Summary
      • Get Portfolio Valuation
      • Get All Transactions
  • WebSocket API
    • Introduction
    • Connecting
    • Rate Limits
    • Authentication
    • Subscribing & Unsubscribing
    • Message Format
    • Market Data
      • Order Book
      • Trades
      • Ticker
    • Orders & Account Data
      • Orders
      • Trades
      • Balances
      • Post-Trade Settlement
  • FIX API
    • FIX Order Entry
    • FIX Market Data
    • QuickFIX Guide
  • Errors
    • Error Codes
Powered by GitBook
On this page
  • Subscribing
  • Trades Message
  • Example Code
  1. WebSocket API
  2. Market Data

Trades

Real-time tick data feed of any trade executed across all of sFOX’s integrated liquidity providers. Please note that this feed does not only represent trades executed on sFOX.

Subscribing

Feed

trades.sfox.<basequote>

Example

trades.sfox.btcusd

// Request -> orders feed
{
    "type": "subscribe", 
    "feeds": ["trades.sfox.btcusd"]
}

Trades Message

Trades Object

Key
Description

buyOrderId

Order ID of the buy trade

sellOrderId

Order ID of the sell trade

pair

The currency pair of this trade

price

Price of this trade

quantity

Quantity traded

side

Side taken buy or sell

exchange

Location of the trade

exchange_id

ID of the trade location

timestamp

Time of the trade

Trades Message

// Trades feed message
{
  "sequence": 24,
  "recipient": "trades.sfox.btcusd",
  "timestamp": 1649901441593380244,
  "payload": {
    "id": "1062696823",
    "quantity": "0.005",
    "price": "41492",
    "exchange": "bitfinex",
    "exchange_id": 2,
    "side": "buy",
    "pair": "btcusd",
    "pair_id": 1,
    "timestamp": "2022-04-14T01:57:21.521999872Z",
    "timeStamp": "2022-04-14T01:57:21.521",
    "buyOrderId": "",
    "sellOrderId": "",
    "is_decimal": true
  }
}

Example Code

const WebSocket = require('ws')

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

ws.on('message', function(data) {
    console.log(data);
});

ws.on('open', function() {
  const subscribeMsg = {
    type: 'subscribe',
    feeds: ['trades.sfox.btcusd']
  }
  ws.send(JSON.stringify(subscribeMsg));
});
import asyncio
import json

import websockets


async def main(uri):
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": [
                "trades.sfox.btcusd",
            ],
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
PreviousOrder BookNextTicker

Last updated 7 months ago