# Fetching a Discount Curve

The `/discount_curve` endpoint returns a schedule of discount factors between two dates at a specified frequency. Use this when you need to discount multiple future cash flows back to present value.

***

## Basic Example

```python
import requests

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

params = {
    "index": "SOFR",
    "start_date": "0D",
    "end_date": "5Y",
    "frequency": "6M"
}

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

for point in data["curve"]:
    print(f"{point['date']}: {point['discount_factor']:.6f}")
```

```bash
curl -X GET "https://api.bluegamma.io/v1/discount_curve?index=SOFR&start_date=0D&end_date=5Y&frequency=6M" \
  -H "x-api-key: your_api_key_here"
```

**Response:**

```json
{
  "start_date": "2026-04-01",
  "end_date": "2031-04-01",
  "index": "SOFR",
  "valuation_time": "2026-04-01T20:57:50.523152",
  "is_end_of_month": true,
  "frequency": "6M",
  "curve": [
    { "date": "2026-04-01", "discount_factor": 1.0 },
    { "date": "2026-04-30", "discount_factor": 0.997063 },
    { "date": "2026-10-31", "discount_factor": 0.978594 },
    { "date": "2027-04-30", "discount_factor": 0.960977 },
    { "date": "2027-10-31", "discount_factor": 0.943836 },
    { "date": "2028-04-30", "discount_factor": 0.927581 },
    { "date": "2028-10-31", "discount_factor": 0.911458 },
    { "date": "2029-04-30", "discount_factor": 0.895746 },
    { "date": "2029-10-31", "discount_factor": 0.879728 },
    { "date": "2030-04-30", "discount_factor": 0.863909 },
    { "date": "2030-10-31", "discount_factor": 0.847782 },
    { "date": "2031-04-30", "discount_factor": 0.831898 }
  ],
  "timestamp": "2026-04-01T20:57:27"
}
```

### Response fields

| Field             | Description                                             |
| ----------------- | ------------------------------------------------------- |
| `start_date`      | Start date of the curve                                 |
| `end_date`        | End date of the curve                                   |
| `index`           | The interest rate index used                            |
| `valuation_time`  | When the curve was calculated                           |
| `is_end_of_month` | Whether dates are aligned to month-ends                 |
| `frequency`       | Spacing between curve points                            |
| `curve`           | Array of points, each with `date` and `discount_factor` |
| `timestamp`       | When the underlying market data was captured            |

### Curve point fields

| Field             | Description                                                                                           |
| ----------------- | ----------------------------------------------------------------------------------------------------- |
| `date`            | The future date (ISO 8601 format)                                                                     |
| `discount_factor` | The present value of 1 unit of currency received on that date. Starts at 1.0 and decreases over time. |

***

## Parameters

| Parameter         | Required | Description                                                                |
| ----------------- | -------- | -------------------------------------------------------------------------- |
| `index`           | Yes      | Interest rate index (e.g., `SOFR`, `SONIA`, `6M EURIBOR`)                  |
| `start_date`      | Yes      | Start of the curve. Relative (`0D`, `1Y`) or absolute (`2026-04-01`)       |
| `end_date`        | Yes      | End of the curve. Relative (`5Y`, `10Y`, `30Y`) or absolute (`2031-04-01`) |
| `frequency`       | Yes      | Spacing between points: `1M`, `3M`, `6M`, or `1Y`                          |
| `valuation_time`  | No       | Historical timestamp (ISO 8601) for reproducibility                        |
| `is_end_of_month` | No       | Align dates to month-ends. Defaults to `true`                              |

***

## Practical example: Discounting a loan schedule

```python
import requests

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

# Get semi-annual discount factors for the next 3 years
params = {
    "index": "SOFR",
    "start_date": "0D",
    "end_date": "3Y",
    "frequency": "6M"
}

response = requests.get(url, headers=headers, params=params)
curve = response.json()["curve"]

# Semi-annual loan payments
payments = [50000] * 6  # 6 payments of 50,000

total_pv = 0
for i, payment in enumerate(payments):
    # Skip the first curve point (date = today, DF = 1.0)
    df = curve[i + 1]["discount_factor"]
    pv = payment * df
    total_pv += pv
    print(f"{curve[i + 1]['date']}: {payment:>10,} x {df:.6f} = {pv:>10,.2f}")

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

***

## `/discount_curve` vs `/discount_factor`

|               | `/discount_curve`                                  | `/discount_factor`                          |
| ------------- | -------------------------------------------------- | ------------------------------------------- |
| **Returns**   | Full schedule of discount factors                  | A single discount factor                    |
| **API calls** | 1 call for the entire curve                        | 1 call per date                             |
| **Best for**  | Loan/bond valuation, DCF models, batch discounting | Quick lookups, single cash flow discounting |

Use `/discount_curve` when you need discount factors for multiple dates. Use [`/discount_factor`](https://bluegamma.io/documentation/integrations/api/how-to-guides/getting-discount-factors) when you only need one.

***

## Visualising a discount curve

<figure><img src="https://3184259219-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmmQPefoflG1RwUnUKKBR%2Fuploads%2Fgit-blob-ae5889202f1dffa0a0ff6c590b871a8744ae5794%2Fdiscount-curve-sofr-10y.png?alt=media" alt="Discount curves for SOFR, SONIA, and 6M EURIBOR over 10 years"><figcaption><p>SOFR, SONIA, and 6M EURIBOR discount curves: 10-year, quarterly frequency</p></figcaption></figure>

***

## Related Endpoints

| If you need...           | Use                                                                                                              |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| A single discount factor | [`/discount_factor`](https://bluegamma.io/documentation/integrations/api/how-to-guides/getting-discount-factors) |
| Zero rates               | [`/zero_rate`](https://bluegamma.io/documentation/integrations/api/how-to-guides/fetching-zero-rates)            |
| Forward rates            | [`/forward_rate`](https://bluegamma.io/documentation/integrations/api/how-to-guides/getting-forward-rates)       |
| A forward curve          | [`/forward_curve`](https://bluegamma.io/documentation/integrations/api/how-to-guides/getting-a-forward-curve)    |

***

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


---

# 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://bluegamma.io/documentation/integrations/api/how-to-guides/fetching-a-discount-curve.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.
