# Exchange-provided metrics

## What is this endpoint for? <a href="#what-is-this-endpoint-for" id="what-is-this-endpoint-for"></a>

This endpoint is part of [Derivatives Risk Indicators](https://www.kaiko.com/products/analytics/derivatives-risk-indicators). It can be used to get risk information such as greeks and IV in real-time.&#x20;

## Endpoints

{% tabs %}
{% tab title="gRPC" %}

```url
gateway-v0-grpc.kaiko.ovh
```

{% endtab %}

{% tab title="http" %}

```url
gateway-v0-http.kaiko.ovh
```

{% endtab %}

{% tab title="API (testing)" %}

```url
https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1
```

{% endtab %}
{% endtabs %}

## Parameters

<table><thead><tr><th width="246">Parameter</th><th width="387">Description</th><th>Examples</th></tr></thead><tbody><tr><td><code>instrumentCriteria</code></td><td><p>A <strong>nested object</strong> to configure following properties for your stream: </p><ul><li><code>exchange</code> (String) - The code(s) for the exchange(s)</li><li><code>instrument_class</code> (String) - The class(es) of the instrument(s) . The instrument must be a derivative class.</li><li><code>code (String) -</code> The Kaiko code for the instrument.</li></ul><p>Explore instruments, codes and exchanges in the <a href="https://instruments.kaiko.com/#/instruments">Instrument Explorer</a> or <a data-mention href="/spaces/ltAbhvgBfrAWlpUnC7ys/pages/ypeWZ4XSK6XHt2hrySeK">/spaces/ltAbhvgBfrAWlpUnC7ys/pages/ypeWZ4XSK6XHt2hrySeK</a>.  </p></td><td><p><code>cbse</code></p><p></p><p><code>option</code></p><p></p><p><code>algo-btc</code><br><br></p></td></tr><tr><td><code>commodities</code></td><td>Always<code>SDICK_RISK</code></td><td><code>SDICK_RISK</code></td></tr></tbody></table>

{% hint style="info" %}
**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. <br>

For example, the configuration below would deliver all perpetual future contracts on OkEX. \
\
`exchange: okex`\
`class: perpetual-future`\
`instrument: *`
{% endhint %}

## Fields: Perpetual Future <a href="#fields" id="fields"></a>

<table><thead><tr><th width="185">Field</th><th width="383">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>Value</code></td><td>The value for the commodity in the received message.<br><br>eg: <code>24h_volume</code> or <code>price</code></td><td><code>59583.2</code></td></tr><tr><td><code>legacySymbol</code></td><td>Exchange assigned instrument identifier</td><td><code>BTCUSDC_PERP</code></td></tr><tr><td><code>exchange</code></td><td><a href="https://instruments.kaiko.com/#/exchanges">Supported Exchanges</a></td><td><code>binc</code></td></tr><tr><td><code>commodityKind</code></td><td>Always <code>SDICK_RISK</code> </td><td><code>SDICK_RISK</code></td></tr><tr><td><code>tsCollection</code></td><td>The timestamp for when Kaiko received the trade from the exchange.</td><td><code>2024-08-30T10:19:38.044166107Z</code></td></tr><tr><td><code>tsEvent</code></td><td>The timestamp for the interval.</td><td><code>2024-08-30T10:19:39.206955912Z</code></td></tr><tr><td><code>commodity:funding rate</code></td><td>The current funding rate.</td><td><code>-0.0000756735759807</code></td></tr><tr><td><code>comodity: predicted_funding_rate</code></td><td>The predicted funding rate for the next period.</td><td><code>-0.0000845044644161</code></td></tr><tr><td><code>commodity: ask</code></td><td>The best ask price from the order book at the time of funding rate calculation.</td><td><code>101937.0</code></td></tr><tr><td><code>commodity:  ask_amount</code></td><td>The size of the best ask order from the order book at the time of funding rate calculation.</td><td><code>0.552</code></td></tr><tr><td><code>commodity: bid</code></td><td>The best bid price from the order book at the time of the funding rate calculation. </td><td><code>101936.0</code></td></tr><tr><td><code>commodity: bid_amount</code></td><td>The size of the best bid order from the order book at the time of funding rate calculation.</td><td><code>0.396</code></td></tr><tr><td><code>commodity: 24h_volume</code></td><td>The volume of the trades executed in the last 24 hours (can be in base_asset, quote_asset or the number of contracts)</td><td><code>140.235</code></td></tr><tr><td><code>commodity: open_interest</code></td><td>The total outstanding number of contracts (units in which open interest metrics are quoted vary by exchange)</td><td><code>144.817</code></td></tr></tbody></table>

## Fields: Future <a href="#fields" id="fields"></a>

<table><thead><tr><th width="184">Field</th><th>Description</th><th width="187">Example</th></tr></thead><tbody><tr><td><code>Value</code></td><td>The value for the commodity in the received message.<br><br>eg: <code>24h_volume</code> or <code>price</code></td><td><code>59583.2</code></td></tr><tr><td><code>commodityKind</code></td><td>Always <code>SDICK_RISK</code> </td><td><code>SDICK_RISK</code></td></tr><tr><td><code>tsCollection</code></td><td>The timestamp for when Kaiko received the trade from the exchange.</td><td><code>2024-08-30T10:19:38.044166107Z</code></td></tr><tr><td><code>tsEvent</code></td><td>The timestamp for the interval.</td><td><code>2024-08-30T10:19:39.206955912Z</code></td></tr><tr><td><code>commodity: time_to_expiry</code></td><td>The number of minutes remaining before expiry.</td><td><code>41504</code></td></tr><tr><td><code>commodity: nearby</code></td><td>The soonest expiring contract with the same base &#x26; quote asset on the specified exchange</td><td>boolean value</td></tr><tr><td><code>commodity: quarterly_nearby</code></td><td>The soonest expiring <strong>quarterly</strong> contract with the same base &#x26; quote asset on the specified exchange</td><td>boolean value</td></tr><tr><td><code>commodity: expiry</code></td><td>Expiration date of the contract</td><td><code>1737072000000000000</code></td></tr><tr><td><code>commodity: 24h_volume</code></td><td>The volume of the trades executed in the last 24 hours (can be in base_asset, quote_asset or the number of contracts)</td><td><code>2047.3</code></td></tr><tr><td><code>commodity: open_interest</code></td><td>The total outstanding number of contracts (units in which open interest metrics are quoted vary by exchange)</td><td><code>6813.4</code></td></tr><tr><td><code>commodity: ask</code></td><td>The price level of the best ask order from the order book at the time of message receipt.</td><td><code>97890.1</code></td></tr><tr><td><code>commodity: ask_amount</code></td><td>The size of the best ask order from the order book at the time of the message.</td><td><code>0.552</code></td></tr><tr><td><code>commodity: bid</code></td><td>The price level of the best bid order from the order book at the time of message receipt.</td><td><code>97878.4</code></td></tr><tr><td><code>commodity: bid_amount</code></td><td>The size of the best bid order from the order book at the time of the message.</td><td><code>0.396</code></td></tr></tbody></table>

## Fields: Option <a href="#fields" id="fields"></a>

<table><thead><tr><th width="177">Field</th><th width="387">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>Value</code></td><td>The value for the commodity (price, 24 hour volume etc) received in the message.</td><td><code>59583.2</code></td></tr><tr><td><code>commodityKind</code></td><td>Always <code>SDICK_RISK</code> </td><td><code>SDICK_RISK</code></td></tr><tr><td><code>tsCollection</code></td><td>The timestamp for when Kaiko received the trade from the exchange.</td><td><code>2024-08-30T10:19:38.044166107Z</code></td></tr><tr><td><code>tsEvent</code></td><td>The timestamp for the interval.</td><td><code>2024-08-30T10:19:39.206955912Z</code></td></tr><tr><td><code>commodity: time_to_expiry</code></td><td>The number of minutes remaining before expiry.</td><td><code>41504</code></td></tr><tr><td><code>commodity: nearby</code></td><td>The soonest expiring contract with the same base &#x26; quote asset on the specified exchange</td><td>boolean value</td></tr><tr><td><code>commodity: quarterly_nearby</code></td><td>The soonest expiring <strong>quarterly</strong> contract with the same base &#x26; quote asset on the specified exchange</td><td>boolean value</td></tr><tr><td><code>commodity: ask_iv</code></td><td>Implied volatility for the best ask.</td><td><code>0.8166587</code></td></tr><tr><td><code>commodity: bid_iv</code></td><td>Implied volatility for the best bid.</td><td><code>0.6817713</code></td></tr><tr><td><code>commodity: mark_iv</code></td><td>The implied volatility for the mark price.</td><td><code>0.7418202</code></td></tr><tr><td><code>commodity: delta</code></td><td>The delta value for the option.</td><td><code>-1.6532715362206545</code></td></tr><tr><td><code>commodity: gamma</code></td><td>The gamma value for the option.</td><td><code>3.7235607858486044</code></td></tr><tr><td><code>commodity: rho</code></td><td>The rho value for the option.</td><td><code>16.74149</code></td></tr><tr><td><code>commodity: theta</code></td><td>The theta value for the option.</td><td><code>0.0002888</code></td></tr><tr><td><code>commodity: vega</code></td><td>The vega value for the option.</td><td><code>0.0006550</code></td></tr><tr><td><code>commodity: strike_price</code></td><td>The strike price of the contract in USD</td><td><code>90000</code></td></tr><tr><td><code>commodity: underlying_index</code></td><td>Name of the underlying index</td><td><code>BTC-31JAN25</code></td></tr><tr><td><code>commodity: kind</code></td><td>Put or Call</td><td><code>C</code></td></tr><tr><td><code>commodity: expiry</code></td><td>Expiry</td><td><code>1738281600000000000</code></td></tr></tbody></table>

## Request examples <a href="#fields" id="fields"></a>

{% tabs %}
{% tab title="Python" %}

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

```

{% endtab %}

{% tab title="cURL" %}
**cURL requests are intended for testing purposes only.**

{% code overflow="wrap" %}

```url
curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/derivatives_instrument_metrics_v1" \
-H "accept: application/json" \
-H "X-Api-Key: $kaiko_api_key" \
-H "Content-Type: application/json" \
-d "{ \"instrumentCriteria\": {  \"exchange\": \"okex\",  \"instrumentClass\": \"perpetual-future\",  \"code\": \"btc-usdt\" }}"
```

{% endcode %}
{% endtab %}

{% tab title="BigQuery" %}
Information from this endpoint can be accessed through Google BigQuery. \
\
To get started, read our [guide](broken://spaces/zwO3AMVXsp37KK2FngVc/pages/LFIZ1UwRtOxTg308jneZ).
{% endtab %}

{% tab title="Other examples" %}
For more advanced users, you can access our full SDK [here](https://github.com/kaikodata/kaiko-sdk-examples/tree/master), where you'll find more coding languages, examples, and guidance.
{% endtab %}
{% endtabs %}

## Response Example

```json
{
  "value": "-0.0000345359072087",
  "legacySymbol": "btcusdtswap",
  "exchange": "okex",
  "commodity": "funding_rate",
  "commodityKind": "SDICK_RISK",
  "tsCollection": "2024-12-18T13:15:43.861660474Z",
  "tsEvent": "2024-12-18T13:15:45.456011570Z"
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kaiko.com/stream/analytics-solutions/kaiko-derivatives-risk-indicators/exchange-provided-metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
