> For the complete documentation index, see [llms.txt](https://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://bluegamma.io/documentation/integrations/api/how-to-guides/fetching-zero-rates.md).

# Fetching Zero Rates

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:** The API returns zero rates with simple compounding, so the discount factor formula is `DF = 1 / (1 + rate × time)`, not `1 / (1 + rate)^time`.
{% endhint %}

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

```python
import requests

url = "https://api.bluegamma.io/v1/zero_rate"
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
]

total_pv = 0

for cf in cash_flows:
    # Get the zero rate for this maturity
    response = requests.get(url, headers=headers, params={
        "index": "SOFR",
        "date": cf["date"]
    })
    zero_rate = response.json()["zero_rate"] / 100
    
    # Calculate years to maturity (simplified)
    years = int(cf["date"][:4]) - 2025
    
    # 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
# Example for a single maturity (repeat for each cash flow date)
curl -X GET "https://api.bluegamma.io/v1/zero_rate?index=SOFR&date=2028-12-17" \
  -H "x-api-key: your_api_key_here"
```

**Output:**

```
2026-12-17: £220,000 × 0.9664 = £212,608
2027-12-17: £215,000 × 0.9365 = £201,348
2028-12-17: £210,000 × 0.9059 = £190,239
2029-12-17: £205,000 × 0.8750 = £179,375
2030-12-17: £200,000 × 0.8436 = £168,720

Total Present Value: £952,290
```

{% hint style="success" %}
**Need this data for your valuation process?** We'll get you set up with API access. [Book a demo →](https://app.lemcal.com/@alivohra/website-demo?back=1)
{% endhint %}

***

## Use Case: Building a Zero Curve

Fetch zero rates across multiple tenors to build a complete curve:

```python
import requests

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

tenors = ["2026-12-17", "2027-12-17", "2028-12-17", "2029-12-17", 
          "2030-12-17", "2031-12-17", "2032-12-17"]

zero_curve = []

for date in tenors:
    response = requests.get(url, headers=headers, params={
        "index": "SOFR",
        "date": date
    })
    data = response.json()
    zero_curve.append({
        "date": date,
        "zero_rate": data["zero_rate"]
    })

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

```bash
# Example for a single date (repeat for each tenor)
curl -X GET "https://api.bluegamma.io/v1/zero_rate?index=SOFR&date=2030-12-17" \
  -H "x-api-key: your_api_key_here"
```

**Current SOFR Zero Curve (December 2025):**

| Maturity      | Zero Rate |
| ------------- | --------- |
| Dec 2026 (1Y) | 3.48%     |
| Dec 2027 (2Y) | 3.39%     |
| Dec 2028 (3Y) | 3.46%     |
| Dec 2029 (4Y) | 3.57%     |
| Dec 2030 (5Y) | 3.71%     |
| Dec 2031 (6Y) | 3.87%     |
| Dec 2032 (7Y) | 4.03%     |

The curve is slightly inverted at the short end (1Y > 2Y), then steepens — reflecting market expectations of near-term rate cuts followed by normalisation.

{% hint style="success" %}
**Ready to pull curves for your models?** Get an API key and start fetching live data in minutes.

[Get API access →](mailto:support@bluegamma.io) | [Book a demo →](https://app.lemcal.com/@alivohra/website-demo?back=1)
{% endhint %}

***

## 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="/files/w2eovjJkWlTRjreuAd2H" 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>

The chart shows:

* **SOFR (USD)**: Slight inversion at the short end (1Y > 2Y), then steepening to \~4.6% at 10Y
* **SONIA (GBP)**: Consistently 20-30bps higher across all tenors
* Both curves reflect market expectations of near-term rate cuts followed by normalisation

***

## Converting Zero Rates to Discount Factors

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)          |

***

## 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/integrations/available-indices.md).

***

## Related Endpoints

| If you need...                  | Use                                                                                             |
| ------------------------------- | ----------------------------------------------------------------------------------------------- |
| Discount factors directly       | [`/discount_factor`](/documentation/integrations/api/how-to-guides/getting-discount-factors.md) |
| 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.

***

**Need an API key?**\
📩 <support@bluegamma.io> | 📅 [Book a call](https://app.lemcal.com/@alivohra/website-demo?back=1)


---

# 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
