Before we begin, ensure that you have Python installed along with the requests
and matplotlib
libraries. If you don't have them yet, install them using:
pip install requests matplotlib
The /forward_rate
endpoint in the BlueGamma API lets you fetch forward rates for specific start dates and tenors. Let's start with an example for a single date:
import requests
# API endpoint
url = "https://api.bluegamma.io/v1/forward_rate"
# Query parameters for a single forward rate
querystring = {
"index": "CORRA", # Reference rate
"start_date": "2025-06-30", # Start date
"end_date": "3M" # Fixed tenor of 3M
}
# API headers (replace 'YOUR_API_KEY' with your actual API key)
headers = {"X-Api-Key": "YOUR_API_KEY"}
# Fetch the forward rate
response = requests.get(url, headers=headers, params=querystring)
if response.status_code == 200:
data = response.json()
print("Forward Rate:", data["forward_rate"])
else:
print("Error:", response.status_code, response.text)
The script fetches the 3-month CORRA forward rate starting on 2025-06-30. The response includes the forward rate and other relevant details.
Now, let's expand this to fetch forward rates for a set of predefined dates. By doing so, we'll plot a CORRA forward curve to visualise how the rate evolves over time.
import requests
# API endpoint
url = "https://api.bluegamma.io/v1/forward_rate"
# Query parameters for a single forward rate
querystring = {
"index": "CORRA", # Reference rate
"start_date": "2025-06-30", # Start date
"end_date": "3M" # Fixed tenor of 3M
}
# API headers (replace 'YOUR_API_KEY' with your actual API key)
headers = {"X-Api-Key": "YOUR_API_KEY"}
# Fetch the forward rate
response = requests.get(url, headers=headers, params=querystring)
if response.status_code == 200:
data = response.json()
print("Forward Rate:", data["forward_rate"])
else:
print("Error:", response.status_code, response.text)
The graph plots the 3-month CORRA forward curve with:
Whether you're forecasting interest costs or performing valuations, the BlueGamma API makes it easy to fetch real-time swap rates and build forward curves.
👉 Request access to the API here