示例#1
0
def Import_ListOfQuotes_LSE(quotes,market='LSE SETS',dlg=None,x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = itrade_config.connectionTimeout
                               )

    import xlrd

    if market=='LSE SETS':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/sets/list-sets.xls'
    elif market=='LSE SETSqx':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/setsqx/ccp-securities.xls'
    elif market=='LSE SEAQ':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/seaq/list-seaq.xls'
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_LSE_%s:connect to %s' % (market,url))
    req = urllib2.Request(url)
    req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041202 Firefox/1.0')

    try:
        f = urllib2.urlopen(req)
        data = f.read()
    except:
        info('Import_ListOfQuotes_LSE_%s:unable to connect :-(' % market)
        return False

    # returns the data
    book = itrade_excel.open_excel(file=None,content=data)
    sh = book.sheet_by_index(0)
    n = 0
    indice = {}

    #print 'Import_ListOfQuotes_LSE_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
            if n==0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line,i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val=='ISIN': n = n + 1

                if n==1:
                    #if itrade_config.verbose: print 'Indice:',indice

                    iISIN = indice['ISIN']
                    iName = indice['Short Name']
                    iCurrency = indice['Currency']
                    iCountry = indice['Country of Register']
                    iTicker = indice['Mnemonic']

            else:
                ticker = sh.cell_value(line,iTicker)
                if type(ticker)==float: ticker='%s' % ticker
                if ticker[-1:]=='.':
                    ticker = ticker[:-1]
                    
                name = sh.cell_value(line,iName).replace(',',' ')
                name = name.encode('cp1252')
                name = name.replace('£',' ')
                name = name.replace('  ','')
                quotes.addQuote(isin=sh.cell_value(line,iISIN),name=name, \
                    ticker=ticker,market=market,\
                    currency=sh.cell_value(line,iCurrency),place='LON',\
                    country=sh.cell_value(line,iCountry))
                n = n + 1
    if itrade_config.verbose:
        print 'Imported %d/%d lines from %s' % (n,sh.nrows,market)

    return True
def Import_ListOfQuotes_LSE(quotes,market='LSE SETS',dlg=None,x=0):
    print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = itrade_config.connectionTimeout
                               )

    import xlrd

    if market=='LSE SETS':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/1BCC9E48-6846-411B-8F2A-06F1DD17EB22/0/ListofSETSsecurities.xls"
    elif market=='LSE SETSmm':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/6B92591A-68A2-4715-8333-F28FD517AB27/0/ListofSETSmmsecurities.xls"
    elif market=='LSE SEAQ':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/9731A6AB-B60B-469F-BE6B-A721247CE76C/0/ListofSEAQsecurities.xls"
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_LSE_%s:connect to %s' % (market,url))

    try:
        data = connection.getDataFromUrl(url)
    except:
        info('Import_ListOfQuotes_LSE_%s:unable to connect :-(' % market)
        return False

    #print data[:250]

    # returns the data
    book = itrade_excel.open_excel(file=None,content=data)
    sh = book.sheet_by_index(0)
    n = 0
    indice = {}

    print 'Import_ListOfQuotes_LSE_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
            if n==0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line,i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val=='ISIN': n = n + 1

                if n==1:
                    if itrade_config.verbose: print 'Indice:',indice

                    iISIN = indice['ISIN']
                    iName = indice['Short Name']
                    iCurrency = indice['Currency']
                    iCountry = indice['Country of Register']
                    iTicker = indice['Mnemonic']

            else:
                ticker = sh.cell_value(line,iTicker)
                if type(ticker)==float: ticker='%s' % ticker
                #print line,iTicker,ticker,type(ticker)
                if ticker[-1:]=='.':
                    ticker = ticker[:-1]
                name = sh.cell_value(line,iName).replace(',',' ')
                #print line,'>',sh.cell_value(line,iISIN),' : ',name,ticker
                quotes.addQuote(isin=sh.cell_value(line,iISIN),name=name, \
                    ticker=ticker,market=market,\
                    currency=sh.cell_value(line,iCurrency),place='LON',\
                    country=sh.cell_value(line,iCountry))

                n = n + 1

    print 'Imported %d/%d lines from %s data.' % (n,sh.nrows,market)

    return True
