All pages
Powered by GitBook
1 of 1

Loading...

FOREX conversion

Convert your USD rate into a currency of your choosing.

What is this endpoint for?

This endpoint retrieves any single-asset Benchmark Reference Rate and converts USD into a local currency of your choosing using TP-ICAP as the source for the conversion. Currencies available are:

  • CHF

  • EUR

  • GBP

  • JPY

  • KRW

Endpoints

Request parameters

Parameter
Description
Examples

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

Response fields

Field
Description

Request examples

cURL requests are intended for testing purposes only.

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

Response Example

price

The price of the Reference Rate in the converted currency.

tsEvent

The exact time of converted reference rate publication.

detail_underlying_name

The ticker of the underlying reference rate.

detail_underlying_price

The original published price of the Reference Rate in USD.

detail_underlying_tsEvent

The exact timestamp of original reference rate publication.

fxrate_name

The name of the FOREX conversion rate we've sourced to convert USD into your chosen currency.

fxrate_price

The price of the FOREX conversion rate we've used to convert USD into your chosen currency.

fxrate_tsEvent

The timestamp for when we collected the FOREX conversion rate we've used to convert USD into your chosen currency.

index_code

The Kaiko Benchmark Reference Rate ticker. You can find a full list of our tickers here.

KK_RR_BTCUS

indexCode

The ticker identifying the rate.

commodity

The type of publication. Either real-time or fixings

interval_startTime

The start time for the interval.

interval_endTime

The end time for the interval.

composition_underlying_name

The Kaiko Reference Rate Ticker.

composition_underlying_tsEvent

The exact time of original reference rate publication.

gateway-v0-grpc.kaiko.ovh
gateway-v0-http.kaiko.ovh
https://gateway-v0-http.kaiko.ovh/api/stream/index_forex_rate_v1
here
curl -X POST "https://gateway-v0-http.kaiko.ovh/api/stream/index_forex_rate_v1" -H "accept: application/json" -H "X-Api-Key: $KAIKO_API_KEY" -H "Content-Type: application/json" -d "{\"indexCode\": \"KK_BRR_BTCUSD\"}"
{
  "indexCode": "KK_BRR_BTCUSD_EUR",
  "commodity": "SIC_REAL_TIME",
  "interval": {
    "startTime": "2024-09-12T21:42:35Z",
    "endTime": "2024-09-12T21:42:50Z"
  },
  "composition": {
    "underlying": {
      "name": "KK_BRR_BTCUSD",
      "tsEvent": "2024-09-12T21:42:50.658126160Z"
    },
    "fxrate": {
      "name": "USD/EUR",
      "tsEvent": "2024-09-12T21:42:01.048683287Z"
    }
  },
  "price": 52215.539302000085,
  "tsEvent": "2024-09-12T21:42:50.857862111Z",
  "detail": {
    "underlying": {
      "name": "KK_BRR_BTCUSD",
      "price": 57826.099,
      "tsEvent": "2024-09-12T21:42:50.658126160Z"
    },
    "fxrate": {
      "name": "USD/EUR",
      "price": 0.9029753036254458,
      "tsEvent": "2024-09-12T21:42:01.048683287Z"
    }
  }
}
# This is a code example. Configure your parameters below #

from __future__ import print_function
from datetime import datetime, timedelta
import logging
import os
from google.protobuf.timestamp_pb2 import Timestamp
import grpc
from google.protobuf.json_format import MessageToJson
from kaikosdk import sdk_pb2_grpc
from kaikosdk.stream.index_forex_rate_v1 import request_pb2 as pb_index_forex_rate

def index_forex_rate(channel: grpc.Channel):
    try:
        with channel:
            stub = sdk_pb2_grpc.StreamIndexForexRateServiceV1Stub(channel)
            responses = stub.Subscribe(pb_index_forex_rate.StreamIndexForexRateServiceRequestV1(
                index_code = "KK_BRR_BTCUSD_EUR"
            ))
            for response in responses:
                # for debug purpose only, don't use MessageToJson in the reading loop in production
                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)
    index_forex_rate(channel)

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