How to build an end-to-end transaction cost analysis framework

Haykaz Aramyan
LSEG Developer Community
4 min readMar 18, 2024

Overview

Financial professionals are often required to analyze and evaluate the costs related to trading financial instruments. Transaction Cost Analysis (TCA) is a tool for doing exactly that by utilizing a variety of metrics and benchmarks. Building a TCA system from scratch is a significant undertaking, requiring a deep understanding of financial markets, data analysis, and software development.

We break down the complexity of the TCA into stages by implementing a proprietary TCA system and introducing in series of articles that can be found on LSEG’s Developer Portal.

The full articles can be found in reference section. Checkout the complete source code of the project here.

Trade Simulation

We expect users of the prototype will submit their own trades for enrichment and analysis. However, in the first article of the series, along with touching the theory behind the TCA, we have briefly discussed our simulation approach.

We assumed that an investment decision is taken at TDecision, at time TArrival the order finds itself in the orderbook awaiting execution. While we have implemented limit orders, only market orders were used in the simulation. This way, we can highlight their high immediate cost, also known as market impact. The following graph depicts all the stages of such an execution sequence and the costs incurred at each stage.

Trade Enrichment

The cornerstone of effective and accurate TCA is the use of noise free market data enhanced with prevailing market conditions. In the second article of the series we focused on trade enrichment using the LSEG Tick History data. To optimize the performance and speed of data processing, we implement the data ingestion asynchronously.

Upon completion of the ingestion process, each order, for every asset, is encapsulated in its own gzip-compressed file. An extract of a file with tick data captured 2 minutes before and after a specific trade on BARC.L, is shown below.

Further analysis is conducted by merging the tick outputs with simulated trades, providing a layered aggregation that maps tick data against the trades.

The following DataFrame provides a snapshot of trading flows by asset. Metrics include the number of brokers and traders involved, the volume of buy and sell orders placed and the respective numbers of executions fulfilling the order amount. Additionally, the count of tick data points collected both before and after trades are stored, offering a granular view into market conditions surrounding each transaction.

Analysis and Interactive Visualisations

In the final article of our series on building an end-to-end Transaction Cost Analysis (TCA) framework, leveraging the enriched dataset, we present a detailed analysis using a variety of metrics and benchmarks to understand the costs involved in trading financial instruments. In addition to analysing these costs, we have introduced a User Interface (UI) that implements a presentation layer visualizing our findings using Streamlit. This UI will allow us to access both an overall summary and detailed company-level insights.

Among other visualisation, in the aggregated view we demonstrates the analysis of slippage across different trading venues, currencies, and stocks, revealing interesting patterns in the data.

We provide wide range of analytics under the Company view as well in Buy, Sell, and All trades level. One example is the examination of Buy trades for BARC.L, we specifically look at the Trades Volume-Weighted Average Price (VWAP) in relation to benchmarks like the market best, mid, and market VWAP prices.

References

References

Downloads

Related Articles

--

--