示例#3
0
def Import_ListOfQuotes_HKG(quotes,
                            market='HONG KONG EXCHANGE',
                            dlg=None,
                            x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies=None,
                                  proxy=itrade_config.proxyHostname,
                                  proxyAuth=itrade_config.proxyAuthentication)

    import xlrd

    if market == 'HONG KONG EXCHANGE':
        # Two urls for download list of HONG KONG EXCHANGE
        urls = [
            'http://www.hkex.com.hk/eng/market/sec_tradinfo/isincode/documents/isino.xls',
            'http://www.hkex.com.hk/eng/market/sec_tradinfo/isincode/documents/isinsehk.xls'
        ]

        n = 0
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x: x, lines)

        def removeCarriage(s):
            if s[-1] == '\r':
                return s[:-1]
            else:
                return s

        lines = [removeCarriage(l) for l in lines]
        return lines

    for url in urls:

        info('Import_ListOfQuotes_HKG_%s:connect to %s' % (market, url))

        try:
            data = connection.getDataFromUrl(url)
        except:
            info('Import_ListOfQuotes_HKG_%s:unable to connect :-(' % market)
            return False

        # returns the data
        book = itrade_excel.open_excel(file=None, content=data)
        sh = book.sheet_by_index(0)

        #print 'Import_ListOfQuotes_HKG_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

        for line in range(sh.nrows):
            if sh.cell_type(line, 1) != xlrd.XL_CELL_EMPTY:
                if sh.cell_value(line,
                                 3) in ('ORD SH', 'PREF SH', 'TRT', 'RTS'):

                    isin = sh.cell_value(line, 1)

                    ticker = sh.cell_value(line, 2)
                    if type(ticker) == float:
                        ticker = int(ticker)
                        ticker = '%s' % ticker
                    if len(ticker) == 1: ticker = '000' + ticker
                    if len(ticker) == 2: ticker = '00' + ticker
                    if len(ticker) == 3: ticker = '0' + ticker

                    name = sh.cell_value(line, 0)

                    if ticker == '0657':
                        name = 'G-VISION INTERNATIONAL (HOLDINGS) LTD'

                    name = name.decode().encode('utf8')
                    name = name.replace(',', ' ')

                    currency = 'HKD'
                    place = 'HKG'
                    country = 'HK'

                    quotes.addQuote(isin=isin,
                                    name=name,
                                    ticker=ticker,
                                    market='HONG KONG EXCHANGE',
                                    currency=currency,
                                    place=place,
                                    country=country)

                    n = n + 1

    if itrade_config.verbose:
        print 'Imported %d lines from %s ' % (n, market)

    return True
