Back to Blog

What Is a Currency Swap? FX Swaps, Cross-Currency Swaps and Swap Lines Explained

V
Vlado Grigirov
November 07, 2026
Currency API Exchange Rates Currency Swap FX Swap Educational Finexly

If you have ever seen a line item called "swap points" in a treasury report, or read that the Federal Reserve "opened swap lines" during a crisis, you have run into the same family of ideas. So, what is a currency swap? In short, it is an agreement between two parties to exchange one currency for another today and to reverse the exchange later at a pre-agreed rate. Everything else, from corporate funding to central bank emergency liquidity, is a variation on that single idea.

This guide explains the three things people usually mean by "currency swap" (the FX swap, the cross-currency swap, and the central bank swap line), shows the arithmetic behind swap points, and gives you working code to price a swap using live rates from the Finexly API documentation endpoints.

What Is a Currency Swap?

A currency swap is a contract with two legs. On the near leg, two parties exchange amounts in two currencies. On the far leg, they exchange the same amounts back on a later date. Because the far-leg rate is fixed in advance, neither party carries outright exchange rate risk on the principal; they have effectively borrowed one currency against collateral in another.

The word "swap" is used loosely, so it helps to separate three instruments:

  1. FX swap: a short-term spot-plus-forward pair, typically from overnight to a few months.
  2. Cross-currency swap: a longer-term contract, often years, that also exchanges interest payments.
  3. Central bank swap line: an arrangement where one central bank lends its currency to another in return for the other's currency.

All three rest on the same pricing logic, which is why developers building multi-currency products benefit from understanding it even if they never trade one.

FX Swaps: Spot Plus Forward

An FX swap combines a spot transaction and an opposite forward transaction in a single deal. Say a European company needs US dollars for 3 months. It buys USD spot against EUR and simultaneously agrees to sell the USD back for EUR in 3 months at a rate fixed today.

The difference between the forward rate and the spot rate is called swap points (or forward points). It is not a forecast of where the market thinks the rate is heading. It is a mechanical result of the interest rate gap between the two currencies, a relationship known as covered interest parity. If you want a refresher on the forward leg, see our guide to spot rate vs forward rate.

The Swap Point Formula

For a currency pair quoted as base/quote, the forward rate is approximately:

Forward = Spot × (1 + r_quote × d/360) / (1 + r_base × d/360)

Here r_quote and r_base are the annual interest rates of the quote and base currencies, and d is the number of days. (Some currencies, such as GBP, use a 365-day basis.) The currency with the higher interest rate trades at a forward discount, and the one with the lower rate trades at a forward premium.

FX swaps are by far the largest segment of FX turnover. The BIS Triennial Survey has consistently shown them accounting for roughly half of daily global FX volume, well ahead of spot trades. Most of that is institutions managing short-term funding rather than speculation.

Cross-Currency Swaps: Funding and Interest in Two Currencies

A cross-currency swap (sometimes called a currency swap in the narrow sense) runs for longer, often 2 to 10 years, and adds a stream of interest payments. A typical structure has three steps:

  1. Initial exchange: the parties swap principal at the spot rate.
  2. Periodic interest: each party pays interest on the currency it received, usually every quarter or half year.
  3. Final re-exchange: principal is swapped back at the original spot rate.

A classic use case: a US company wants to build a factory in Germany. Borrowing euros locally might be expensive, while it can borrow dollars cheaply at home. It borrows USD, swaps into EUR with a bank, pays EUR interest to the bank, and receives USD interest that covers its dollar loan. The company ends up with euro funding at an effective cost that can be lower than the direct route.

The Cross-Currency Basis

In theory, covered interest parity says the swap should price exactly off the interest rate differential. In practice there is an additional spread called the cross-currency basis. When global demand for US dollar funding is high, the basis widens and borrowing dollars through swaps becomes more expensive. The basis is widely watched as a gauge of dollar funding stress, and it widened sharply in 2008 and again in March 2020.

Central Bank Swap Lines

A central bank swap line is the same two-leg structure at the sovereign level. The Federal Reserve provides US dollars to a foreign central bank, which hands the Fed an equal value of its local currency at the prevailing market rate. The foreign central bank then lends the dollars to banks in its own jurisdiction. At maturity the transaction reverses at the same exchange rate, with the foreign central bank paying interest.

Because the reversal uses the original rate, the Fed bears no exchange rate risk. The program exists to stop dollar shortages abroad from turning into global market stress. Standing arrangements exist among the Fed, the ECB, the Bank of England, the Bank of Japan, the Bank of Canada and the Swiss National Bank, and temporary lines have been extended to other central banks during crises.

Separately, China's central bank (PBOC) has signed bilateral swap agreements with dozens of central banks, which are mainly used to support trade settlement in yuan. These are bilateral currency swaps in the original sense.

