Introducing Meeta – Our in-house trading algorithm

Meeta is our in-house Python language trading algorithm which made Rs.22,20,800 in the FOREX currency futures market in a back-test over the last 7 years. The algorithm is called Meeta, because she is really sweet!

Currency Markets in India

Currency markets are very unlike equity markets.  Unless it is the Turkish Lira we are talking about, most other exchange rates are remarkably stable over long periods of time. This is the chart of GBP-INR exchange rate over the last 7 years.

At the beginning of 2014, you could exchange one British pound for Rs.102. Fast forward 7 years to today, that value is Rs.97! More or less unchanged. Go back 20 years to 2000, GBP was still priced at Rs.70 – in essence appreciating by just 1.7% per year over two decades. This is perhaps why the FX market is the perfect place to trial out algorithmic trading strategies – which is precisely what we set out to do.

What factors influence exchange rates?

But before we get into that – What are the factors that influence exchange rates? If you think about it, there are no real fundamentals that drive currency values. They neither post quarterly results nor pay dividends. They neither have a profit & loss statement nor publish a detailed annual report each year. So, what then does influence their movements?

Theoretical finance says that interest rate differences between different countries are the primary drivers of their currency values in the long term. We will demo this using a popular concept in finance called the arbitrage-free valuation framework. Also known variously as the law of one price and no-free-lunch, the theory is grounded by a strong assumption that in real-world it is impossible to make free money.

Take the example of Indian Rupees and British Pounds. At the beginning of the year 2019, the risk-free interest rate was 7% in India and 0.1% in the UK. The exchange rate was Rs.90 per £.

A savvy investor, say, John Doe, could have done the following list of transactions.

People in financial circles call this the carry trade. But theoretical finance argues that this is not possible. It says that prices will adjust such that the Indian rupee will deteriorate enough to not give anyone the opportunity to make free money. But John just did.

There are other factors that influence currency values too – like the balance of payments, inflation, reckless money printing by central banks etc. But fixed income traders in large investment banks have known for a long time that in the short term none of this matters. The key factors that influence currency values in the short term are sentiments like growth prospects or BREXIT and currency demand from the likes of importers/exporters or FIIs. Not interest rates. This is the reason carry-traders like Joe have made easy money in the last decade.

And the primary reason why carry trade has worked so well is that currencies of developed markets have not appreciated as much as the interest rate differentials suggest. EURO and SGD have appreciated at an annual rate of 3.5% versus the Indian rupees while USD has appreciated by 2.7% per annum. The interest rate differentials between India and these countries were significantly higher during this time period

How to profit from currency markets in India?

Great piece of info. Thanks! Tell us how to profit from it 😉

Here are the current spot rates, interest rate differential and spot rates as ‘expected’ by 2 and 3-month futures contract for GBPINR, EURINR and USDINR.

What the futures markets are telling us is this – The Indian rupee will depreciate by a % at least equal to or greater than that warranted by the interest rate differential between the countries. But this is precisely what has not happened in the last 20 years. The INR spot rates have depreciated by a much smaller percentage than that expected by theoretical finance. Remember John? He is laughing at all of this.

Our observation is this – The futures contracts are routinely undervaluing the India rupee vis-à-vis other currencies. And therein lies an opportunity to profit. Buy the undervalued currency (INR), sell the overvalued currency(ies) and hope that the trade works.

Has it worked? Did this strategy turn a profit?

Overwhelmingly yes!

Here are some very brief notes about our algorithm – We are calling her Meeta (because she is sweet!)

We developed a mean-reversion strategy-based currency trading algorithm on Python. The way it works is as below.

  • Currency contracts expire each month, so there are 12 different contracts per currency pair each year.
  • Positions are initiated 3-months prior to the expiry of every contract on 10 lots. One lot is equal to 1000 units of the foreign currency (GBP in this case)
  • On the date the position is initiated, the algorithm compares the current futures price of the currency pair with the simple moving average of the spot price over the past 3-months.
  • If the futures price is higher, a short position is initiated. If it is lower, a long position is initiated. (mean-reversion)
  • All positions are closed out on the day of contract expiry and profits computed.

We had 7-years’ worth of GBPINR futures pricing data from January 2014. 80 different contracts were evaluated. And here are the results.

  • Our total cash outlay in the form of span margins, considering the algorithm held 3 different contracts at any one time, would have been around Rs.1,20,000.
  • The algorithm went long 24 times, went short 53 times and did not trade 3 times since some data points were not available.
  • The algorithm turned a profit 82% of the times i.e., there were 63 winning trades.
  • From all winning trades, it made a total profit of Rs.24,71,375
  • The average amount of profit per winning trade was Rs.37,445
  • In all losing trades, it lost a total of Rs.2,50,575
  • The average amount of losses per losing trade was Rs.17,898
  • Total earnings were Rs.22,20,800

That means our money grew by 18.5X in 7 years!

What is the key-takeaway?

If there is only one thing, we take away from this exercise it is that in the last decade the currency futures market consistently undervalued the Indian rupee against the British pound. Consequently, a trader who simply kept shorting the GBPINR contract 3-months before expiry made money. Will this strategy work going-forward? Absolutely no clue. The only way to find out is to put it in action.

What next?

We now need to back test this algorithm even further back on the GBPINR contract. And then, we need to test this algorithm on other contracts like the USDINR, EURINR and JPYINR. We will also need to integrate transaction costs. And more importantly, we need to take into account span margins to see how many times losing trades hit margin calls. Perhaps they’ll all tell us a different story?

Share this post

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email