# Store the notation of the website
# Last updated: 2026-01-14 from https://www.casablanca-bourse.com/en/marche-cash/instruments-actions
# Includes common aliases (CFG, CMG, IAM, MDP) for user convenience
def notation(): 
	return ['Addoha',
 'AFMA',
 'Afric Indus',
 'Afriquia Gaz',
 'Agma',
 'Akdital',
 'Alliances',
 'Aluminium Maroc',
 'Aradei Capital',
 'ATLANTASANAD',
 'Attijariwafa',
 'Auto Hall',
 'Auto Nejma',
 'BALIMA',
 'BOA',
 'BCP',
 'BMCI',
 'Cartier Saada',
 'Cash Plus',
 'CDM',
 'CFG Bank',
 'CIH',
 'Ciments Maroc',
 'CMGP Group',
 'CMT',
 'Colorado',
 'COSUMAR',
 'CTM',
 'Dari Couspate',
 'Delattre Levivier',
 'Delta Holding',
 'DIAC Salaf',
 'Disty Technolog',
 'DISWAY',
 'Ennakl',
 'EQDOM',
 'FENIE BROSSETTE',
 'HPS',
 'IBMaroc',
 'Immr Invest',
 'INVOLYS',
 'Jet Contractors',
 'LABEL VIE',
 'LafargeHolcim',
 'Lesieur Cristal',
 'M2M Group',
 'Maghreb Oxygene',
 'Maghrebail',
 'Managem',
 'Maroc Leasing',
 'Maroc Telecom',
 'Med Paper',
 'Microdata',
 'Mutandis',
 'Oulmes',
 'PROMOPHARM',
 'Rebab Company',
 'Res.Dar Saada',
 'Risma',
 'S2M',
 'Sanlam Maroc',
 'SALAFIN',
 'SGTM',
 'SMI',
 'Stokvis Nord Afr',
 'SNEP',
 'SODEP',
 'Sonasid',
 'SOTHEMA',
 'SRM',
 'Ste Boissons',
 'STROC Indus',
 'TAQA Morocco',
 'TGCC',
 'Timar',
 'Total Maroc',
 'Unimer',
 'Wafa Assur',
 'Zellidja',
 'MASI',
 'MSI20']
	
