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

Orders

The open orders feed tracks updates to all of your users' open orders.

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 latest information for 1 or more open orders in the account.

Subscription Instructions

Feed Name

private.enterprise.users.open-orders

Order Object

Order updates received will include the following object per order:

Field
Type
Description

id

int

sFOX-generated order ID, assigned on order creation.

action

string

Order side. Possible values: buy (buy order), sell (sell order)

algorithm_id

int

type

string

pair

string

Pair or product in the format basequote . e.g. btcusd, ethbtc, ethusdc

quantity

number

Order size in base currency quantity.

price

number

Order limit price.

amount

number

Amount (quote currency) to spend when buying.

net_market_amount

number

amount net fees for Market (100) orders.

filled

number

Unsigned, cumulative base currency quantity filled.

vwap

number

Cumulative volume-weighted average fill price of the order.

filled_amount

number

Unsigned, cumulative quote currency amount filled.

fees

number

Unsigned, cumulative quote currency fee amount accrued to this order.

net_proceeds

number

Signed, cumulative quote currency proceeds amount net fees.

status

string

routing_option

string

Special order routing instructions.

routing_type

string

Order routing type.

time_in_force

string

Order time in force specified at order creation.

expires

datetime

Expiration date of the order (for time_in_force = GTD orders)

dateupdated

datetime

Date of the most recent update to this order.

date_added

datetime

Date the order was created.

client_order_id

string

User-specified ID for this order.

algorithm_options

string[]

Additional object specifying special order parameters.

destination

string

Order destination.

Order Statuses

Orders may have any of the following statuses.

Status
Status Code
Description

Started

100

  • The order is open and active

  • Filled quantity may be >= 0

  • Filled quantity is < the order quantity

Cancel Pending

90

  • The order is in the process of being canceled but cancellation has not been completed

  • The order may still receive fills

Canceled

10

  • The order was successfully canceled

  • Order may have been partially filled prior to cancellation

Filled

210

  • The order has fully filled

  • The order has not yet settled

Done

300

  • The order was is completed, no longer active, and settled successfully

  • Filled quantity = order quantity

  • The order will not receive new fills

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 user open orders feed
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['private.enterprise.users.open-orders']
}

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 open orders feed
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": ["private.enterprise.users.open-orders"]
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
{
    "sequence": 22,
    "recipient": "private.enterprise.users.open-orders",
    "timestamp": 1710367225302228171,
    "payload": {
        "user_id": "test3",                        //Unique shared ID you generated for the End User account
        "updates": [
            {
                    "id": 693291242,
                    "client_order_id": "577ab261-9dfc-415a-ba61-a54a18c1942c",
                    "date_added": "2023-11-14T22:08:53.000Z",
                    "status": "Started",
                    "filled": "0.00035333",
                    "filled_amount": "14.61628778",
                    "vwap": "41367.24246455",
                    "price": "37227.82",
                    "quantity": "0.05",
                    "pair": "btcusd",
                    "action": "Sell",
                    "type": "TWAP",
                    "algorithm_id": 307,
                    "fees": "0.02850176"
            }
        ]
    }
}

PreviousBalancesNextTrades

Last updated 11 months ago

Order type / algorithm ID. Possible values: .

Order type / algorithm name. Possible values: .

Status name. Possible values: .

Order Types & Algorithms
Order Types & Algorithms
Order Statuses