示例#4
0
def Import_ListOfQuotes_OMX(quotes,market='STOCKHOLM EXCHANGE',dlg=None,x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection=ITradeConnection(cookies=None,
                                proxy=itrade_config.proxyHostname,
                                proxyAuth=itrade_config.proxyAuthentication)

    import xlrd

    # find url to update list
    ch ='href="/digitalAssets/'
    try:
        url = connection.getDataFromUrl('http://www.nasdaqomxnordic.com/shares?languadeID=1')
    except:
        info('Import_ListOfQuotes_OMX_%s:unable to get XLS file name :-(' % market)
        return False

    if url.find(ch):
        a = url.find(ch)+len(ch)
        endurl = url[a:url.index('"',a)]
    else:
        info('Import_ListOfQuotes_OMX_%s:unable to parse XLS file name :-(' % market)
        return False


    url = "http://www.nasdaqomxnordic.com/digitalAssets/" + endurl
    if market=='STOCKHOLM EXCHANGE':
        m_place='STO'
        country='SE'

    elif market=='COPENHAGEN EXCHANGE':
        #m_place='CSE'
        m_place='CPH'
        country='DK'
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_OMX_%s:connect to %s' % (market,url))

    try:
        data = connection.getDataFromUrl(url)
    except:
        info('Import_ListOfQuotes_OMX_%s:unable to connect :-(' % market)
        return False
    
    # returns the data
    book = itrade_excel.open_excel(file=None,content=data)
    sh = book.sheet_by_index(1)
    n = 0
    indice = {}
    country = ''

    #print 'Import_ListOfQuotes_OMX_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
            if n==0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line,i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val=='ISIN': n = n + 1

                if n==1:

                    iISIN = indice['ISIN']
                    iTicker = indice['Short Name']
                    iCurrency = indice['Currency']
                    iPlace = indice['Exchange']

            else:
                place=sh.cell_value(line,iPlace)

                if place == m_place :
                    if place == 'CPH' : place = 'CSE'
                    
                    isin=sh.cell_value(line,iISIN)

                    ticker = sh.cell_value(line,iTicker)
                    if type(ticker)==float: ticker='%s' % ticker
                    ticker=ticker.replace(' ','-')

                    name = sh.cell_value(line,0)
                    name = name.strip()
                    # caractere error in this name
                    # Black Earth Farming Ltd. SDB ('á' is between Farming and Ltd)
                    if 'Black Earth Farming' in name:
                        name = 'Black Earth Farming Ltd. SDB'

                    name = name.encode('cp1252')

                    name = name.replace('æ','ae')
                    name = name.replace('ä','a')
                    name = name.replace('å','a')
                    #name = name.replace('á',' ')not valid
                    name = name.replace('Å','A')
                    name = name.replace('ø','o')
                    name = name.replace('Ø','O')
                    name = name.replace('ó','o')
                    name = name.replace('ö','o')
                    name = name.replace('Ö','O')
                    name = name.replace('ü','u')
                    name = name.replace(',',' ')
                    
                    currency=sh.cell_value(line,iCurrency)
                    quotes.addQuote(isin = isin,name = name,ticker = ticker,market = market,currency=currency,place=place,country=country)

                    n = n + 1
    if itrade_config.verbose:
        print 'Imported %d/%d lines from %s' % (n-1,sh.nrows,market)

    return True
示例#5
0
def Import_ListOfQuotes_LSE(quotes, market='LSE SETS', dlg=None, x=0):
    print 'Update %s list of symbols' % market
    connection = ITradeConnection(
        cookies=None,
        proxy=itrade_config.proxyHostname,
        proxyAuth=itrade_config.proxyAuthentication,
        connectionTimeout=itrade_config.connectionTimeout)

    import xlrd

    if market == 'LSE SETS':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/1BCC9E48-6846-411B-8F2A-06F1DD17EB22/0/ListofSETSsecurities.xls"
    elif market == 'LSE SETSmm':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/6B92591A-68A2-4715-8333-F28FD517AB27/0/ListofSETSmmsecurities.xls"
    elif market == 'LSE SEAQ':
        url = "http://www.londonstockexchange.com/NR/rdonlyres/9731A6AB-B60B-469F-BE6B-A721247CE76C/0/ListofSEAQsecurities.xls"
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x: x, lines)

        def removeCarriage(s):
            if s[-1] == '\r':
                return s[:-1]
            else:
                return s

        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_LSE_%s:connect to %s' % (market, url))

    try:
        data = connection.getDataFromUrl(url)
    except:
        info('Import_ListOfQuotes_LSE_%s:unable to connect :-(' % market)
        return False

    #print data[:250]

    # returns the data
    book = itrade_excel.open_excel(file=None, content=data)
    sh = book.sheet_by_index(0)
    n = 0
    indice = {}

    print 'Import_ListOfQuotes_LSE_%s:' % market, 'book', book, 'sheet', sh, 'nrows=', sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line, 1) != xlrd.XL_CELL_EMPTY:
            if n == 0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line, i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val == 'ISIN': n = n + 1

                if n == 1:
                    if itrade_config.verbose: print 'Indice:', indice

                    iISIN = indice['ISIN']
                    iName = indice['Short Name']
                    iCurrency = indice['Currency']
                    iCountry = indice['Country of Register']
                    iTicker = indice['Mnemonic']

            else:
                ticker = sh.cell_value(line, iTicker)
                if type(ticker) == float: ticker = '%s' % ticker
                #print line,iTicker,ticker,type(ticker)
                if ticker[-1:] == '.':
                    ticker = ticker[:-1]
                name = sh.cell_value(line, iName).replace(',', ' ')
                #print line,'>',sh.cell_value(line,iISIN),' : ',name,ticker
                quotes.addQuote(isin=sh.cell_value(line,iISIN),name=name, \
                    ticker=ticker,market=market,\
                    currency=sh.cell_value(line,iCurrency),place='LON',\
                    country=sh.cell_value(line,iCountry))

                n = n + 1

    print 'Imported %d/%d lines from %s data.' % (n, sh.nrows, market)

    return True
