LogoLogo
  • Kaiko Knowledge Hub
  • General
    • 👋Introduction
    • ℹ️General information
      • Response codes
      • API Key
      • Parameter patterns
      • Rate limiting
    • 🏎️Quick-Start Guides
      • Quick-Start: Python
      • Quick-Start: cURL
  • Data Feeds
    • Introduction
    • Level 1 & Level 2 Data
      • Level 1 Aggregations
        • OHLCV
        • VWAP
      • Level 1 Tick-Level
        • All trades
        • Best bids and asks (top of book)
      • Level 2 Tick-Level
        • Bids and asks
    • Reference Data
      • Derivatives pricing
  • Analytics Solutions
    • Kaiko Best Execution
    • Kaiko Fair Market Value
      • Kaiko Fair Market Value (high liquidity pairs)
      • Kaiko Fair Market Value (low liquidity pairs)
    • Kaiko Derivatives Risk Indicators
      • Exchange-provided metrics
  • Legacy endpoints
    • Aggregated Quotes (v1)
    • OHLCV Candles (v1)
    • Trades (v1)
    • VWAP (v1)
    • Bids and asks: Market Update
  • BETA ENDPOINTS
    • Implied Volatility SVI (Closed Beta)
Powered by GitBook
On this page
  • What is this endpoint for?
  • Endpoints
  • Parameters
  • Fields
  • Request examples
  • Response Example

Was this helpful?

Export as PDF
  1. Analytics Solutions

Kaiko Best Execution

PreviousDerivatives pricingNextKaiko Fair Market Value

Last updated 2 months ago

Was this helpful?

What is this endpoint for?

Get a market-representative execution benchmark that’s ideal for reporting and demonstrating execution efficiency to clients. The exchanges used in this calculation are vetted, meaning only those that are part of the 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
gateway-v0-http.kaiko.ovh
https://gateway-v0-http.kaiko.ovh/api/stream/aggregated_quote_v2

Parameters

Parameter
Description
Examples
Mandatory?

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

Field
Description

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

 # 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()

cURL requests are intended for testing purposes only.

curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/aggregated_quote_v2" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"instrumentClass\":\"spot\", \"code\": \"btc-usd\"}"

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"

The class of the instrument(s) . Explore instruments, codes and exchanges in the or .

The Kaiko code for the instrument(s). The class of the instrument(s) . Explore instruments, codes and exchanges in the or .

Make sure to read our before starting.

For more advanced users, you can access our full SDK , where you'll find more coding languages, examples and guidance.

Kaiko Exchange Ranking
Python quick-start guide
here
Instrument Explorer
Instrument Explorer
Reference Data
Reference Data