Each `exchange` code must map to exactly one `mic`. Mirrors `test_exchange_market_one_to_one`: a single exchange code resolving to multiple MICs signals drift in the exchange-to-MIC mapping.
()
| 270 | |
| 271 | |
| 272 | def test_exchange_mic_one_to_one() -> None: |
| 273 | """Each `exchange` code must map to exactly one `mic`. |
| 274 | |
| 275 | Mirrors `test_exchange_market_one_to_one`: a single exchange code resolving |
| 276 | to multiple MICs signals drift in the exchange-to-MIC mapping. |
| 277 | """ |
| 278 | df = equities.select() |
| 279 | pairs = df.dropna(subset=["exchange", "mic"]) |
| 280 | by_exchange = pairs.groupby("exchange")["mic"].nunique() |
| 281 | ambiguous = by_exchange[by_exchange > 1] |
| 282 | assert ( |
| 283 | ambiguous.empty |
| 284 | ), f"Exchange codes mapping to multiple MICs: {ambiguous.to_dict()}" |
| 285 | |
| 286 | |
| 287 | def test_mic_filled_when_exchange_mapped() -> None: |