Talk:SEDOL
From Wikipedia, the free encyclopedia
shouldn't it be United Kingdom rather than England?
Can someone describe the rules for creating valid "dummy" sedol codes? Is it just that they start with a "9" or is there more to it than that?
[edit] Validation of SEDOLs
FYI, python code that will validate a SEDOL string:
class SEDOLException(Exception): """Blank exception""" pass def validateSEDOL(sedol_str): """Check a SEDOL string for correctness""" if len(sedol_str) != 7: raise SEDOLException('SEDOL must be 7 characters long') correct_checkDigit = calcSEDOLCheckDigit(sedol_str[:-1]) if correct_checkDigit != sedol_str[-1:]: raise SEDOLException("Checkdigit '%s' is incorrect. It should be '%s'" % (sedol_str[-1:], correct_checkDigit)) def calcSEDOLCheckDigit(sedol_str): """Calculate the checkdigit for a 6 character SEDOL""" digit_weight = [1, 3, 1, 7, 3, 9] #Convert letters to digits sedol_digits = [] for char in sedol_str: if char.isalpha(): sedol_digits.append((string.ascii_uppercase.index(char.upper()) + 9 + 1)) else: sedol_digits.append(char) #Multiply each digit by the appropriate weight sedol_sum = sum([int(sedol_digits[i])*digit_weight[i] for i in range(6)]) checkdigit = ((10 - (sedol_sum % 10))) % 10 return str(checkdigit)
Rob cowie 12:22, 15 December 2006 (UTC)