Over the past few years, I’ve been working on tcapy, a transaction cost analysis library in Python, which I’ve recently open sourced. As a result I’ve been thinking about TCA for a long time. Why is it important to do transaction cost analysis on your trades? Ultimately doing TCA can save you money on your trading costs and is also a way to show best execution for regulators.
The next question is how you can do TCA? Using an external service can be an easier way to accomplish TCA. However, it requires you to send out your trade data externally and the costs can vary considerably. An external TCA service might not be as customisable as writing your own TCA software internally. The problem is that writing your own comprehensive internal TCA software can cost many hundreds of thousands of dollars and take a very long time.
tcapy gives you a fully customisable solution with all the source code, just like an internal build would do, but without spending hundreds of thousands of dollars on developing and maintaining it all. Cuemacro can also provide commercial support and you can sponsor Cuemacro to write new features.
What’s next after downloading tcapy?
So let’s say you’ve downloaded tcapy and you’ve installed it, what should you do next? There are a number of Jupyter notebooks I’ve written on tcapy, showing you how to code up typical types of analysis with tcapy. I’ve also recently written a real world Jupyter notebook study with tcapy on data from the FX desk of Swedbank Robur over several months and they’ve allowed me to publish it. Below, however, we’ll try to summarise the steps you’ll need to do, to get up and running with tcapy to provide you with results.
Sorting out your trade/order data
The notebook shows how to ingest real trade/order data and how to clean it up before using tcapy. If you do any sort of TCA a key part of it, is your own trade data, and you need to make sure it’s in the right format. It is crucial you collect the right fields and granularity of data. You run tcapy locally so your data is kept private.
Getting market data as a benchmark
As well as trade data, you’ll need market data to do your own TCA. I’ve used Dukascopy retail FX tick data as a benchmark in the above research study, given it’s free. In practice, it’s likely you’d want to use a source of market data which aggregates a number of liquidity providers. Currently, tcapy also has a wrapper to make it easy to download data from New Change FX who create a market benchmark based on many different FX venues. Note that you’ll need a subscription from New Change FX in order to download the market data. You can even try to use several market data sources if you wanted with tcapy.
What types of TCA to do?
If all your data is all sorted (and preferably have a database – and tcapy supports many database types), you then need to figure out what type of TCA to do. Typically, one of the first things you would likely calculate metrics like slippage against the arrival price of your order. You can also calculate other basic metrics like market impact. You’ll also want to aggregate your results across a lot of trades and summarise it in an easy to interpret way. You might also wish to use other benchmarks, eg. a TWAP over 1600 LDN, as a proxy for the FX fix.
Each desk will have different needs: customize your analysis
Each trading desk will have different demands on their TCA and precisely where they spend time analysing data. For example, you can see in my real world study, my main focus was on analysis of EUR/SEK, given that was a big part of what was traded by the asset manager.
tcapy comes preloaded with many common metrics and benchmarks prewritten, but you can add your own customised ones. Furthermore, it comes with lots of tools to generate charts, PDFs (here’s an autogenerated PDF example) etc. It also comes with a web GUI and can be controlled via Excel with xlwings, to make it easy to interact with tcapy.
If you’re trading, you really should be doing TCA. If you don’t, it’s difficult to know precisely how much your execution is costing and you need to show best execution for regularity purposes. Without being able to quantify it, it makes it difficult to reduce the cost. You don’t need to spend hundreds of thousands to do TCA. Instead, use tcapy, an open source alternative.
You can download tcapy from GitHub here. If you’re interested in me doing a similar Jupyter notebook on your own trade data using tcapy let me know! I’m hoping to write several Jupyter notebooks with real data from trading desks to help illustrate the different types of TCA that can be done with tcapy.