LogoLogo
  • Kaiko Knowledge Hub
  • GETTING STARTED
    • About Kaiko Indices
    • General information
      • API Key
      • Timestamps
      • Index codes
  • Benchmarks: Single-Asset Reference Rates
    • Subscribe
    • Reference data
    • Historical prices
    • FOREX conversion
    • Replication data
  • Benchmarks: Indices
    • Subscribe
  • Customized Indices
    • Valour - CDF Index
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. Benchmarks: Indices

Subscribe

How to configure a Kaiko multi-asset rate stream.

PreviousReplication dataNextValour - CDF Index

Last updated 22 days ago

Was this helpful?

What is this endpoint for?

Monitor the overall performance of specific buckets of assets. The indices combine several data sources to summarize market performance. They can be used to aid the issuance of derivatives contracts or investment vehicles by providing pricing for settlement. You can see our full list of indices and learn more about their performance in our .

Endpoints

gateway-v0-grpc.kaiko.ovh
gateway-v0-http.kaiko.ovh
https://gateway-v0-http.kaiko.ovh/api/stream/index_multi_assets_v1

Parameters

Parameter
Description
Examples

index_code

KT5

Requesting multiple tickers at the same time To configure multiple tickers in the same stream, provide the indexCode as a comma-separated list eg KT5,KT10NYC Alternatively, use a wildcard by entering a * and you'll receive all tickers you have as part of your Kaiko subscription.

Fields

Field
Description

indexCode

The ticker identifying the index.

commodity

The type of publication. Either real-time or fixings

interval

The time period in which transaction data are considered for the calculation of the index. If an index's calculation methodology has an interval of 15 seconds, startTime and endTime will be separated by 15s.

mainQuote

is the quote asset used for the index denomination.

compositions

The list of underlying data used to calculate the index price.

  • underlyingInstrument

The ticker for the Kaiko Reference Rate(s) used to calculate the multi-asset index.

  • base

The base asset for the used Reference Rate.

  • quote

The quote asset for the used Reference Rate

  • Exchanges

The exchanges used to calculate the Reference Rate.

  • insturmentInterval

The startTime and endTime of the calculation period for the specific Reference Rate.

  • tsEvent

The time the rate was published by Kaiko.

price

Information on the pricing for the index.

  • indexValue

The value for the index publication.

pairs

The pricing details of the underlying Kaiko Reference Rates used in the calculation.

  • underlyingPrice

The published price of the Reference Rate.

  • weightingFactor

The weighting of the Reference Rate to the index.

  • cappingFactor

The capping of the Reference Rate to the index.

  • currencyConversionFactor

The conversion factor used in the Reference Rate for the index.

tsEvent

The theoretical time of price publication

tsCompute

The exact time of price computation.

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 index_multi_asset(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamIndexMultiAssetsServiceV1Stub(channel)
            responses = stub.Subscribe(pb_index_multi_assets.StreamIndexMultiAssetsServiceRequestV1(
                index_code = "KT5"
            ))
            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)

    index_multi_asset(channel)

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

This example demonstrates how to request historical data using replay. The maximum amount of data you can request for one replay cannot exceed a total of 24 hours in hours, seconds, and minutes. Replay data is available on a 72-hour rolling basis and should only be used to retrieve missed data. If full history is required, please use Rest API or CSV deployment methods.

 # This is a code example. Configure your parameters below #

from __future__ import print_function
import logging
import os
import datetime

import grpc
from google.protobuf.json_format import MessageToJson

from kaikosdk import sdk_pb2_grpc
from kaikosdk.stream.index_multi_assets_v1 import request_pb2 as pb_index_multi_assets
from google.protobuf.timestamp_pb2 import Timestamp

api_key = os.environ.get('KAIKO_API_KEY')

def index_multi_asset(channel: grpc.Channel, index_code, start_unix, end_unix):
    k = []
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamIndexMultiAssetsServiceV1Stub(channel)
            responses = stub.Subscribe(pb_index_multi_assets.StreamIndexMultiAssetsServiceRequestV1(
                index_code=index_code,
                interval={
                    'start_time': Timestamp(seconds=start_unix),
                    'end_time': Timestamp(seconds=end_unix)
                }
            ))

            if os.path.exists('index_replay_logging.txt'):
                os.remove('index_replay_logging.txt')
                print("index_replay_logging.txt Removed!")

            for response in responses:
                # print("Received message %s" % (MessageToJson(response, including_default_value_fields=True)))
                k += [eval(MessageToJson(response))]
                
    except grpc.RpcError as e:
        print(e.details(), e.code())
    
    print("replay is done!")
    return k
    
def run(start_time, end_time, index_list):
    credentials = grpc.ssl_channel_credentials(root_certificates=None)
    call_credentials = grpc.access_token_call_credentials(api_key)
    composite_credentials = grpc.composite_channel_credentials(credentials, call_credentials)
    channel = grpc.secure_channel('gateway-v0-grpc.kaiko.ovh', composite_credentials)
    res = index_multi_asset(channel=channel,
                  index_code=','.join(index_list),
                  start_unix=start_time,
                  end_unix=end_time)
    # print(res)
    return res


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

    current_time = datetime.datetime.now()
    current_time = current_time.replace(second=0, microsecond=0)
     # start of time configuration #
    start_time = current_time - datetime.timedelta(minutes=15)
    end_time = current_time - datetime.timedelta(minutes=5)
     # start of time configuration  #
    start_time = int(start_time.timestamp())
    end_time = int(end_time.timestamp())
    # add your index code(s) #
    
    res = run(start_time=start_time, end_time=end_time, index_list = ['KT5'])
    print(res)