def notation_code():
      return [{'name': 'Addoha', 'ISIN': 'MA0000011512'},
 {'name': 'AFMA', 'ISIN': 'MA0000012296'},
 {'name': 'Afric Indus', 'ISIN': 'MA0000012114'},
 {'name': 'Afriquia Gaz', 'ISIN': 'MA0000010951'},
 {'name': 'Agma', 'ISIN': 'MA0000010944'},
 {'name': 'Akdital', 'ISIN': 'MA0000012585'},
 {'name': 'Alliances', 'ISIN': 'MA0000011819'},
 {'name': 'Aluminium Maroc', 'ISIN': 'MA0000010936'},
 {'name': 'Aradei Capital', 'ISIN': 'MA0000012460'},
 {'name': 'ATLANTASANAD', 'ISIN': 'MA0000011710'},
 {'name': 'Attijariwafa', 'ISIN': 'MA0000012445'},
 {'name': 'Auto Hall', 'ISIN': 'MA0000010969'},
 {'name': 'Auto Nejma', 'ISIN': 'MA0000011009'},
 {'name': 'BALIMA', 'ISIN': 'MA0000011991'},
 {'name': 'BOA', 'ISIN': 'MA0000012437'},
 {'name': 'BCP', 'ISIN': 'MA0000011884'},
 {'name': 'BMCI', 'ISIN': 'MA0000010811'},
 {'name': 'Cartier Saada', 'ISIN': 'MA0000011868'},
 {'name': 'Cash Plus', 'ISIN': 'MA0000012767'},
 {'name': 'CDM', 'ISIN': 'MA0000010381'},
 {'name': 'CFG Bank', 'ISIN': 'MA0000012627'},
 {'name': 'CFG', 'ISIN': 'MA0000012627'},  # Alias for CFG Bank
 {'name': 'CIH', 'ISIN': 'MA0000011454'},
 {'name': 'Ciments Maroc', 'ISIN': 'MA0000010506'},
 {'name': 'CMGP Group', 'ISIN': 'MA0000012718'},
 {'name': 'CMG', 'ISIN': 'MA0000012718'},  # Alias for CMGP Group
 {'name': 'CMT', 'ISIN': 'MA0000011793'},
 {'name': 'Colorado', 'ISIN': 'MA0000011934'},
 {'name': 'COSUMAR', 'ISIN': 'MA0000012247'},
 {'name': 'CTM', 'ISIN': 'MA0000010340'},
 {'name': 'Dari Couspate', 'ISIN': 'MA0000011421'},
 {'name': 'Delattre Levivier', 'ISIN': 'MA0000012551'},
 {'name': 'Delta Holding', 'ISIN': 'MA0000011850'},
 {'name': 'DIAC Salaf', 'ISIN': 'MA0000010639'},
 {'name': 'Disty Technolog', 'ISIN': 'MA0000012536'},
 {'name': 'DISWAY', 'ISIN': 'MA0000011637'},
 {'name': 'Ennakl', 'ISIN': 'MA0000011942'},
 {'name': 'EQDOM', 'ISIN': 'MA0000010357'},
 {'name': 'FENIE BROSSETTE', 'ISIN': 'MA0000011587'},
 {'name': 'HPS', 'ISIN': 'MA0000011611'},
 {'name': 'IBMaroc', 'ISIN': 'MA0000011132'},
 {'name': 'Immr Invest', 'ISIN': 'MA0000012387'},
 {'name': 'INVOLYS', 'ISIN': 'MA0000011579'},
 {'name': 'Jet Contractors', 'ISIN': 'MA0000012080'},
 {'name': 'LABEL VIE', 'ISIN': 'MA0000011801'},
 {'name': 'LafargeHolcim', 'ISIN': 'MA0000012320'},
 {'name': 'Lesieur Cristal', 'ISIN': 'MA0000012031'},
 {'name': 'M2M Group', 'ISIN': 'MA0000011678'},
 {'name': 'Maghreb Oxygene', 'ISIN': 'MA0000010985'},
 {'name': 'Maghrebail', 'ISIN': 'MA0000011215'},
 {'name': 'Managem', 'ISIN': 'MA0000011058'},
 {'name': 'Maroc Leasing', 'ISIN': 'MA0000010035'},
 {'name': 'Maroc Telecom', 'ISIN': 'MA0000011488'},
 {'name': 'IAM', 'ISIN': 'MA0000011488'},  # Alias for Maroc Telecom (Itissalat Al-Maghrib)
 {'name': 'ITISSALAT', 'ISIN': 'MA0000011488'},  # Alias for Maroc Telecom
 {'name': 'Med Paper', 'ISIN': 'MA0000012593'},
 {'name': 'MDP', 'ISIN': 'MA0000012593'},  # Alias for Med Paper
 {'name': 'Microdata', 'ISIN': 'MA0000012163'},
 {'name': 'Mutandis', 'ISIN': 'MA0000012395'},
 {'name': 'Oulmes', 'ISIN': 'MA0000010415'},
 {'name': 'PROMOPHARM', 'ISIN': 'MA0000011660'},
 {'name': 'Rebab Company', 'ISIN': 'MA0000010993'},
 {'name': 'Res.Dar Saada', 'ISIN': 'MA0000012239'},
 {'name': 'Risma', 'ISIN': 'MA0000011462'},
 {'name': 'S2M', 'ISIN': 'MA0000012106'},
 {'name': 'Sanlam Maroc', 'ISIN': 'MA0000012007'},
 {'name': 'SAM', 'ISIN': 'MA0000012007'},  # Alias for Sanlam Maroc
 {'name': 'SALAFIN', 'ISIN': 'MA0000011744'},
 {'name': 'SGTM', 'ISIN': 'MA0000012783'},
 {'name': 'SMI', 'ISIN': 'MA0000010068'},
 {'name': 'Stokvis Nord Afr', 'ISIN': 'MA0000011843'},
 {'name': 'SNEP', 'ISIN': 'MA0000011728'},
 {'name': 'SODEP', 'ISIN': 'MA0000012312'},
 {'name': 'Sonasid', 'ISIN': 'MA0000010019'},
 {'name': 'SOTHEMA', 'ISIN': 'MA0000012502'},
 {'name': 'SRM', 'ISIN': 'MA0000011595'},
 {'name': 'Ste Boissons', 'ISIN': 'MA0000010365'},
 {'name': 'STROC Indus', 'ISIN': 'MA0000012056'},
 {'name': 'TAQA Morocco', 'ISIN': 'MA0000012205'},
 {'name': 'TGCC', 'ISIN': 'MA0000012528'},
 {'name': 'Timar', 'ISIN': 'MA0000011686'},
 {'name': 'Total Maroc', 'ISIN': 'MA0000012262'},
 {'name': 'Unimer', 'ISIN': 'MA0000012023'},
 {'name': 'Wafa Assur', 'ISIN': 'MA0000010928'},
 {'name': 'Zellidja', 'ISIN': 'MA0000010571'},
 {'name': 'MASI', 'ISIN': ''},
 {'name': 'MSI20', 'ISIN': ''}]
    
