> For the complete documentation index, see [llms.txt](https://www.bluegamma.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.bluegamma.io/documentation/integrations/api/how-to-guides/fetching-zero-rates.md).

# Fetching Zero Rates

Fetch zero-coupon rates for discounting cash flows, building DCF models, and valuing debt portfolios.

The `/zero_rate` endpoint returns the zero-coupon rate (spot rate) for any date and index. Use this when you need to **discount future cash flows** to present value.

***

## When to Use Zero Rates

| Use Case                               | Why Zero Rates?                                                       |
| -------------------------------------- | --------------------------------------------------------------------- |
| **Discount cash flows in a DCF model** | Zero rates give you the pure time-value of money for each maturity    |
| **Value a loan or bond portfolio**     | Calculate the present value of future principal and interest payments |
| **Build a pricing engine**             | Zero rates are the foundation for swap, bond, and derivative pricing  |
| **Compare rates across tenors**        | Unlike swap rates, zero rates can be directly compared                |

{% hint style="info" %}
**Zero rates vs swap rates:** Swap rates are averages across the life of the swap. Zero rates represent the rate for a specific maturity — no coupon effects.
{% endhint %}

***

## Basic Example

```python
import requests

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

params = {
    "index": "SOFR",
    "date": "2030-12-17"  # 5 years from now
}

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

```bash
curl -X GET "https://api.bluegamma.io/v1/zero_rate?index=SOFR&date=2030-12-17" \
  -H "x-api-key: your_api_key_here"
```

**Response:**

```json
{
  "index": "SOFR",
  "date": "2030-12-17",
  "valuation_time": "2025-12-17T11:47:29.268475",
  "zero_rate": 3.71,
  "day_count": "Actual360",
  "compounding": "Simple",
  "timestamp": "2025-12-17T11:46:57"
}
```

| Field         | Description                                     |
| ------------- | ----------------------------------------------- |
| `zero_rate`   | The zero-coupon rate as a percentage (3.71%)    |
| `day_count`   | Day count convention used (Actual/360 for SOFR) |
| `compounding` | Compounding convention (Simple for OIS indices) |
| `timestamp`   | When the underlying market data was captured    |

***

## Use Case: Discounting Cash Flows

A common task is discounting a series of future cash flows to present value — for example, valuing a loan with scheduled repayments.

{% hint style="info" %}
**Simple compounding:** By default, the API returns zero rates with simple compounding in the curve's day count, so the discount factor formula is `DF = 1 / (1 + rate × time)`, not `1 / (1 + rate)^time`. Use the `compounding` parameter to change this (see [Parameters](#parameters)).
{% endhint %}

### Example: Value a 5-Year Amortising Loan

`/zero_rates` returns the zero rate for every cash flow date in one call, all read off the same curve:

```python
import requests
from datetime import date

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

# Loan cash flows (principal + interest payments)
cash_flows = [
    {"date": "2026-12-17", "amount": 220000},  # Year 1
    {"date": "2027-12-17", "amount": 215000},  # Year 2
    {"date": "2028-12-17", "amount": 210000},  # Year 3
    {"date": "2029-12-17", "amount": 205000},  # Year 4
    {"date": "2030-12-17", "amount": 200000},  # Year 5
]

response = requests.get(url, headers=headers, params={
    "index": "SOFR",
    "dates": [cf["date"] for cf in cash_flows]
})
data = response.json()
valuation_date = date.fromisoformat(data["valuation_time"][:10])

total_pv = 0

for cf, point in zip(cash_flows, data["zero_rates"]):
    zero_rate = point["zero_rate"] / 100

    # Year fraction in SOFR's day count (Actual/360)
    years = (date.fromisoformat(point["date"]) - valuation_date).days / 360

    # Discount using simple compounding (as returned by the API)
    discount_factor = 1 / (1 + zero_rate * years)
    pv = cf["amount"] * discount_factor
    total_pv += pv

    print(f"{cf['date']}: ${cf['amount']:,} × {discount_factor:.4f} = ${pv:,.0f}")

print(f"\nTotal Present Value: ${total_pv:,.0f}")
```

```bash
curl -X GET "https://api.bluegamma.io/v1/zero_rates?index=SOFR&dates=2026-12-17&dates=2027-12-17&dates=2028-12-17&dates=2029-12-17&dates=2030-12-17" \
  -H "x-api-key: your_api_key_here"
```

**Example output (13 Oct 2026):**

```
2026-12-17: $220,000 × 0.9929 = $218,437
2027-12-17: $215,000 × 0.9486 = $203,942
2028-12-17: $210,000 × 0.9044 = $189,930
2029-12-17: $205,000 × 0.8629 = $176,892
2030-12-17: $200,000 × 0.8236 = $164,717

Total Present Value: $953,918
```

***

## Use Case: Building a Zero Curve

Fetch zero rates for a list of dates in one call to build a complete curve. `dates` takes dates or tenors, up to 500 per request:

```python
import requests

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

response = requests.get(url, headers=headers, params={
    "index": "SOFR",
    "dates": ["1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y"]
})

# Print the curve
for point in response.json()["zero_rates"]:
    print(f"{point['date']}: {point['zero_rate']:.2f}%")
```

```bash
curl -X GET "https://api.bluegamma.io/v1/zero_rates?index=SOFR&dates=1Y&dates=2Y&dates=3Y&dates=4Y&dates=5Y&dates=6Y&dates=7Y" \
  -H "x-api-key: your_api_key_here"
```

***

## Use Case: Comparing USD vs GBP Rates

Compare zero rates across currencies to understand relative funding costs:

```python
import requests

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

date = "2030-12-17"  # 5-year maturity

# Fetch USD (SOFR) and GBP (SONIA) zero rates
sofr = requests.get(url, headers=headers, params={"index": "SOFR", "date": date}).json()
sonia = requests.get(url, headers=headers, params={"index": "SONIA", "date": date}).json()

print(f"5Y SOFR Zero Rate:  {sofr['zero_rate']:.2f}%")
print(f"5Y SONIA Zero Rate: {sonia['zero_rate']:.2f}%")
print(f"Spread (SONIA - SOFR): {(sonia['zero_rate'] - sofr['zero_rate']) * 100:.0f} bps")
```

```bash
# SOFR zero rate
curl -X GET "https://api.bluegamma.io/v1/zero_rate?index=SOFR&date=2030-12-17" \
  -H "x-api-key: your_api_key_here"

# SONIA zero rate
curl -X GET "https://api.bluegamma.io/v1/zero_rate?index=SONIA&date=2030-12-17" \
  -H "x-api-key: your_api_key_here"
```

**Output:**

```
5Y SOFR Zero Rate:  3.71%
5Y SONIA Zero Rate: 3.94%
Spread (SONIA - SOFR): 23 bps
```

***

## Visualising Zero Curves

By fetching zero rates across multiple tenors, you can build and visualise complete zero curves:

<figure><img src="https://3184259219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmmQPefoflG1RwUnUKKBR%2Fuploads%2Fgit-blob-b9916a4fb61adc5f9043f07c377a0a0cec9fc77a%2Fzero-curve-sofr-sonia.png?alt=media" alt="Zero curve comparison chart showing SOFR and SONIA rates from 2026 to 2035"><figcaption><p>SOFR vs SONIA zero curves — live API data, December 2025</p></figcaption></figure>

***

## Converting Zero Rates to Discount Factors

By default, the API returns zero rates with **simple compounding**. To convert to a discount factor:

```python
zero_rate = 3.71 / 100  # 3.71%
years = 5

# Simple compounding formula (matches API convention)
discount_factor = 1 / (1 + zero_rate * years)
print(f"Discount Factor: {discount_factor:.6f}")  # 0.843282
```

Or use the `/discount_factor` endpoint directly to skip the calculation:

```bash
curl "https://api.bluegamma.io/v1/discount_factor?index=SOFR&date=2030-12-17" \
  -H "x-api-key: your_api_key"
```

***

## Parameters

| Parameter               | Required | Description                                                                                                                                               |
| ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `index`                 | Yes      | The interest rate index (e.g., `SOFR`, `SONIA`, `6M EURIBOR`)                                                                                             |
| `date`                  | Yes      | The maturity date (YYYY-MM-DD format)                                                                                                                     |
| `valuation_time`        | No       | Historical timestamp for the curve (ISO 8601 format)                                                                                                      |
| `day_count`             | No       | Day count for the rate: `Actual360`, `Actual365Fixed`, `Thirty360BondBasis`, `Thirty360EurobondBasis` or `Business252`. Defaults to the curve's day count |
| `compounding`           | No       | `Simple` (default), `Compounded` or `Continuous`                                                                                                          |
| `compounding_frequency` | No       | `1M`, `3M`, `6M` or `12M` (default). Used only when `compounding` is `Compounded`                                                                         |

`/zero_rates` takes the same parameters, with `dates` (repeated, up to 500) in place of `date`.

***

## Supported Indices

| Index        | Currency | Day Count  |
| ------------ | -------- | ---------- |
| `SOFR`       | USD      | Actual/360 |
| `SONIA`      | GBP      | Actual/365 |
| `ESTR`       | EUR      | Actual/360 |
| `6M EURIBOR` | EUR      | Actual/360 |
| `CORRA`      | CAD      | Actual/365 |

For the full list, see [Available Indices](/documentation/data-coverage/data-coverage/available-indices.md).

***

## Related Endpoints

| If you need...                  | Use                                                                                             |
| ------------------------------- | ----------------------------------------------------------------------------------------------- |
| Discount factors directly       | [`/discount_factor`](/documentation/integrations/api/how-to-guides/getting-discount-factors.md) |
| Zero rates for a list of dates  | `/zero_rates` (see [Building a Zero Curve](#use-case-building-a-zero-curve))                    |
| Forward rates between two dates | [`/forward_rate`](/documentation/integrations/api/how-to-guides/getting-forward-rates.md)       |
| The full swap curve             | [`/get_swap_curve`](/documentation/integrations/api/how-to-guides/fetching-a-swap-curve.md)     |
| Historical rates                | Add `valuation_time` parameter                                                                  |

***

## Excel Alternative

If you prefer Excel, use the BlueGamma Add-in:

```
=BlueGamma.ZERO_RATE("SOFR", "2030-12-17")
```

Returns: `3.71`

See [Excel Add-in Guide](/documentation/integrations/excel-add-in/installation-and-setup.md) for setup instructions.

***

Create a key under **API Keys** in the app sidebar. See [Authentication](/documentation/integrations/api/authentication.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.bluegamma.io/documentation/integrations/api/how-to-guides/fetching-zero-rates.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
