# MiFID II Reporting Classifier

## A Plain-English Explanation

### The Analogy: The "EU Customs Checkpoint"

Imagine the European Union has a customs checkpoint at the border. Their job is to record every trade involving European interests.

**The rule is simple:**

> *"If you're trading on European soil, or you're a European company, or you're dealing with a European partner — we need to know about it."*

But here's the catch: **If two Americans meet in Tokyo to trade Japanese goods, the EU has no business knowing about it.** They might be trading shares of a German car company, but neither party is European, and the trade didn't happen in Europe.

Our software is the customs officer making these decisions thousands of times per second.

---

### The Rules (In Plain English)

Our reporting classifier asks four questions, in order:

| Priority | Question | If Yes... |
|----------|----------|-----------|
| **1** | Did this trade happen on a European stock exchange (like Paris or Frankfurt)? | → **Report it** |
| **2** | Is this a European instrument (like Airbus stock) AND is at least one party European? | → **Report it** |
| **3** | Was this an over-the-counter trade AND is at least one party European? | → **Report it** |
| **4** | None of the above? | → **Don't report** |

**The Key Insight:** Just because they're trading a European stock doesn't mean Europe has jurisdiction. The *parties* matter too.

---

### The Bug We Found

#### What Went Wrong

Our original code had a flaw in Rule 2. It said:

> *"If it's a European stock → Report it"*

But it forgot to ask: *"Is anyone in this trade actually European?"*

#### The Problem Scenario

**The Trade:**
- **Buyer:** A hedge fund in New York
- **Seller:** A bank in Singapore  
- **What they traded:** BMW shares (a German company)
- **Where:** Over the phone (OTC — not on any exchange)

**What the buggy code said:** "BMW is German! Report to ESMA!" ❌

**What should happen:** Neither party is European. The trade didn't happen in Europe. ESMA has no jurisdiction here. Don't report. ✅

#### Why This Matters

- **Over-reporting** wastes compliance resources and could expose your trading strategies to regulators who shouldn't see them
- **It's legally questionable** to claim EU jurisdiction over a trade between two non-EU parties
- **It creates noise** in regulatory systems, making it harder to spot actual issues

---

### The Fix

We updated Rule 2 to say:

> *"If it's a European stock AND at least one party is European → Report it"*

Now the BMW trade between New York and Singapore correctly gets marked as "Not Reportable."

---

### Did It Pass?

✅ **Yes.** 

We used a "Digital Auditor" called Imandra to mathematically verify our fix. It checked every possible combination of trades and confirmed:

> *"An over-the-counter trade between two non-European parties will NEVER be flagged for reporting — no matter what stock they're trading."*

This isn't just testing with examples. It's a mathematical proof that covers every possible scenario.

---

### The Bottom Line

| Before | After |
|--------|-------|
| BMW trade between US and Singapore → **REPORTED** ❌ | BMW trade between US and Singapore → **NOT REPORTED** ✅ |
| Jurisdictional overreach | Proper boundaries |
| Potential compliance issues | Mathematically verified |

**For Compliance Officers:** You can now demonstrate to regulators that your reporting logic has been formally verified to respect jurisdictional boundaries.

**For Lawyers:** The invariant proof provides documentary evidence that the system cannot flag trades outside MiFID II scope.

**For Traders:** Your non-EU bilateral trades stay private as they should.

---

*Verified by Imandra — The Digital Auditor for Financial Logic*