cURL requests are intended for testing purposes only.

curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/index_multi_assets_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"indexCode\": \"KT5\"}"

Response Example

{
  "commodity": "SIC_REAL_TIME",
  "indexCode": "KT5",
  "interval": {
    "startTime": "2024-08-12T14:23:55Z",
    "endTime": "2024-08-12T14:29:00Z"
  },
  "mainQuote": "usd",
  "compositions": [
    {
      "underlyingInstrument": "KK_RFR_AVAXUSD",
      "base": "avax",
      "quote": "usd",
      "exchanges": [
        "bfnx",
        "cbse",
        "krkn",
        "stmp"
      ],
      "instrumentInterval": {
        "startTime": "2024-08-12T14:23:55Z",
        "endTime": "2024-08-12T14:28:55Z"
      },
      "currencyConversion": "none",
      "tsEvent": "2024-08-12T14:28:56.074863348Z"
    },
    {
      "underlyingInstrument": "KK_RFR_BTCUSD",
      "base": "btc",
      "quote": "usd",
      "exchanges": [
        "bfnx",
        "cbse",
        "krkn",
        "lmax",
        "stmp"
      ],
      "instrumentInterval": {
        "startTime": "2024-08-12T14:24:00Z",
        "endTime": "2024-08-12T14:29:00Z"
      },
      "currencyConversion": "none",
      "tsEvent": "2024-08-12T14:29:01.087284434Z"
    },
    {
      "underlyingInstrument": "KK_RFR_ETHUSD",
      "base": "eth",
      "quote": "usd",
      "exchanges": [
        "bfnx",
        "cbse",
        "krkn",
        "lmax",
        "stmp"
      ],
      "instrumentInterval": {
        "startTime": "2024-08-12T14:23:55Z",
        "endTime": "2024-08-12T14:28:55Z"
      },
      "currencyConversion": "none",
      "tsEvent": "2024-08-12T14:28:56.142347541Z"
    },
    {
      "underlyingInstrument": "KK_RFR_SOLUSD",
      "base": "sol",
      "quote": "usd",
      "exchanges": [
        "bfnx",
        "cbse",
        "gmni",
        "krkn",
        "stmp"
      ],
      "instrumentInterval": {
        "startTime": "2024-08-12T14:24:00Z",
        "endTime": "2024-08-12T14:29:00Z"
      },
      "currencyConversion": "none",
      "tsEvent": "2024-08-12T14:29:00.784958075Z"
    },
    {
      "underlyingInstrument": "KK_RFR_XRPUSD",
      "base": "xrp",
      "quote": "usd",
      "exchanges": [
        "cbse",
        "indr",
        "krkn",
        "lmax",
        "stmp"
      ],
      "instrumentInterval": {
        "startTime": "2024-08-12T14:23:55Z",
        "endTime": "2024-08-12T14:28:55Z"
      },
      "currencyConversion": "none",
      "tsEvent": "2024-08-12T14:28:55.988918370Z"
    }
  ],
  "price": {
    "indexValue": 334.99947165068875,
    "divisor": 26979870988.68237,
    "pairs": [
      {
        "underlyingInstrument": "KK_RFR_AVAXUSD",
        "underlyingPrice": 21.333163636363636,
        "weightingFactor": 17278580619.32558,
        "cappingFactor": 1.0,
        "currencyConversionFactor": 1.0
      },
      {
        "underlyingInstrument": "KK_RFR_BTCUSD",
        "underlyingPrice": 59699.73163636363,
        "weightingFactor": 390312772.9127332,
        "cappingFactor": 0.119856816159272,
        "currencyConversionFactor": 1.0
      },
      {
        "underlyingInstrument": "KK_RFR_ETHUSD",
        "underlyingPrice": 2680.1494545454543,
        "weightingFactor": 2288124768.3108406,
        "cappingFactor": 0.373375636405882,
        "currencyConversionFactor": 1.0
      },
      {
        "underlyingInstrument": "KK_RFR_SOLUSD",
        "underlyingPrice": 147.37236363636362,
        "weightingFactor": 17542805404.323048,
        "cappingFactor": 1.0,
        "currencyConversionFactor": 1.0
      },
      {
        "underlyingInstrument": "KK_RFR_XRPUSD",
        "underlyingPrice": 0.5706330909090909,
        "weightingFactor": 1755466226611.777,
        "cappingFactor": 1.0,
        "currencyConversionFactor": 1.0
      }
    ]
  },
  "tsEvent": "2024-08-12T14:29:00Z",
  "tsCompute": "2024-08-12T14:29:05.210675561Z"
}

The Benchmark ticker. You can find a full list of our tickers .

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

here
factsheet
here
here