Financial Applications3 Comments

brexit-plot-600

Brexit brought a wave of uncertainty to the world’s political and financial ecosystems.  Its effects were felt in many areas, from the prices of stocks to the value of gold. Many who follow global financial news are familiar with the rapid drop in the pound relative to the dollar as the Brexit results were announced. Less visible was how FX traders anticipated and responded to the event. In this analysis, we utilize 1QBit’s Quantum-Ready Software to provide insights on their activity. We also provide the capability to run such analysis for yourself, so that you, the user, can begin to formulate research ideas and trading strategies around calculations such as these.

This post examines how Brexit was perceived by traders of a particular type currency forward. It takes advantage of the algorithms in 1QBit’s interactive Jupyter Notebook, which provides a limited version of the Quantum-Ready Software Development Kit (SDK) to explore this new trade data.

This is the first in a series of analyses that we will be posting in the coming weeks. The community is encouraged to post their own results and comments using the same data and tools. We look forward to the hearing of your experiences in producing your own investigations.

First, we will cover Brexit and the specific type of currency forward under examination. Then, we will discuss the idea of making graphs from the data we retrieve on these contracts. Finally, we examine the sample graphs that come out of the analysis. Further posts in the coming weeks will discuss changes in graphs before and after the Brexit vote.

The Brexit Vote

The Brexit vote took place on Thursday, June 23, 2016, in the middle of our three week analysis window. The polls closed at 10:00pm British Summer Time (9:00 pm GMT), and the results were gradually announced through the early hours of Friday June 24th. However, it was clear after a few hours that Leave would almost certainly win. This was reflected in both the volatility and sharp decline of the pound (GBP) against the US dollar (USD).

The picture on below is a representative Open, High, Low, Close chart using the most widely published US market data. Each specific market has its own version, but the size of the drop is unmistakeable.

brexit-plot-600

 

Events like the Brexit vote are rare and provide an opportunity to study unusual behavior not present in day-to-day financial activities. By studying examples of these events using new tools, we may find new insights into the dynamics of the foreign exchange market.

New Data, New Techniques

The analysis makes use of new data and new techniques:

  • Non-Deliverable Forward (NDF) trade reports made public by the Swap Data Repository (SDR) operated by the Depository Trust & Clearing Corporation (DTCC). Public SDR data has only been available since 2013 and is fragmented amongst several repositories with different formats and access protocols.
  • Detection of cliques and quasi-cliques in currency relationship graphs using tools provided in 1QBit’s Quantum-Ready Software Development Kit.
  • The currencies are modeled as nodes in a graph, and the trades as edges from one node to another. An edge may represent a simple message count or a property such as price or volume. A clique is a fully connected subgraph, which, in the case of currencies, means that trading is present between all the pairs of currencies that belong to the clique (i.e. there is an edge connecting every pair of nodes).  The graphs are represented by adjacency matrices that can be loaded into a Jupyter interactive Python notebook, where they can be manipulated and visualized.

Data Sharing

The U.S. Commodity Futures Trading Commission (CFTC) requires that every Swap Data Repository  “publish and make available swap transaction and # pricing data in a non-discriminatory manner, through the Internet or other electronic data feed that is widely published and in machine-readable electronic format”.

The data used in this study was filtered from the DTCC’s real time dashboard and converted into Python lists. Initially, we provide fifteen 30×30 adjacency matrices covering the NDF message counts on trading days from Monday, June 13 to Friday, July 1. For convenience, these have been reproduced at the end of this post. Members of the Quantum for Quants community are encouraged to download them for their own use with 1QBit’s interactive notebooks. A larger data set will be posted in the future.

Non-Deliverable Forward Contracts

The Non-Deliverable Forward is a short-term, cash-settled currency forward between two counterparties. On the settlement date, the profit or loss is determined by the difference between the contracted rate and the prevailing spot rate. The key idea is that the settlement is made in a major deliverable currency, because exchange controls or national regulations limit the availability of one or more of the traded currencies. For example, the Bank of China offers NDF contracts in Chinese Renminbi (CNY), Euros (EUR), British Pounds (GBP), Hong Kong Dollars (HKD), and U.S. Dollars (USD). These are settled in USD and give exposure to the Renminbi without requiring possession of the actual currency.

