Looking for:
Zerodha kite api docs -Zerodha kite api docs -
The WebSocket API is the most efficient speed, latency, resource consumption, and bandwidth way to receive quotes for instruments across all exchanges during live market hours. In addition, the text messages, alerts, and order updates the same as the ones available as Postbacks are also streamed.
You can subscribe for up to instruments on a single WebSocket connection and receive live quotes for them. Single API key can have upto 3 websocket connections. Implementing an asynchronous WebSocket client with a binary parser for the market data structure may be a complex task.
We recommend using one of our pre-built client libraries. Requests are simple JSON messages with two parameters, a action and v value. Following are the available actions and possible values. Always check the type of an incoming WebSocket messages. Market data is always binary and Postbacks and other updates are always text. Quotes delivered via the API are always binary messages. These have to be read as bytes and then type-casted into appropriate quote data structures.
Each binary message array of 0 to n individual bytes --or frame in WebSocket terminology--received via the WebSocket is a combination of one or more quote packets for one or more instruments.
The message structure is as follows. Each individual packet extracted from the message, based on the structure shown in the previous section, can be cast into a data structure as follows. All prices are in paise. For currencies, the int32 price values should be divided by to obtain four decimal plaes. For everything else, the price values should be divided by They have fewer fields.
Each market depth entry is a combination of 3 fields, quantity int32 , price int32 , orders int16 and there is a 2 byte padding at the end which should be skipped totalling to 12 bytes. There are ten entries in succession—five [ 64 - ] bid entries and five [ - ] offer entries.
Apart from binary market data, the WebSocket stream delivers postbacks and other updates in the text mode. These messages are JSON encoded and should be parsed on receipt.
For order Postbacks, the payload is contained in the data key and has the same structure described in the Postbacks section. Skip to content. Table of contents Connecting to the WebSocket endpoint Request structure Modes Binary market data Message structure Quote packet structure Index packet structure Market depth structure Postbacks and non-binary updates Message types. If there is no data to be streamed over an open WebSocket connection, the API will send a 1 byte "heartbeat" every couple seconds to keep the connection alive.
This can be safely ignored. The next two bytes [2 - 4] -- SHORT or int16 represent the length number of bytes of the first packet. Order Postback. The data field will contain the full order Postback payload. Messages and alerts from the broker. The data field will contain the message string.
No comments:
Post a Comment