Paxos WebSocket Documentation V2 Streaming Market Data and Execution Data

Introduction

Paxos offers industry-standard streaming market data and execution data over Websockets.  Advanced users will be able to construct the state of the order book and stream executed orders in real-time as the connection will feed updates from the OMS to the stream once the events occur. 

 

Streaming Market Data

Connection Details

Paxos allows unauthenticated connections to websocket marketdata. All connections are secured ("wss://"). Each connection will stream information for all markets, or for the single market specified in a path parameter.

 

ENV

Type

URL

Production

All Markets

wss://ws.paxos.com/marketdata

Production

Single Market

wss://ws.paxos.com/marketdata/{market}

Sandbox

All Markets

wss://ws.sandbox.paxos.com/marketdata

Sandbox

Single Market

wss://ws.sandbox.paxos.com/marketdata/{market}

 

Possible Markets: “BTCUSD”, “BTCEUR”, “BTCSGD”, “ETHUSD”, “ETHEUR”, “ETHSGD”, “PAXGUSD”, “BCHUSD”, “LTCUSD”, “LINKUSD”, “MATICUSD”, “AAVEUSD”, “UNIUSD”

Note: Market data has a built-in instantaneous failover. Clients should have a reconnection mechanism in case of server disconnection. 

Message Body

You will receive a snapshot of the current order book state for each requested market, followed by updates. 

Initial Book Snapshot Message

After completing the websocket handshake you will receive a SNAPSHOT of the current order book state in a single message. Prices are in descending order for bids and ascending order for asks. Each price-and-amount pair represents a level of the book.

Example Initial Book Snapshot Message:

{
"type": "SNAPSHOT",
"market": "BTCUSD",
"bids": [{"price": "9245.75", "amount": "1.12341002"}, ...],
"asks": [{"price": "9248.00", "amount": "0.87140241"}, ...],
"final_snapshot": "true"
}

When streaming data for all markets, you will receive a SNAPSHOT message for each market, differentiated by the "market" field. 

The "final_snapshot" field indicates the last snapshot message has been received and all future messages will be in UPDATE message format.

Update Message

After the initial book SNAPSHOT messages, you will receive a stream of UPDATE messages which remove, add or update a price level in the order book of a particular market.

When streaming data for all markets, you should differentiate the per-market updates using the "market" field.

Example Update Message

{
"type": "UPDATE",
"market": "BTCUSD",
"side": "SELL",
"price": "9250.00",
"amount": "0.13141000"
}

Processing Update Messages

You can maintain your own up-to-date copy of an order book by processing update messages according to the following rules:

  • If "side" is "BUY":
    • If "amount" is "0":
      • Remove the existing entry with price "price" from the bids list.
    • If an entry with price "price" is already in the bids list:
      • Update the amount for that entry in the bids list to "amount".
    • If no entry with price "price" is in the bids list:
      • Add an entry with price "price" and amount "amount" to the bids list.
  • If "side" is "SELL":
    • Perform the same logic as for "BUY", but on the asks list.

Streaming Execution Data

Connection Details

Paxos allows unauthenticated connections to websocket execution data via secured ("wss://") connections. Each connection streams information for all markets, or for the single market specified as a path parameter.

ENV

Type

URL

Production

All Markets

wss://ws.paxos.com/executiondata

Production

Single Market

wss://ws.paxos.com/executiondata/{market}

Sandbox

All Markets

wss://ws.sandbox.paxos.com/executiondata

Sandbox

Single Market

wss://ws.sandbox.paxos.com/executiondata/{market}

 

Possible Markets: “BTCUSD”, “BTCEUR”, “BTCSGD”, “ETHUSD”, “ETHEUR”, “ETHSGD”, “PAXGUSD”, “BCHUSD”, “LTCUSD”, “LINKUSD”, “MATICUSD”, “AAVEUSD”, “UNIUSD”

Note: Execution data has a built-in instantaneous failover. Clients should have a re-connection mechanism in case of server disconnection. 

 

Message Body

Upon connection, you will start to receive messages for each market execution (based on the use of the market parameter). The first message corresponds to the last execution for the market at the point of the connection after that, each new message represents a new execution.

If there are no executions for longer periods of time for a particular market upon connection you may not receive any message until a new execution is made.

Note: Upon reconnection you will receive the last execution for the market, in which case clients should handle duplicate messages. You may use a match number as an idempotent field.

 

Example Execution Message

{
 "market": "ETHUSD",
 "price": "200.5",
 "amount": "0.5",
 "executed_at": "2020-10-08T13:16:56Z",
 "match_number": "5USVVYRL82P3"
}

 

Websocket Limits

WebSockets market and execution data services have a rate limit of average five subscription requests per IP per second during a two-second window, or average three subscription requests per second during a five-minute window.

Websocket Best Practices

Paxos recommends Crypto Brokerage partners implement a single WSS connection at the server level (multiplexing), as multiple connections can create logistical and update issues without providing appreciable performance gains. To support integration and platform stability and maintenance, each implementation should:

  • Ensure all application clients can easily rollout platform updates to users through a single mechanism.
  • Have a centralized reconnection mechanism to recover from any feed disruptions.

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful