Aggregated Quotes

What is this endpoint for?

Aggregated Quotes provides computed real-time price that is based on the best bids and best asks across a highly-vetted selection of exchanges, meaning you can get a comprehensive view of demand, without the need to monitor exchanges individually. The exchanges used in this calculation are vetted, meaning only those that are part of the Kaiko Exchange Ranking are included. The best bids are aggregated over 10-second intervals and delivered every second. This means you receive the best bids and asks from the previous 10 seconds, updated every second.

Note that Kaiko Exchange Ranking is updated every quarter, so the exchanges used in the calculation may change.

Endpoints

gateway-v0-grpc.kaiko.ovh

Parameters

ParameterDescriptionExamplesMandatory?

instrument_class

spot

code

btc-usd

includeUnvettedPrice

This parameter is set to false by default and not included in the code example. Setting this field to true includes best bids and asks from exchanges that are not included in the Kaiko Exchange Ranking. This parameter is helpful when an instrument you need is not covered by any exchange on the Kaiko Exchange ranking. It also serves as a backup for instruments covered by only one exchange, ensuring you still receive a price in case that exchange drops off the ranking when it's updated. If you set this parameter true, the calculation will include all exchanges covered by Kaiko and this price will appear in a separate unvetted section of the response.

"includeUnvettedPrice": true

Configuring multiple instruments

To configure multiple instruments in the same stream, provide the code as a comma separated list eg btc-usd,eth-usd.

Fields

FieldDescription

aggregate

The time period over which the best bid or ask was calculated. This is always 10s.

instrumentClass

The class of the instrument.

code

The instrument code.

eventType

BEST_BID - The best bid from the period BEST_ASK - The best ask from the period

tsEvent

The timestamp the data became available in the Kaiko system.

price

When BEST-BID: The price per unit of the base that the buyer is willing to pay in the quote asset, represented as a scientific notation

Example: btc-usd

  • base asset = btc

  • quote asset = usd price: 60555.00271626198

For each unit of btc, the buyer is willing to pay 60555.00271626198 USD.

When BEST-ASK: The price per unit of the base that the seller is willing to accept in the quote asset, represented as a scientific notation

Example: btc-usd

  • base asset = btc

  • quote asset = usd price: 60556.00224312413

For each unit of btc, the buyer is willing to accept 60556.00224312413 USD.

volume

  • When BEST-BID: The quantity of the base asset that the buyer is willing to purchase

  • When BEST-ASK: The quantity of the base asset the seller has available for sale

Request examples

Make sure to read our Python quick-start guide before starting.

 # This is a code example. Configure your parameters in the parameter configuration section #

from __future__ import print_function
import logging
import os

import grpc
from google.protobuf.json_format import MessageToJson
from google.protobuf import duration_pb2

from kaikosdk import sdk_pb2_grpc
from kaikosdk.core import instrument_criteria_pb2, assets_pb2
from kaikosdk.stream.aggregates_ohlcv_v1 import request_pb2 as pb_ohlcv
from kaikosdk.stream.aggregates_vwap_v1 import request_pb2 as pb_vwap
from kaikosdk.stream.market_update_v1 import request_pb2 as pb_market_update
from kaikosdk.stream.market_update_v1 import commodity_pb2 as pb_commodity
from kaikosdk.stream.trades_v1 import request_pb2 as pb_trades
from kaikosdk.stream.index_v1 import request_pb2 as pb_index
from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate
from kaikosdk.stream.aggregated_quote_v2 import request_pb2 as pb_aggregated_quote
from kaikosdk.stream.aggregates_spot_exchange_rate_v2 import request_pb2 as pb_spot_exchange_rate
from kaikosdk.stream.aggregates_direct_exchange_rate_v2 import request_pb2 as pb_direct_exchange_rate

def aggregated_quote_request(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamAggregatedQuoteServiceV2Stub(channel)
            responses = stub.Subscribe(pb_aggregated_quote.StreamAggregatedQuoteRequestV2(
                 # Start of parameter configuration #
                instrument_class = "spot",
                code = "btc-usd"
            ))
            # End of parameter configuration  #
            for response in responses:
                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)

    aggregated_quote_request(channel)

if __name__ == '__main__':
    logging.basicConfig()
    run()

Response Example

 "aggregate": "10s",
  "instrumentClass": "spot",
  "code": "btc-usd",
  "eventType": "BEST_ASK",
  "tsEvent": "2024-08-09T23:15:18.087882038Z",
  "vetted": {
    "price": "60556.00224312413",
    "volume": "0.2699806"

Last updated