Guide · Python · SDK · REST API

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.

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.

ℹ️A single exchange can have multiple MIC codes. For example, NASDAQ has an operating MIC (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.

PropertyRuleExample
LengthExactly 4 charactersXNAS
Character setUppercase A–Z and digits 0–9XLON, XHKG
Type: Operating (OPRT)Identifies the exchange or trading venue as a wholeXNAS (NASDAQ)
Type: Segment (SGMT)Identifies a specific market segment within an operating MICXNGS (NASDAQ Global Select)
⚠️Operating and segment MICs are distinct codes. An operating MIC groups one or more segment MICs under it. When reporting trades, regulators may require either the operating MIC or the specific segment MIC depending on the jurisdiction and reporting regime.

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.

ISO 10383
Standard
official SWIFT MIC registry
<10ms
Response time
pure in-memory lookup
100/day
Free tier
no credit card

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"],
    }
The API accepts both lowercase and uppercase input — it normalises the value internally. You do not need to call .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"
}
FieldTypeDescription
validbooleanWhether the input is a structurally valid 4-character MIC
foundbooleanWhether the MIC exists in the ISO 10383 registry
micstringNormalised (uppercase) 4-character code
operatingMicstringThe parent operating MIC (same as mic for OPRT types)
namestringOfficial exchange or venue name
typestringOPRT (operating) or SGMT (segment)
statusstringACTV, TERM, EXPI, or MODI
countryCodestringISO 3166-1 alpha-2 country code
countryNamestring | nullFull country name, or null if unavailable
citystringCity where the venue is located
websitestring | nullVenue 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

StatusMeaningUse in reporting
ACTVActive — venue is operationalSafe to use
TERMTerminated — venue has been decommissionedDo not use for new reports
EXPIExpired — MIC allocation has lapsedDo not use for new reports
MODIModified — venue details have changedCheck updated details before use

8. Summary

Do not hardcode MIC lists — the ISO 10383 registry is updated regularly as venues change
Do not report trades against TERM or EXPI MICs — regulators will reject the submission
Check the status field — only ACTV MICs should be used for new trade reporting
Use operatingMic to resolve segment MICs back to their parent exchange
Validate MICs at data ingestion time to catch malformed venue identifiers early
Combine with ISIN and LEI validation for complete MiFID II and EMIR compliance

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.