MIC Validation in Python — ISO 10383 Exchange Codes
MIC codes identify exchanges and trading venues in trade reporting, order routing, and regulatory filings. Here's how the ISO 10383 standard works, the difference between operating and segment MICs, and how to validate them in your Python application.
In this guide
1. What is a MIC?
A MIC (Market Identifier Code) is a standardised 4-character alphanumeric code defined by ISO 10383. It uniquely identifies exchanges, trading platforms, regulated markets, and other trading venues worldwide.
MIC codes are maintained by SWIFT on behalf of ISO and are updated regularly as new venues are created, existing ones are restructured, and terminated exchanges are retired. The standard is used across MiFID II reporting, EMIR trade repositories, FIX protocol messages, and virtually every institutional trading workflow.
XNAS) and several segment MICs for its different market tiers and trading systems.2. MIC structure
Every MIC code is exactly 4 characters, all uppercase alphanumeric. The code itself is an opaque identifier — unlike ISINs or CFI codes, the characters do not encode structured meaning, though by convention many MICs start with X for exchange-level identifiers.
| Property | Rule | Example |
|---|---|---|
| Length | Exactly 4 characters | XNAS |
| Character set | Uppercase A–Z and digits 0–9 | XLON, XHKG |
| Type: Operating (OPRT) | Identifies the exchange or trading venue as a whole | XNAS (NASDAQ) |
| Type: Segment (SGMT) | Identifies a specific market segment within an operating MIC | XNGS (NASDAQ Global Select) |
3. Why MIC validation matters
MiFID II transaction reporting
Under MiFID II, investment firms must report the venue of execution using a valid MIC code. Invalid or terminated MICs cause trade reports to be rejected by national competent authorities, triggering compliance exceptions and potential fines.
EMIR derivatives reporting
EMIR requires counterparties to report derivative contracts to trade repositories with the execution venue identified by MIC. Using a decommissioned or incorrect MIC results in rejected submissions and regulatory scrutiny.
Order routing and smart order routing (SOR)
Trading systems use MIC codes to route orders to the correct venue. A mistyped MIC can route orders to the wrong exchange or cause routing failures, directly impacting execution quality and best-execution obligations.
Data quality and reference data management
Financial data feeds use MIC codes extensively. Validating MICs at ingestion time ensures that exchange identifiers in your database are current and correctly mapped to the right venues, preventing downstream data quality issues.
4. The right solution
The IsValid MIC API validates a MIC code against the official ISO 10383 registry and returns enriched venue metadata — including the exchange name, type (operating or segment), status, country, city, and website. The registry is kept up to date so you do not need to maintain your own copy of the SWIFT MIC database.
Full parameter reference and response schema: MIC Validation API docs →
5. Python code example
Using the isvalid-sdk package or the requests library. Install with pip install isvalid-sdk or pip install requests.
# mic_validator.py import os from isvalid_sdk import IsValidConfig, create_client iv = create_client(IsValidConfig(api_key=os.environ["ISVALID_API_KEY"])) result = iv.mic("XNAS") print(result["valid"]) # True print(result["found"]) # True print(result["name"]) # 'NASDAQ' print(result["type"]) # 'OPRT' print(result["status"]) # 'ACTV' print(result["countryCode"]) # 'US' print(result["city"]) # 'NEW YORK' print(result["operatingMic"]) # 'XNAS'
In a trade reporting pipeline — validating execution venue before submission:
# Validate execution venue MIC before regulatory submission def validate_trade_venue(trade: dict) -> dict: mic = validate_mic(trade["execution_venue"]) if not mic["valid"] or not mic["found"]: raise ValueError(f"Unknown execution venue: {trade['execution_venue']}") if mic["status"] != "ACTV": raise ValueError( f"Venue {mic['mic']} ({mic['name']}) has status {mic['status']} " f"— cannot report trades against a non-active venue" ) # For MiFID II, some reports require the operating MIC return { **trade, "execution_venue_mic": mic["mic"], "operating_mic": mic["operatingMic"], "venue_name": mic["name"], "venue_country": mic["countryCode"], "venue_type": mic["type"], }
.upper() before sending the request.6. cURL example and response
Validate an operating MIC (NASDAQ):
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/mic?value=XNAS"
Validate a segment MIC (NASDAQ Global Select):
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.isvalid.dev/v0/mic?value=XNGS"
Valid MIC response (XNAS):
{ "valid": true, "found": true, "mic": "XNAS", "operatingMic": "XNAS", "name": "NASDAQ", "type": "OPRT", "status": "ACTV", "countryCode": "US", "countryName": "United States of America", "city": "NEW YORK", "website": "https://www.nasdaq.com" }
Invalid MIC response:
{ "valid": false, "found": false, "mic": "ZZZZ" }
| Field | Type | Description |
|---|---|---|
| valid | boolean | Whether the input is a structurally valid 4-character MIC |
| found | boolean | Whether the MIC exists in the ISO 10383 registry |
| mic | string | Normalised (uppercase) 4-character code |
| operatingMic | string | The parent operating MIC (same as mic for OPRT types) |
| name | string | Official exchange or venue name |
| type | string | OPRT (operating) or SGMT (segment) |
| status | string | ACTV, TERM, EXPI, or MODI |
| countryCode | string | ISO 3166-1 alpha-2 country code |
| countryName | string | null | Full country name, or null if unavailable |
| city | string | City where the venue is located |
| website | string | null | Venue website URL, or null if unavailable |
7. Edge cases
Operating vs segment MICs
An operating MIC (type OPRT) identifies the exchange as a whole. A segment MIC (type SGMT) identifies a specific market segment within that exchange. The operatingMic field always points back to the parent operating MIC.
# XNGS is a segment MIC under XNAS segment = iv.mic("XNGS") print(segment["type"]) # 'SGMT' print(segment["operatingMic"]) # 'XNAS' print(segment["name"]) # 'NASDAQ/NMS (GLOBAL SELECT MARKET)' # XNAS is an operating MIC — operatingMic points to itself operating = iv.mic("XNAS") print(operating["type"]) # 'OPRT' print(operating["operatingMic"]) # 'XNAS'
Terminated and expired exchanges
The ISO 10383 registry retains MICs for exchanges that have been terminated (TERM), expired (EXPI), or modified (MODI). These MICs are still found in the registry but should not be used for new trade reporting.
result = iv.mic("XVTX") if result["found"] and result["status"] != "ACTV": print( f"MIC {result['mic']} exists but has status {result['status']} " f"— consider using the replacement venue" )
Status codes explained
| Status | Meaning | Use in reporting |
|---|---|---|
| ACTV | Active — venue is operational | Safe to use |
| TERM | Terminated — venue has been decommissioned | Do not use for new reports |
| EXPI | Expired — MIC allocation has lapsed | Do not use for new reports |
| MODI | Modified — venue details have changed | Check updated details before use |
8. Summary
See also
Validate MIC codes instantly
Free tier includes 100 API calls per day. No credit card required. Full ISO 10383 registry lookup with venue metadata, status, and operating MIC resolution.