My Engineering Perspective on Currency Swaps

Anton Batiaev
Published in
6 min readMar 13, 2022


With more neo-banks, fintech startups, and crypto trading projects popping up, more engineers take on trading projects where they have to solve very specific financial tasks. As a Technical Product Manager of the Trading Platform, I can say for sure that building high-quality software products in finances requires expertise in certain aspects of trading. So fintech engineers have to dig deeper and get a higher-than-average qualification.

In this series of articles, I want to tell you about various tradable products that I worked with for the past six years — firstly at Otkritie Broker, then at Deutsche Bank, and now at Revolut. This journey will be started from currency swaps. You’ll know what an engineer needs to build a currency swap solution, what’s the logic behind it, and how to create reports and calculate risks.

In this first article, I’ll explain in simple words what a currency swap is and give you some examples of its use. We’ll take a first look at the main attributes of the currency swap and explore how the swap order would generally appear. I’ll also show you how to automate some of the operations starting with the settlement dates count. Let’s get to it!

What is a currency swap?

A currency swap is the exchange of assets for a certain time. Currency swaps are used as a corporate investment product by high-street banks to manage liquidity and spare money. They are also popular with multinational companies that operate in several currencies across different locations.

Imagine a British company that wants to enter the French market. It’s hiring people in France and needs to pay them a salary and buy equipment in Euro, so it has to have a certain amount of EUR on its account on a certain date. A loan from a bank makes no economic sense as the company has money, just in a different currency (GBP). Simple currency exchange is not the best solution either, as the company will gain enough EUR soon in the new market and will need to exchange them back to British Pound, and the currency rate may change unfavourably causing financial loss. To mitigate the unpredictability of rates, the company decides to make a currency swap with a bank by exchanging pounds for euros for eight months at a rate fixed by the agreement.

As you can see, a currency swap is an alternative way of giving loans to businesses. The first currency swap was designed by Salomon Brothers, Inc. (an American investment bank) in 1981. You can read more about it on the internet — just google the IBM case.

Currency swaps also work under the hood for individual investors when they buy stock on margin, i.e. buy assets by borrowing money from a broker. Suppose you have the investor’s account in US dollars and you want to buy a Norwegian paper. The broker allows you to make this purchase in dollars. We won’t dive deeply into details, but the broker makes sure your balance is positive by making the overnight currency swap. This means that at night the broker exchanges your dollars to Krones and then back before the trading hours. As an investor, you don’t even notice these swaps.

Engineering a Currency Swap Agreement: MVP

Let’s go back to our example of a British company that needs to exchange 10,000,000 GBP for EUR for eight months. So they. will go to some large investment bank to do so.

If we look at it through the engineer’s eyes, a currency swap involves two exchange deals — the first one takes place now, and the second one in eight months. The fields of the swap agreement in the database are as follows:

Let’s see who’s who here:

  • owner is the legal entity that owns the swap. Usually, it will be some large investment organisation.
  • counterparty is the company that requests the swap.
  • baseCurrency is the currency that the company gives to a bank. In our example, it’s GBP. The amount will be the same in the near and far legs.
  • counterCurrency is the one the company gets from a bank (EUR). Its amount will depend on the FX rate on the settlement date and interest rates that will define how.
  • tradeDate is the date when the company and bank reach an agreement.
  • nearSettlementDate and farSettlementDate are the dates of the first and the second deals. The first settlement will happen two business days after the trade date.

This flat structure works well for a relational DB. However, we should keep in mind that the amount is not just a number here — it’s the amount of money, and that a swap involves two FX deals. So we’ll adapt this code to real-life entities.

To get an MVP, we do the following:

  • Add the endpoints (CRUD), i.e. API allowing you to get updates from the database
  • Create a user interface that will serve the swap deals
  • Integrate with financial systems to make transactions with the counterparty company.

That’s it! Now traders can create orders, all the info is written to the DB, and transactions are made to the counterparty’s banking account.

tradeDate = 2022–01–05

However, at this level, many things are manual: you have to add rates, count amounts, select settlement dates. This is not efficient, so we’re going to improve the interface for the order.

Getting beyond the MVP: Swap order

This is our swap order:

BUY FX_SWAP 8M 10,000,000 GBP/EUR + (tradeDate = currentDate)

A fintech engineer would dissect it into the following parts:

  1. Settlement date
  2. Currency rates
  3. Financial reports
  4. Risk estimates

Let’s look into them one by one.

Settlement date

Under our swap agreement, the first settlement with the counterparty will usually occur two business days after the trade date, or the day when the order is executed.

nearSettlementDate = tradeDate.plusDays(2);

Take a moment now to think about what’s missing in this equation.

First, we need to narrow down the possible settlement days to business days by excluding the weekends.

Cool, what’s next? We need to fetch the information about holidays both in Britain for the swap owner (bank) and in France for the counterparty.

var ownerHolidays = calendar.holidaysIn(;

var counterpartyHolidays = calendar.holidaysIn(;

And that’s not all. If your currency exchange is executed through US dollars (GBPEUR == GBPUSD -> USDEUR), then you might need to take into account US holidays as well.

To be continued…

As I mentioned, a fintech engineer logically dissects our currency swap order into four parts. I’ve covered the settlement date — now you know how to calculate it automatically. In the next article, we’ll dive deeper and I’ll show you the hidden reefs of calculating the currency rates, creating fin reports, and estimating risks.

Don’t hesitate to comment and ask questions. I’ll try to address them in my next publications. Stay tuned!



Anton Batiaev
Editor for

Quantitive finance, fintech software development, risk management, trading etc..