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
  • Ticker Message
  • Example Code & Ticker Message
  1. WebSocket API
  2. Market Data

Ticker

Receive aggregated 24-hour OHLCV data from all supported exchanges and the last price before each update every 3 seconds. Subscriptions to the ticker feed will receive real-time trades that occur on any of the exchanges that are active on the sFOX platform.

Subscribing

Feed

ticker.sfox.<basequote>

Example

ticker.sfox.btcusd

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

Ticker Message

Ticker Object

Key
Description

amount

Quantity of the most recent trade on this pair

exchange

Location of the most recent trade on this pair

last

Price of the most recent trade on this pair

high

High price since 00:00:00 GMT

low

Low price since 00:00:00 GMT

open

Open price at 00:00:00 GMT

pair

Currency pair

source

Data source

timestamp

Time of the trade

volume

Volume traded since 00:00:00 GMT (base currency)

vwap

Volume-weighted average price since 00:00:00 GMT

Ticker Message

// Ticker feed message
{
  "sequence": 4,
  "recipient": "ticker.sfox.btcusd",
  "timestamp": 1649901842979345289,
  "payload": {
    "amount": 0.00005737,
    "exchange": "coinbase",
    "high": 41512.43,
    "last": 41420.58,
    "low": 41058.82,
    "open": 41141.31,
    "pair": "btcusd",
    "route": "Smart",
    "source": "ticker-info",
    "timestamp": "2022-04-14T02:04:02.481Z",
    "volume": 1387.77211046,
    "vwap": 41283.96339697249
  }
}

Example Code & Ticker Message

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: ['ticker.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": [
                "ticker.sfox.btcusd",
            ],
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
PreviousTradesNextOrders & Account Data

Last updated 7 months ago