OHLCV
What is this endpoint for?
This Stream delivers the OHLCV for an instrument on an exchange in real-time.
Endpoints
gateway-v0-grpc.kaiko.ovh
Request parameters
aggregate
The period you would like the OHLCV aggregation to be calculated over.
1m
instrumentCriteria
A nested object to configure following properties for your stream:
exchange
(String) - The code(s) for the exchange(s)instrument_class
(String) - The class(es) of the instrument(s) .code (String) -
The Kaiko code for the instrument.
Explore instruments, codes and exchanges in the Instrument Explorer or Reference Data.
cbse
spot
btc-usd
Response fields
aggregate
The period of calculation.
class
The class of instrument.
close
Closing price of interval. null
when no trades reported.
exchange
The exchange the OHLCV is referencing.
high
Closing price of interval. null
when no trades reported.
low
Lowest price during interval. null
when no trades reported.
open
Opening price of interval. null
when no trades reported.
code
The instrument code.
timestamp
The timestamp for the interval.
uid
The unique ID for this delivery.
volume
Volume traded in interval. 0 when no trades reported.
sequenceId
Not applicable. Null
Request examples
# This is a code example. Configure your parameters below #
# Last update - 2025-06-26 #
from __future__ import print_function
from datetime import datetime, timedelta
import logging
import os
from google.protobuf.timestamp_pb2 import Timestamp
import grpc
from google.protobuf.json_format import MessageToJson
from kaikosdk import sdk_pb2_grpc
from kaikosdk.core import instrument_criteria_pb2
from kaikosdk.stream.aggregates_ohlcv_v1 import request_pb2 as pb_ohlcv
def ohlcv_request(channel: grpc.Channel):
try:
with channel:
stub = sdk_pb2_grpc.StreamAggregatesOHLCVServiceV1Stub(channel)
responses = stub.Subscribe(pb_ohlcv.StreamAggregatesOHLCVRequestV1(
aggregate='1s',
instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
exchange = "cbse",
instrument_class = "spot",
code = "btc-usd"
)
))
for response in responses:
# for debug purpose only, don't use MessageToJson in the reading loop in production
print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
# print("Received message %s" % list(map(lambda o: o.string_value, response.data.values)))
except grpc.RpcError as e:
print(e.details(), e.code())
def run():
credentials = grpc.ssl_channel_credentials(root_certificates=None)
call_credentials = grpc.access_token_call_credentials(os.environ['KAIKO_API_KEY'])
composite_credentials = grpc.composite_channel_credentials(credentials, call_credentials)
channel = grpc.secure_channel('gateway-v0-grpc.kaiko.ovh', composite_credentials)
ohlcv_request(channel)
if __name__ == '__main__':
logging.basicConfig()
run()
Response Example
{"aggregate": "1s",
"class": "spot",
"close": "60521.02",
"exchange": "cbse",
"high": "60528.91",
"low": "60521.02",
"open": "60528.91",
"code": "btc-usd",
"timestamp": "2024-08-09T13:13:14.347471354Z",
"uid": "2024-08-09T13:13:13Z",
"volume": "0.00028618000000000003",
"sequenceId": "" }
Last updated
Was this helpful?