You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: providers/websockets/README.md
+1
Original file line number
Diff line number
Diff line change
@@ -11,4 +11,5 @@ Web sockets are preferred over HTTP APIs for real-time data as they only require
11
11
The current set of supported providers are:
12
12
13
13
*[Crypto.com](./cryptodotcom/README.md) - Crypto.com is a cryptocurrency exchange that provides a free API for fetching cryptocurrency data. Crypto.com is a **primary data source** for the oracle.
14
+
*[OKX](./okx/README.md) - OKX is a cryptocurrency exchange that provides a free API for fetching cryptocurrency data. OKX is a **primary data source** for the oracle.
The OKX provider is used to fetch the ticker price from the [OKX web socket API](https://www.okx.com/docs-v5/en/#overview-websocket-overview). The web socket request size for data transmission between the client and server is only 2 bytes. The total number of requests to subscribe to new markets is limited to 3 requests per second. The total number of 'subscribe'/'unsubscribe'/'login' requests per connection is limited to 480 times per hour. WebSocket login and subscription rate limits are based on connection.
6
+
7
+
Connections will break automatically if the subscription is not established or data has not been pushed for more than 30 seconds. [Per OKX documentation](https://www.okx.com/docs-v5/en/#overview-websocket-overview),
8
+
9
+
```text
10
+
If there’s a network problem, the system will automatically disable the connection.
11
+
12
+
The connection will break automatically if the subscription is not established or data has not been pushed for more than 30 seconds.
13
+
14
+
To keep the connection stable:
15
+
16
+
1. Set a timer of N seconds whenever a response message is received, where N is less than 30.
17
+
2. If the timer is triggered, which means that no new message is received within N seconds, send the String 'ping'.
18
+
3. Expect a 'pong' as a response. If the response message is not received within N seconds, please raise an error or reconnect.
19
+
```
20
+
21
+
OKX provides [public and private channels](https://www.okx.com/docs-v5/en/?shell#overview-websocket-subscribe).
22
+
23
+
* Public channels -- No authentication is required, include tickers channel, K-Line channel, limit price channel, order book channel, and mark price channel etc.
24
+
* Private channels -- including account channel, order channel, and position channel, etc -- require log in.
25
+
26
+
Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 64 KB. This provider is implemented assuming that the user is only subscribing to public channels.
27
+
28
+
The exact channel that is used to subscribe to the ticker price is the [`Index Tickers Channel`](https://www.okx.com/docs-v5/en/?shell#public-data-websocket-index-tickers-channel). This pushes data every 100ms if there are any price updates, otherwise it will push updates once a minute.
29
+
30
+
To retrieve all of the supported [spot markets](https://www.okx.com/docs-v5/en/?shell#public-data-rest-api-get-instruments), please run the following command:
0 commit comments