In a study done in 2005 for the Federal Reserve Bank of New York, it was found that NDF prices “can be a useful tool for market monitoring in that these prices reflect market expectations and supply and demand factors that cannot be fully manifested in onshore currency product prices in a country with capital controls… in periods of heightened investor caution or concern over potential change in the exchange rate regime or a perceived increase in onshore country risk”.

Non-Deliverable Forwards are useful in studies of market perception because they are largely traded by well-informed traders at major financial institutions. Furthermore, we will look at only the most heavily traded maturities, where an individual trader can compare his or her perception with that of others in the market.

Our study period covers Monday June 13 through to Friday July 1. We will begin by looking at “trader engagement” with specific currency pairs, i.e. did they trade these or did they prefer to wait. Then will go on to other market data such as price, volume, direction, and contract tenor. We will look at short-term NDF contracts where the settlement date is only a month from the execution date (and the effective date is no more than two business days from the execution date).

Setting Up a Currency Graph

The ISO 4277 Standard defines over 160 three-letter currency codes. In our three week analysis window, 51 of these appeared in NDF trades. The 30 most active were used to create a matrix, ranging from US Dollars (#1 at 72%) and Indian Rupees (#2 at 4.2%) down to Danish Krone (0.12%). The cutoff is, somewhat arbitrarily, 0.1%.

In the one month maturities, there were 74,015 reported trades over the 15 trading days from Monday, June 13 to Friday, July 1.

The 30 currencies can be plotted around the perimeter of an ellipse. The graph below indicates the activity observed on Monday, June 13, the first day of our analysis period.

01-monday-june-13-clique-0

The USD is connected with almost every other currency. The euro (EUR) is also highly connected. Other currencies vary. The pound (GBP) is connected to the Japanese yen (JPY), the Colombian peso (COP) and the USD. The South African rand (ZAR) and the New Zealand dollar (NZD) are not connected at all. No NDF contracts in these currencies were traded that day.

Three currencies have been highlighted in yellow. The Mexican peso (MXN), the Chilean peso (CLP) and the US dollar (USD) form a triangular clique, in that each of these currencies is connected to the other two. Triangular cliques are common in the data, and indicate broadly that businesses in all three countries intend to do business with each other.

A graph may contain multiple cliques. However, our goal will be to find the largest clique, which may contain four or five members and sometimes more. There may also be more than one of these.

For example, in this picture from July 1, the end of our analysis window, the active currencies (USD, EUR, and GBP) form a clique with the Australian dollar (AUD) and the Korean won (KRW).

15-fri-jul-01-clique-0

Note that these are simple message counts, such that the presence of a single trade is enough to create an edge. A single NDF trade between Danish krone (DKK) and USD has the same weight as a thousand trades in USD-EUR.  

A more realistic approach might be to set a threshold, e.g. only pairs with message counts above the median count for all pairs are counted as connected. Other possibilities are to include volume or bid/ask spread as a measure of “trader engagement” with that pair.  Even more could be deduced by studying how cliques form over time, e.g. by breaking down the daily counts into hourly counts.  All of this is possible with the SDR data, more of which will be posted as the study proceeds.

References

  1. Triennial Central Bank Survey of foreign exchange and derivatives market activity in 2013, Bank for International Settlements, http://www.bis.org/publ/rpfx13.htm
  2. Lipscomb, Laura, An Overview of Non-Deliverable Foreign Exchange Forward Markets, Federal Reserve Bank of New York May 2005, also available from the Bank for International Settlements,  https://www.bis.org/publ/cgfs22fedny5.pdf  

Some Example Data to Start With

The following instructions have been tested with Chrome Version 52.0.2743.116 (64-bit) running on OS X El Capitan Version 10.11.6.  

Make sure you have the basics:

  • Register for immediate access to qdk.1qbit.com or sign in.  You can register using e-mail, or sign in with Google, Facebook or various other identities.
  • On the “NOTEBOOK” panel (left side of the page), click the “LOAD” button.  This should bring you to a page like the one shown below. 

qdk-screen-shot-01

 

We will be using the KPlex.ipynb interactive notebook as an example. So if you haven’t done this already, please make sure you are familiar with the basics of clique analysis using the 1QBit SDK Jupyter notebook:

  • Make a duplicate by selecting the checkbox to the left of the KPlex.ipynb notebook name, then clicking the “Duplicate” button that should appear at the top of the notebook list.
  • Open the duplicate notebook and familiarize yourself with the general flow of execution, e.g. loading the packages, creating the agent, running the solver and plotting the graphs.  By working in the duplicate, you can keep the original as a reference.  The undo function is not strong enough to get back from a major misstep, and the only other way to restore the original is to copy and paste from the static tutorial elsewhere on the site.

 

Make sure you can keep your work. The following steps are needed because the interactive notebook server is reset periodically, so if you want to keep your work for more than a few days, you will have to save it to your local machine, and upload it again after the reset.  

  1. Create a new notebook using the “New” drop-down menu at the top of the notebook list on the right hand side.  Select “Python 2” to create the notebook.
  2. In the first cell, enter the simple Python statement print “hello world”  and hit SHIFT+ENTER to execute the cell’s contents.  You should see the “hello world” string printed (without the quotes) just below the cell.
  3. Name and save your notebook with a name you will recognize later. In the rest of these instructions it will be referred to as “brexit-cliques.ipynb” or “the brexit clique notebook”.
  4. Verify that you can download your brexit clique notebook in the ipynb format.  The command is in the “File” menu which usually appears just under the 1QBit logo. Other formats are also possible and this is a good moment to check them out.
  5. Verify that you can upload the notebook that you downloaded.  
    1. Start the process by clicking on the white “Upload” button at the top of the notebook list towards the right.  
    2. Finish the process by clicking on the blue “Upload” button that will appear to the right of the new filename.  You can change the filename, and the uploaded file will take on the name that you assign it.

In this introductory post, the data has been provided in a form that can be copied and pasted into an IPython notebook.  There are two cells to complete, after which you can copy and paste the second cell and modify the parameters to look at cliques on different days.

  • Cell 1 gives you the basic Python expressions for the 15 adjacency matrices,  transforms the simple lists of lists into NumPy arrays and creates the graphs that can be passed to the 1QBit SDK.  It ends with an example that you can use to verify that the software is working, and to experiment with the basic drawing parameters.
  • Cell 2  contains the code that calls the SDK.  To look at different days, copy and paste the Cell 2 code into subsequent cells and pick the index of the day you want to study.  Note that there may be more than one clique with the maximal dimension, and that although they should all appear in the solutions list, the order might vary.

 

You are welcome to copy the data for your own use and share additional data and analysis in the comments for this post.  

 

Cell 1 Data:  Copy and Paste the Code at this Link into Cell 1 of Your Brexit Notebook

Brexit Project Setup Data (Cell 1)

 

Cell 2 Data:  Copy and Paste the Code at this Link into Cell 2 of Your Brexit Notebook

Brexit Clique Finding Code (Cell 2)

Further Notes:

Swap Data Repositories as a Data Source

Trade data for non-deliverable forwards (NDF) is reported to swap data repositories (SDRs) according to the regulations of the US Commodity Futures Trading Commission, pursuant to the Dodd-Frank act. The share of CFTC regulated trades relative to total NDF trades can be estimated from the global outright forwards data collected by the Bank for International Settlements, where in 2013, 43% of forwards involved USD as opposed to 13% for EUR, 9% for JPY, and 5% for GBP. The USD trades are typically settled in USD and therefore fall within the jurisdiction of the CFTC. The biggest SDR is operated by the Depository Trust & Clearing Corporation (DTCC); for this analysis its figures will be taken as representative of the market as a whole.

The DTCC trade data is viewable on the DTCC website. It is possible to download cumulative slice files for the last few weeks or to run searches on arbitrary periods. The NDF data is relatively straightforward to analyze, since many of the fields required for more complex instruments can be ignored. With the columns for NOTIONAL_CURRENCY_1 and NOTIONAL_CURRENCY_2 and some careful use of Excel’s COUNTIF() and SUMIF() functions, it is easy to construct a matrix with the first currency as the row and the second currency as the column.

With about the same amount of effort, a Python script can be written to iterate the slice files and count pairs of dictionary keys like “USD-EUR”, “HKD-MYR” and so on. This was the approach used to create the matrices provided on the web page referred to earlier.

3 Comments on this article

Add a comment