示例#6
0
def Import_ListOfQuotes_OMX(quotes,market='STOCKHOLM EXCHANGE',dlg=None,x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection=ITradeConnection(cookies=None,
                                proxy=itrade_config.proxyHostname,
                                proxyAuth=itrade_config.proxyAuthentication)

    import xlrd

    # find url to update list
    ch ='href="/digitalAssets/'
    try:
        url = connection.getDataFromUrl('http://www.nasdaqomxnordic.com/shares?languadeID=1')
    except:
        info('Import_ListOfQuotes_OMX_%s:unable to get XLS file name :-(' % market)
        return False

    if url.find(ch):
        a = url.find(ch)+len(ch)
        endurl = url[a:url.index('"',a)]
    else:
        info('Import_ListOfQuotes_OMX_%s:unable to parse XLS file name :-(' % market)
        return False


    url = "http://www.nasdaqomxnordic.com/digitalAssets/" + endurl
    if market=='STOCKHOLM EXCHANGE':
        m_place='STO'
        country='SE'

    elif market=='COPENHAGEN EXCHANGE':
        #m_place='CSE'
        m_place='CPH'
        country='DK'
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_OMX_%s:connect to %s' % (market,url))

    try:
        data = connection.getDataFromUrl(url)
    except:
        info('Import_ListOfQuotes_OMX_%s:unable to connect :-(' % market)
        return False
    
    # returns the data
    book = itrade_excel.open_excel(file=None,content=data)
    sh = book.sheet_by_index(1)
    n = 0
    indice = {}
    country = ''

    #print 'Import_ListOfQuotes_OMX_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
            if n==0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line,i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val=='ISIN': n = n + 1

                if n==1:

                    iISIN = indice['ISIN']
                    iTicker = indice['Short Name']
                    iCurrency = indice['Currency']
                    iPlace = indice['Exchange']

            else:
                place=sh.cell_value(line,iPlace)

                if place == m_place :
                    if place == 'CPH' : place = 'CSE'
                    
                    isin=sh.cell_value(line,iISIN)

                    ticker = sh.cell_value(line,iTicker)
                    if type(ticker)==float: ticker='%s' % ticker
                    ticker=ticker.replace(' ','-')

                    name = sh.cell_value(line,0)
                    name = name.strip()
                    # caractere error in this name
                    # Black Earth Farming Ltd. SDB ('á' is between Farming and Ltd)
                    if 'Black Earth Farming' in name:
                        name = 'Black Earth Farming Ltd. SDB'

                    name = name.encode('cp1252')

                    name = name.replace('æ','ae')
                    name = name.replace('ä','a')
                    name = name.replace('å','a')
                    #name = name.replace('á',' ')not valid
                    name = name.replace('Å','A')
                    name = name.replace('ø','o')
                    name = name.replace('Ø','O')
                    name = name.replace('ó','o')
                    name = name.replace('ö','o')
                    name = name.replace('Ö','O')
                    name = name.replace('ü','u')
                    name = name.replace(',',' ')
                    
                    currency=sh.cell_value(line,iCurrency)
                    quotes.addQuote(isin = isin,name = name,ticker = ticker,market = market,currency=currency,place=place,country=country)

                    n = n + 1
    if itrade_config.verbose:
        print 'Imported %d/%d lines from %s' % (n-1,sh.nrows,market)

    return True
示例#7
0
def Import_ListOfQuotes_LSE(quotes,market='LSE SETS',dlg=None,x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection = ITradeConnection(cookies = None,
                               proxy = itrade_config.proxyHostname,
                               proxyAuth = itrade_config.proxyAuthentication,
                               connectionTimeout = itrade_config.connectionTimeout
                               )

    import xlrd

    if market=='LSE SETS':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/sets/list-sets.xls'
    elif market=='LSE SETSqx':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/setsqx/ccp-securities.xls'
    elif market=='LSE SEAQ':
        url = 'http://www.londonstockexchange.com/products-and-services/trading-services/seaq/list-seaq.xls'
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    info('Import_ListOfQuotes_LSE_%s:connect to %s' % (market,url))
    req = urllib2.Request(url)
    req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041202 Firefox/1.0')

    try:
        f = urllib2.urlopen(req)
        data = f.read()
    except:
        info('Import_ListOfQuotes_LSE_%s:unable to connect :-(' % market)
        return False

    # returns the data
    book = itrade_excel.open_excel(file=None,content=data)
    sh = book.sheet_by_index(0)
    n = 0
    indice = {}

    #print 'Import_ListOfQuotes_LSE_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows

    for line in range(sh.nrows):
        if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
            if n==0:
                for i in range(sh.ncols):
                    val = sh.cell_value(line,i)
                    indice[val] = i

                    # be sure we have detected the title
                    if val=='ISIN': n = n + 1

                if n==1:
                    #if itrade_config.verbose: print 'Indice:',indice

                    iISIN = indice['ISIN']
                    iName = indice['Short Name']
                    iCurrency = indice['Currency']
                    iCountry = indice['Country of Register']
                    iTicker = indice['Mnemonic']

            else:
                ticker = sh.cell_value(line,iTicker)
                if type(ticker)==float: ticker='%s' % ticker
                if ticker[-1:]=='.':
                    ticker = ticker[:-1]
                    
                name = sh.cell_value(line,iName).replace(',',' ')
                name = name.encode('cp1252')
                name = name.replace('£',' ')
                name = name.replace('  ','')
                quotes.addQuote(isin=sh.cell_value(line,iISIN),name=name,
                    ticker=ticker,market=market,
                    currency=sh.cell_value(line,iCurrency),place='LON',
                    country=sh.cell_value(line,iCountry))
                n = n + 1
    if itrade_config.verbose:
        print 'Imported %d/%d lines from %s' % (n,sh.nrows,market)

    return True
def Import_ListOfQuotes_HKG(quotes,market='HONG KONG EXCHANGE',dlg=None,x=0):
    if itrade_config.verbose:
        print 'Update %s list of symbols' % market
    connection=ITradeConnection(cookies=None,
                                proxy=itrade_config.proxyHostname,
                                proxyAuth=itrade_config.proxyAuthentication)

    import xlrd

    if market=='HONG KONG EXCHANGE':
        # Two urls for download list of HONG KONG EXCHANGE
        urls = ['http://www.hkex.com.hk/eng/market/sec_tradinfo/isincode/documents/isino.xls','http://www.hkex.com.hk/eng/market/sec_tradinfo/isincode/documents/isinsehk.xls']
        
        n = 0        
    else:
        return False

    def splitLines(buf):
        lines = string.split(buf, '\n')
        lines = filter(lambda x:x, lines)
        def removeCarriage(s):
            if s[-1]=='\r':
                return s[:-1]
            else:
                return s
        lines = [removeCarriage(l) for l in lines]
        return lines

    for url in urls:

        info('Import_ListOfQuotes_HKG_%s:connect to %s' % (market,url))

        try:
            data = connection.getDataFromUrl(url)
        except:
            info('Import_ListOfQuotes_HKG_%s:unable to connect :-(' % market)
            return False


        # returns the data
        book = itrade_excel.open_excel(file=None,content=data)
        sh = book.sheet_by_index(0)

        #print 'Import_ListOfQuotes_HKG_%s:' % market,'book',book,'sheet',sh,'nrows=',sh.nrows


        for line in range(sh.nrows):
            if sh.cell_type(line,1) != xlrd.XL_CELL_EMPTY:
                if sh.cell_value(line,3) in ('ORD SH','PREF SH','TRT','RTS'):

                    isin=sh.cell_value(line,1)
                    
                    ticker = sh.cell_value(line,2)
                    if type(ticker)==float: ticker=int(ticker);ticker='%s' % ticker
                    if len(ticker) == 1 : ticker='000'+ticker
                    if len(ticker) == 2 : ticker='00'+ticker
                    if len(ticker) == 3 : ticker='0'+ticker
                            
                    name = sh.cell_value(line,0)

                    if ticker == '0657':
                        name = 'G-VISION INTERNATIONAL (HOLDINGS) LTD'
                        
                    name = name.decode().encode('utf8')
                    name = name.replace(',',' ')

                    currency='HKD'
                    place='HKG'
                    country='HK'
               
                    quotes.addQuote(isin = isin,name = name,ticker = ticker,market = 'HONG KONG EXCHANGE',currency = currency,place = place,country = country)

                    n = n + 1
                

    if itrade_config.verbose:
        print 'Imported %d lines from %s ' % (n,market)

    return True