For the complete documentation index, see llms.txt. This page is also available as Markdown.

Building a Historical Time Series

How to retrieve historical swap rate data using the BlueGamma API, whether you need daily end-of-day snapshots or intraday granularity.

If you need a time series of swap rates over days, weeks, or months, the BlueGamma API offers two approaches depending on the granularity you need.


Option 1: Daily snapshots with /historical_swap_rates

The /historical_swap_rates endpoint returns daily swap rates for a given index and tenor across a date range in a single call. This is the simplest way to build a time series.

import requests

url = "https://api.bluegamma.io/v1/historical_swap_rates"
headers = {"x-api-key": "your_api_key_here"}

params = {
    "index": "SOFR",
    "tenor": "5Y",
    "start_date": "2026-03-23",
    "end_date": "2026-03-27"
}

response = requests.get(url, headers=headers, params=params)
data = response.json()

for point in data["swap_rates"]:
    print(f"{point['date']}: {point['rate']:.4f}%")

Response:

Parameters

Parameter
Required
Description

index

Yes

Interest rate index (e.g., SOFR, SONIA, 6M EURIBOR)

tenor

Yes

Swap tenor (e.g., 1Y, 5Y, 10Y)

start_date

Yes

Start of the date range, inclusive (ISO 8601 format: YYYY-MM-DD)

end_date

Yes

End of the date range, inclusive (ISO 8601 format: YYYY-MM-DD)

Response fields

Field
Description

index_name

The index requested

currency

Currency of the swap

fixed_leg_day_count

Day count convention used for the fixed leg

floating_leg_day_count

Day count convention used for the floating leg

fixed_leg_frequency

Payment frequency of the fixed leg

floating_leg_frequency

Payment frequency of the floating leg

swap_rates

Array of rate snapshots, each with rate, date, and tenor

You may see multiple rate entries per date. These represent snapshots captured at different times during the day (e.g., European and US market closes). Use the last entry for a given date if you want end-of-day rates.


Option 2: Intraday time series with /swap_rate + valuation_time

If you need rates at specific times during the day, use the /swap_rate endpoint with the valuation_time parameter. Each call returns a single rate, so you loop through your desired timestamps.

Response:


Which approach should I use?

/historical_swap_rates

/swap_rate + valuation_time

Granularity

Daily

Any (hourly, per-minute, etc.)

API calls

1 call per date range

1 call per timestamp

Best for

End-of-day charts, trend analysis, reporting

Intraday monitoring, precise point-in-time valuations

Conventions

Uses market-standard conventions for each index

You specify leg frequencies and day counts

Date range

Any historical range

Any historical timestamp


Practical example: 1-year daily chart

5Y SOFR swap rate over 1 year, showing daily end-of-day rates from April 2025 to April 2026
5Y SOFR swap rate: 1-year daily history built with /historical_swap_rates

If you need...
Use

A single live swap rate

/swap_rate

A full swap curve (all tenors)

/get_swap_curve

Forward rate curves

/forward_curve


Need an API key? Book a demo | support@bluegamma.io

Last updated

Was this helpful?