Futures

This document outlines establishing and maintaining a WebSocket connection for Futures trading using Token-based or API Key-based authentication. The message format is identical for both connection types.

Token-based Connection

1. Overview

  • The client includes a token in the request header.

  • After a successful connection, a subscription message must be sent.

  • Only after successful subscription will the client begin receiving push notifications.

2. Connection Details

  • Request URL:

    wss://futuresws.coinlocally.com/position_order/ws

3. Request Headers

Parameter Name
Type
Required
Description

token

string

Yes

Token generated after login

4. Subscription Message Format

{
  "event": "sub",
  "token": "<your_token>",
  "broker": 1003
}

API Key-based Connection

1. Overview

  • The client includes an apiKey in the request header.

  • After a successful connection, a subscription message must be sent.

  • Only after successful subscription will the client begin receiving push notifications.

2. Connection Details

  • Request URL:

3. Request Headers

Parameter Name
Type
Required
Description

apiKey

string

Yes

User's API key

4. Subscription Message Format

Receiving Messages

1. Connection Responses

  • Connect Success: "connect success"

  • Subscribe Success: "sub success"

2. Message Format

  • Messages are GZIP-compressed binary data.

  • Use a GZIP decompression tool in your language of choice.

Example (Base64 Encoded):

Parsed Result:

Message Field Descriptions

1. Position & Account Updates

2. ADL Price Push (every second if the user holds the position)

3. System Shutdown

4. Regular Order Updates

5. Trigger Order Updates

Heartbeat

  • Send every 30 seconds:

  • Server response:

  • If no ping is received in 40 seconds, the server will disconnect.

Last updated