For developers, the practical consequence is that swap line headlines can move rates fast. Our guide to handling currency volatility covers how to make your application resilient when that happens.

Why Developers Should Care

You do not need a trading desk to run into swap concepts. They show up in:

  • Treasury and ERP software: hedging accounting often records swap points as a separate P&L component.
  • Marketplaces and payment platforms: settling in one currency and paying out in another creates a short funding gap that is routinely bridged with FX swaps.
  • Fintech products: neobanks offering multi-currency accounts price their spreads off forward points.
  • Analytics: the implied yield from swap points is a clean signal of interest rate expectations. Combine it with data from our historical exchange rates API guide.

Pricing an FX Swap with Live Rates

Let's compute implied swap points. First, fetch the live spot rate from Finexly.

curl "https://api.finexly.com/v1/latest?base=EUR&symbols=USD&apikey=YOUR_API_KEY"

Python Example

import requests

API_KEY = "YOUR_API_KEY"

def get_spot(base: str, quote: str) -> float:
    r = requests.get(
        "https://api.finexly.com/v1/latest",
        params={"base": base, "symbols": quote, "apikey": API_KEY},
        timeout=10,
    )
    r.raise_for_status()
    return r.json()["rates"][quote]

def forward_rate(spot, r_quote, r_base, days, basis=360):
    return spot * (1 + r_quote * days / basis) / (1 + r_base * days / basis)

spot = get_spot("EUR", "USD")      # USD per 1 EUR
r_usd, r_eur = 0.045, 0.025        # example annual rates: replace with your source
fwd = forward_rate(spot, r_usd, r_eur, days=90)
points = (fwd - spot) * 10_000     # swap points in pips

print(f"Spot: {spot:.4f}  3M forward: {fwd:.4f}  swap points: {points:.1f}")

The interest rates above are illustrative inputs. In production, take them from your treasury feed or a reference rate such as SOFR and €STR.

JavaScript Example

const API_KEY = "YOUR_API_KEY";

async function swapPoints(base, quote, rQuote, rBase, days) {
  const res = await fetch(
    `https://api.finexly.com/v1/latest?base=${base}&symbols=${quote}&apikey=${API_KEY}`
  );
  const { rates } = await res.json();
  const spot = rates[quote];
  const fwd = spot * (1 + (rQuote * days) / 360) / (1 + (rBase * days) / 360);
  return { spot, fwd, points: (fwd - spot) * 10000 };
}

swapPoints("EUR", "USD", 0.045, 0.025, 90).then(console.log);

Valuing an Open Swap

To mark an existing FX swap to market, you only need the far-leg amounts and today's rate. The unrealised gain on the far leg is amount × (current_forward − contract_rate). Store the contract rate with full precision and follow the guidance in our currency rounding and decimal places guide to avoid drift.

Currency Swap vs Forward vs Hedge

People often confuse these. A forward is a single future exchange. A swap is two exchanges, near and far. A hedge is a purpose, not an instrument; swaps and forwards are two ways to achieve it. If your goal is protecting revenue from currency moves, start with understanding currency hedging.

Risks to Keep in Mind

  • Counterparty risk: if the other side defaults, you may be left with unreturned principal. Collateral agreements reduce this.
  • Basis risk: the cross-currency basis can move against you over the life of a long swap.
  • Rollover risk: short-dated FX swaps used to fund long-dated assets must be rolled, and rolling can become expensive in stressed markets.
  • Operational risk: wrong day-count conventions or stale rates produce wrong valuations. Cache sensibly, as covered in API caching and error handling best practices.

Frequently Asked Questions

What is a currency swap in simple terms?

It is an agreement to exchange two currencies now and swap them back later at a rate agreed in advance. It works like borrowing one currency while lending another.

What is the difference between an FX swap and a cross-currency swap?

An FX swap is usually short term and exchanges only principal. A cross-currency swap lasts longer and also exchanges interest payments during its life.

What is a central bank swap line?

It is an arrangement where one central bank supplies its currency to another central bank in exchange for that bank's currency, so the second bank can lend to its local banks during a funding squeeze.

Are swap points a prediction of future exchange rates?

No. Swap points reflect the interest rate difference between two currencies, not a market forecast. Actual future spot rates can end up higher or lower.

Can I calculate swap points with a currency API?

Yes. A currency API supplies the spot rate, and you add interest rates from a reference source to compute forward points, as in the code above.

Start Pricing Swaps with Live Data

Ready to integrate real-time exchange rates into your project? Get your free Finexly API key, no credit card required. Start with 1,000 free requests per month and upgrade via our pricing plans as you grow. You can also try the currency converter to sanity-check any rate before you code against it.

Vlado Grigirov

Senior Currency Markets Analyst & Financial Strategist

Vlado Grigirov is a senior currency markets analyst and financial strategist with over 14 years of experience in foreign exchange markets, cross-border finance, and currency risk management. He has wo...

View full profile →