Importing stock names

I have many stocks without company names in my EOD stock database which includes Canadian stocks. I would like to import/update the company names. "Tools/Update US symbol list and categories" does not work for this - company names are still missing.
I have an .xml file that list all the current symbols and company names. But how can I import it to Amibroker? Does anyone have a script that could do it?

Tools/Update US symbol list and categories works perfectly fine, but obviously, as its name says updates US (United States) symbols, not Canadian ones.

And, no XML can not be directly imported. You have to convert XML to CSV and then you can import http://www.amibroker.com/guide/d_ascii.html

By the way it is all described long time ago in the Knowledge Base:

http://www.amibroker.com/kb/2016/01/23/how-to-create-custom-import-definition-for-ascii-importer/

2 Likes

@Wojtek, if your XML file is record-oriented, you can try some online converter like this one (or similar) and then follow the instructions to import the names in your database from the resulting .csv file.

If this file contains more tickers than those in your database, you should uncheck the "Automatically add new symbols" to import the names ONLY for the existing tickers.

Moreover, if you never tried this kind of operations, I suggest to make a full backup of your AmiBroker database, so if something is wrong, you can always revert to the previous version,

Full Name Symbol. US Stock from Amiquate

Hello Mr Tomasz, can the full name symbol also be completed? I download from Amiqoute. Thanks

For US stocks, full names are downloadable using Tools->Update US symbols and categories.

1 Like

I've managed to write a VBA script that has worked very well for me for my Canadian stocks. It requires a CSV data file, however, which I downloaded from EODdata.com.
The code uses Excel VBA and must be copied into an Excel VBA module and run from there.

Sub ImportNames()

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script takes about 40min to run, can be interrupted by closing progress window
' PREPARATION:
' 1. Get CVS data for all exchanges in correct format:
'      - Ticker in column 1, Full name in column 2
'      - Use correct ticker extensions for foreign symbols e.g .TO And .V for Canada
'      - Data must be sorted alphabetically by ticker for VLOOKUP to work!
' 2. Bring all CSV files into a Workbook
' 3. Name all data worksheets with Market names same as in Amibroker
' 4. Edit code below to correspond to the markets used and your database path
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim index As Integer
Dim thisTicker As String
Dim newName As String
Dim startTime As Long
Dim endTime As Long
Dim elapsed As Long
Dim stockItems As Integer
Dim oldName As String


'''''''' Define Excel data ranges ''''''''''''''''''

rangeTSX = Range("TSX!A1:B10000") 'MarketID 1
rangeNASDAQ = Range("NASDAQ!A1:B10000") ' marketID 2
rangeAMEX = Range("AMEX!A1:B10000") 'MarketID 3
rangeNYSE = Range("NYSE!A1:B10000") 'MarketID 4
rangeCDNX = Range("CDNX!A1:B10000") 'MarketID 5

''''''''''''  Setup progress window '''''''''''''''''

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "about:blank"

While ie.ReadyState <> 4: WScript.sleep 100: Wend

ie.Toolbar = False
ie.StatusBar = False
ie.Width = 400
ie.Height = 300

ie.document.body.innerHTML = "<p id='msg'>0</p>"

Set Style = ie.document.CreateStyleSheet
Style.AddRule "p", "text-align: center;"

ie.Visible = True

''''''''''''' Amibroker database scanning '''''''''''''

startTime = Timer()
Set AB = CreateObject("Broker.Application")
AB.LoadDatabase ("C:\Program Files\AmiBroker\New EOD")
      
stockItems = AB.Stocks.Count - 1

    For index = 0 To stockItems
        
        Set thisStock = AB.Stocks.Item(index)
        
        thisTicker = thisStock.ticker
        newName = AB.Stocks.Item(index).FullName 'this in case of error, see below
        whichMarket = thisStock.MarketID
                
        On Error Resume Next 'error is produced when existing Amibroker ticker is not found on VLookup
                   
        If whichMarket = 1 Then
            newName = Application.WorksheetFunction.VLookup(thisTicker, rangeTSX, 2, False)
        ElseIf whichMarket = 2 Then
            newName = Application.WorksheetFunction.VLookup(thisTicker, rangeNASDAQ, 2, False)
        ElseIf whichMarket = 3 Then
            newName = Application.WorksheetFunction.VLookup(thisTicker, rangeAMEX, 2, False)
        ElseIf whichMarket = 4 Then
            newName = Application.WorksheetFunction.VLookup(thisTicker, rangeNYSE, 2, False)
        ElseIf whichMarket = 5 Then
            newName = Application.WorksheetFunction.VLookup(thisTicker, rangeCDNX, 2, False)
        Else
            newName = newName
        End If
               
        thisStock.FullName = newName 'adopts new name or keeps old name if error
        ie.document.getElementById("msg").innerText = "Processing record: " & vbCrLf & vbCrLf & index & "/" & stockItems & vbCrLf & whichMarket & vbCrLf & thisTicker
        
    Next index
    
endTime = Timer()
elapsed = Round((endTime - startTime) / 60, 0)

ie.document.getElementById("msg").innerText = "Script finished " & vbCrLf & vbCrLf & "Time elapsed: " & elapsed & "min"
  
End Sub



Thank you very much Mr Tomasz

AmiQuare long time to update To much Stock

Oh my God, there are so many stocks. From previously 800, now 7437 symbols. Up almost 10x, it will take a long time to update from AmiQuate :joy:

If you wish you can update only those you are interested in either by deleting those you don't need or by using ticker lists in AmiQuote to update only symbols that appear on list.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.