Derivatives Metrics

Derivatives Risk Endpoint

What is this endpoint for?

This endpoint can be used to analyze risk and price related to derivatives, such as open interest, funding rates, and mark price.

Endpoints

gateway-v0-grpc.kaiko.ovh

Parameters

Configuring a wildcard

A wildcard allows you to request all information we have on a specific instrument or exchange in the same stream. Use a * in place of the relevant exchange or class parameter.

For example, the configuration below would deliver all perpetual future contracts on OkEX. exchange: okex class: perpetual-future instrument: *

Fields

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
from kaikosdk.stream.derivatives_instrument_metrics_v1 import request_pb2 as pb_derivatives_instrument_metrics
from kaikosdk.stream.iv_svi_parameters_v1 import request_pb2 as pb_iv_svi_parameters



def derivatives_instrument_metrics_request(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamDerivativesInstrumentMetricsServiceV1Stub(channel)

            responses = stub.Subscribe(pb_derivatives_instrument_metrics.StreamDerivativesInstrumentMetricsRequestV1(
                instrument_criteria = instrument_criteria_pb2.InstrumentCriteria(
                # Start of parameter configuration #
                    exchange = "okex",
                    instrument_class = "perpetual-future",
                    code = "btc-usdt"
                ),
                commodities = [
                "SDICK_RISK"
            ]
            ))
                # End of parameter configuration #
            for response in responses:
                print("Received message %s" % (MessageToJson(response, including_default_value_fields = True)))
    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)

    derivatives_instrument_metrics_request(channel)

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

Response Example

{
  "value": "59583.2",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "bid",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.206163940Z"
}
Received message {
  "value": "59583.2",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.206955912Z"
}
Received message {
  "value": "11535825.5",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "24h_volume",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.207546652Z"
}
Received message {
  "value": "790.1",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "bid_amount",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.208695629Z"
}
Received message {
  "value": "897",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "ask_amount",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.210232016Z"
}
Received message {
  "value": "59583.3",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "ask",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.044166107Z",
  "tsEvent": "2024-08-30T10:19:39.212439076Z"
}
Received message {
  "value": "59583.1",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "mark_price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:38.185367876Z",
  "tsEvent": "2024-08-30T10:19:39.375230934Z"
}
Received message {
  "value": "59668.3",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "index_price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:38.025248460Z",
  "tsEvent": "2024-08-30T10:19:39.399709655Z"
}
Received message {
  "value": "2271074.10000000232",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "open_interest",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.159174620Z",
  "tsEvent": "2024-08-30T10:19:39.412327615Z"
}
Received message {
  "value": "59642.8",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "index_price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:38.183331628Z",
  "tsEvent": "2024-08-30T10:19:39.417789878Z"
}
Received message {
  "value": "59589.8",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "index_price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:38.315614613Z",
  "tsEvent": "2024-08-30T10:19:39.453857128Z"
}
Received message {
  "value": "-0.0000001014222837",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "funding_rate",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:38.619825764Z",
  "tsEvent": "2024-08-30T10:19:39.571097601Z"
}
Received message {
  "value": "59616.3",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "index_price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:48.040708744Z",
  "tsEvent": "2024-08-30T10:19:49.149310575Z"
}
Received message {
  "value": "792.1",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "ask_amount",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.192451006Z"
}
Received message {
  "value": "59604",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "ask",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.192734011Z"
}
Received message {
  "value": "59603.9",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "price",
  "commodityKind": "SDICK_PRICE",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.193612798Z"
}
Received message {
  "value": "11536472.4",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "24h_volume",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.193960504Z"
}
Received message {
  "value": "385.6",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "bid_amount",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.194482596Z"
}
Received message {
  "value": "59603.9",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "bid",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.093288709Z",
  "tsEvent": "2024-08-30T10:19:49.195021257Z"
}
Received message {
  "value": "-0.0000001014222837",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "funding_rate",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-08-30T10:19:48.053370002Z",
  "tsEvent": "2024-08-30T10:19:49.230789712Z"
}

Last updated