The aim of the mifid2-rts project is to persuade regulators to work in a different way, to communicate regulatory intent using working software examples rather than relying solely on legal tomes.
As an example of how regulatory intent could be expressed in software this project implements parts of the MiFID II RTS (Regulatory Technical Standard) documents.
Here are some introductory videos:
- An overview of the context and the objectives of the project.
- How to download the code from GitHub and run it.
- Using the mifid2-rts code to generate lots of sample trade data.
- Running an SI calculation using the mifid2-rts code.
And here are some Jupyter Notebook examples of the code in use:
- Working through the RTS 2 Annex II implementation.
- Generating test trade data.
- Running the SI calculator over generated trade data.
MiFID (Markets in Financial Instruments Directive) is EU law for the regulation of the financial industry. The original MiFID was introduced in 2004, and following the 2007/8 financial crisis a second version, MiFID II, was introduced in 2014.
The regulator ESMA (European Securities and Markets Authority) have been entrusted with enacting MiFID II. ESMA have produced documents which define what firms need to do to comply with MiFID II, a key set of which are the RTS (Regulatory Technical Standards) documents. Here we are focused on the final 14th July 2016 version of RTS 2. An early 2015 draft of the full set of RTS documents can be read here.
The code in this GitHub repository implements the taxonomies defined in RTS 2 Annex 3 and in RTS 23 table 2.
The hope is that we can use this code either as an example of, or as the basis of, a body of code which is a working executable model of all MiFID II Regulatory Technical Standards, together with a body of test data which can illustrate how the technical standards are intended to work in practice.
There are some slides which present the the intent of the project.
If you would like to see some trivial examples of the code in use, just run rts2_annex3.py from the command line. This will build the taxonomies and run a few simple example ‘trades’ through. The module dumps a representation of the RTS 2 taxonomy and the test trade classifications to stdout.
Here is an example of building and classifying a sample trade.
import datetime
import rts2_annex3
class SampleTrade(object):
pass
sample_trade = SampleTrade()
sample_trade.asset_class_name = 'Foreign Exchange Derivatives'
sample_trade.sub_asset_class_name= 'Deliverable FX options (DO)'
sample_trade.underlying_currency_pair = ('GBP~USD')
sample_trade.from_date = datetime.date(2017, 8, 13)
sample_trade.to_date = datetime.date(2017, 10, 12)
sample_classification = rts2_annex3.class_root.classification_for(sample_trade)
sample_classification.classification_dict()
{
'RTS2 version': 'Brussels, 14.7.2016 C(2016) 4301 final ANNEXES 1 to 4',
'Asset class': 'Foreign Exchange Derivatives',
'Sub-asset class': 'Deliverable FX options (DO)',
'Segmentation criterion 1 description': 'underlying currency pair defined as combination of the two currencies underlying the derivative contract',
'Segmentation criterion 1': "('GBP~USD')",
'Segmentation criterion 2 description': 'time to maturity bucket of the swap defined as follows:',
'Segmentation criterion 2': 'Maturity bucket 2: 1 week to 3 months',
}
# ... or as Json:
print(sample_classification.as_json(indent=4))
{
"RTS2 version": "EU 2017/583 of 14 July 2016",
"Asset class": "Foreign Exchange Derivatives",
"Sub-asset class": "Deliverable FX options (DO)",
"Segmentation criterion 1 description": "underlying currency pair defined as combination of the two currencies underlying the derivative contract",
"Segmentation criterion 1": "GBP~USD",
"Segmentation criterion 2 description": "time to maturity bucket of the swap defined as follows:",
"Segmentation criterion 2": "Maturity bucket 2: 1 week to 3 months"
}