def notation_value():
  """Return mapping of asset names to their internal codes (codeValeur) for casablanca-bourse.com API.
  
  Includes common aliases (CFG, CMG, IAM, MDP, SAM) for user convenience.
  """
  return {
    'Addoha': '9000', 'AFMA': '12200', 'Afric Indus': '11700', 'Afriquia Gaz': '7100',
    'Agma': '6700', 'Akdital': '35', 'Alliances': '11200', 'Aluminium Maroc': '6600',
    'Aradei Capital': '27', 'ATLANTASANAD': '10300', 'Attijariwafa': '8200',
    'Auto Hall': '3200', 'Auto Nejma': '7000', 'BALIMA': '3300', 'BOA': '1100',
    'BCP': '8000', 'BMCI': '5100', 'Cartier Saada': '8900', 'Cash Plus': '40',
    'CDM': '3600', 'CFG Bank': '38', 'CFG': '38',  # Alias for CFG Bank
    'CIH': '3100', 'Ciments Maroc': '4000', 'CMGP Group': '39', 'CMG': '39',  # Alias for CMGP Group
    'CMT': '11000', 'Colorado': '9200', 'COSUMAR': '4100', 'CTM': '2200',
    'Dari Couspate': '8500', 'Delattre Levivier': '10800', 'Delta Holding': '10900',
    'DIAC Salaf': '36', 'Disty Technolog': '32', 'DISWAY': '9700', 'Ennakl': '11300',
    'EQDOM': '2300', 'FENIE BROSSETTE': '9300', 'HPS': '9600', 'IBMaroc': '7600',
    'Immr Invest': '12', 'INVOLYS': '9500', 'Jet Contractors': '11600',
    'LABEL VIE': '11100', 'LafargeHolcim': '3800', 'Lesieur Cristal': '4800',
    'M2M Group': '10000', 'Maghreb Oxygene': '7200', 'Maghrebail': '1600',
    'Managem': '7300', 'Maroc Leasing': '2500', 'Maroc Telecom': '8001',
    'IAM': '8001', 'ITISSALAT': '8001',  # Aliases for Maroc Telecom
    'Med Paper': '37', 'MDP': '37',  # Alias for Med Paper
    'Microdata': '10600', 'Mutandis': '21', 'Oulmes': '5200', 'PROMOPHARM': '9900',
    'Rebab Company': '5300', 'Res.Dar Saada': '12000', 'Risma': '8700', 'S2M': '11800',
    'Sanlam Maroc': '11400', 'SAM': '11400',  # Alias for Sanlam Maroc
    'SALAFIN': '10700', 'SGTM': '41', 'SMI': '1500', 'Stokvis Nord Afr': '10500',
    'SNEP': '9400', 'SODEP': '12300', 'Sonasid': '1300', 'SOTHEMA': '9800',
    'SRM': '2000', 'Ste Boissons': '10400', 'STROC Indus': '11500',
    'TAQA Morocco': '11900', 'TGCC': '29', 'Timar': '10100', 'Total Maroc': '12100',
    'Unimer': '7500', 'Wafa Assur': '6400', 'Zellidja': '5800'
  }


def list_assets():
    """Return a sorted list of available asset names."""
    return sorted(notation())


def get_isin_by_name(name: str) -> str:
    """Return the ISIN code for a given asset name (case-insensitive). Raises KeyError if not found."""
    for rec in notation_code():
        if rec['name'].lower() == name.lower():
            return rec['ISIN']
    raise KeyError(f"Asset not found: {name}")
