Security candlesticks (price history)
The request cannot be executed anonymously. The required token
parameter must contain an up-to-date Access Token.
The request creates a subscription to receive historical price data (candlesticks) of a financial asset on the selected exchange for a specified period of time.
Request
To create a subscription to a data channel, send a message to the established WebSocket connection with a request body containing the details of the subscription to be created.
- Request body
- Schema
{
"opcode": "BarsGetAndSubscribe",
"code": "SBER",
"tf": "60",
"from": 1536557084,
"skipHistory": false,
"exchange": "MOEX",
"instrumentGroup": "TQBR",
"format": "Simple",
"frequency": 100,
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"token": "eyJhbGciOiJ..."
}
Request body parameters
OrderBookGetAndSubscribe
— Subscription to order bookBarsGetAndSubscribe
— Subscription to price history (candlesticks)QuotesSubscribe
— Subscription to quotesInstrumentsGetAndSubscribeV2
— Subscription to security information updates on the selected exchangeAllTradesGetAndSubscribe
— Subscribe to all tradesPositionsGetAndSubscribeV2
— Subscription to information about current positions on securities and moneySummariesGetAndSubscribeV2
— Subscription to portfolio summary informationRisksGetAndSubscribe
— Subscription to consolidated information on portfolio risksSpectraRisksGetAndSubscribe
— Subscription to information on derivatives market risks (FORTS)TradesGetAndSubscribeV2
— Subscription for information on tradesOrdersGetAndSubscribeV2
— Subscription to information about current orders on the market for the selected exchange and securityStopOrdersGetAndSubscribeV2
— Subscription to information about current conditional orders in the market for the selected exchange and securityunsubscribe
— Cancelation of previously created subscription15
— 15 seconds60
— 60 seconds or 1 minute3600
— 3600 seconds or 1 hourD
— 1 day (or 86400 seconds)W
— 1 week (or 604800 seconds)M
— 1 month (or 2592000 seconds)Y
— 1 year (or 31536000 seconds)true
— display only new datafalse
— display including historical dataMOEX
— Moscow ExchangeSPBX
— SPB Exchange- List of Moscow Exchange codes is available in table
- SPB Exchange securities always have
SPBX
code Simple
is the original data format. Supports legacy (deprecated) parameters to ensure backward compatibilitySlim
is the lightweight data format for fast messaging. Does not support legacy (deprecated) parametersHeavy
is the complete data format, evolving and augmented with new fields. Does not support legacy (deprecated) parametersSimple
— 25 millisecondsSlim
— 10 millisecondsHeavy
— 500 milliseconds.
Operation code:
Security code (ticker)
Example: SBER
Timeframe duration. You can specify the exact number of seconds or the timeframe code as the value:
Example: 60
Date and time (UTC) for the first requested candle
Example: 1536557084
Flag for filtering out historical data:
Example: false
Exchange code:
Example: MOEX
Trading mode code (Board):
Example: TQBR
The format of the JSON object returned by the server:
Example: Simple
Frequency (interval) of data transmission by the server. The server will return the latest data on request for the time interval specified as the parameter value. Example: the exchange transmits data every 2 ms, but if the parameter value is 10 ms, the server will return only the last value, discarding the previous ones.
Minimum value of the parameter depends on the selected format of the JSON object to be returned:
Example: 100
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Access Token
Example: eyJhbGciOiJ...
Responses
The content of the response returned to the WebSocket connection depends on the results of processing the request:
- If the request is processed successfully, the server will send one
200
code message in response, confirming that the subscription has been created, after which it will begin transmitting100
code messages containing the information requested as part of the subscription. - If the request processing failed, the server will send back one message with an error code corresponding to the reason for the failure, after which it will close the WebSocket connection.
- 100
- 200
- 401
Messages from the channel containing the requested information
- Simple
- Slim
- Heavy
- Response body
- Schema
{
"data": {
"time": 1537529040,
"close": 192.15,
"open": 192.18,
"high": 192.2,
"low": 192.15,
"volume": 1960
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
Time (UTC) (Unix time seconds)
Example: 1537529040
Closing price
Example: 192.15
Opening price
Example: 192.18
Maximum price
Example: 192.2
Minimal price
Example: 192.15
Volume
Example: 1960
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
- Response body
- Schema
{
"data": {
"t": 1537529040,
"c": 192.15,
"o": 192.18,
"h": 192.2,
"l": 192.15,
"v": 1960
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
Time (UTC) (Unix time seconds)
Example: 1537529040
Closing price
Example: 192.15
Opening price
Example: 192.18
Maximum price
Example: 192.2
Minimal price
Example: 192.15
Volume
Example: 1960
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
- Response body
- Schema
{
"data": {
"time": 1537529040,
"close": 192.15,
"open": 192.18,
"high": 192.2,
"low": 192.15,
"volume": 1960
},
"guid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
data
object
Requested data
Time (UTC) (Unix time seconds)
Example: 1537529040
Closing price
Example: 192.15
Opening price
Example: 192.18
Maximum price
Example: 192.2
Minimal price
Example: 192.15
Volume
Example: 1960
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Successful request processing report
- Body
- Schema
{
"message": "Handled successfully",
"httpCode": 200,
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813"
}
Response body parameters
Text description of the returned HTTP code
Example: Handled successfully
HTTP message code
Example: 200
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
Failed to process request. Access token is invalid, not specified in the message or belongs to other system environment
- Body
- Schema
{
"requestGuid": "c328fcf1-e495-408a-a0ed-e20f95d6b813",
"httpCode": 401,
"message": "Invalid JWT token!"
}
Response body parameters
The unique identifier of the operation. All incoming messages related to this operation will have this guid
field value
Example: c328fcf1-e495-408a-a0ed-e20f95d6b813
HTTP message code
Example: 401
Text description of the returned HTTP code
Example: Invalid JWT token!