OBJECTIVE
The objective for this tutorial is to setup a Nasdaq Composite database including Group, Sector , Index, and Watch-list categorization.
SPECIFICATIONS
- AmiBroker: Standard v5.0
- Amiquote: v1.94 registered
- Time Frame: Daily
- Data Source: Yahoo
- Data Type: US Stocks
- OS: Windows XP (Home)
- Software: Microsoft Office XP Professional 2002
- Browser: Internet Explorer v7.0
PRE-REQUISITES
Readers should be familiar with the Users’ Knowledge Base (UKB) posts, Exchanges >> Nasdaq’s Stock Screener and Indexes >> The Nasdaq Indexes, that explain how to download the ticker lists, used in this example, from the Nasdaq site.
INTRODUCTION
This article builds on the ‘template’ established in the UKB post Database Management >> Setup A Custom Database by applying the same ‘top-down’ method, of setting up a database, to the broad based Nasdaq Composite Index (^IXIC). The ‘template’ has been adapted to suit the new Watch list procedures introduced in AmiBroker v 5.0 and also to accommodate the available data set for the Nasdaq Exchange.
Note: An unequivocal method is given, to avoid confusing readers, but in reality there are many possible custom databases and several ways of constructing each of them within AmiBroker. Readers will need to creatively apply the skills and tools demonstrated in this post, and possibly a few more besides, when building custom databases of their own.
PREPARATION
The component lists, used in this example, are recorded in Table 1 (down-loadable copies are attached near the end of this post).
Table 1
| LIST |
SYMBOL COUNT |
FILE TYPE |
FILE CONTENTS |
| Composite |
3094 |
CSV |
Fullname, Symbol |
| |
|
|
|
| Capital Market |
458 |
CSV |
Symbol, Fullname |
| National Market |
2531 |
CSV |
Symbol, Fullname |
| N&C Mkt TOTAL |
2989 |
|
|
| |
|
|
|
| Bank |
519 |
CSV |
Fullname, Symbol |
| BioTech |
170 |
CSV |
Fullname, Symbol |
| Computer |
529 |
CSV |
Fullname, Symbol |
| Healthcare |
535 |
CSV |
Fullname, Symbol |
| Industrial |
1109 |
CSV |
Fullname, Symbol |
| Insurance |
64 |
CSV |
Fullname, Symbol |
| Other Finance |
94 |
CSV |
Fullname, Symbol |
| Telecommunications |
177 |
CSV |
Fullname, Symbol |
| Transportation |
65 |
CSV |
Fullname, Symbol |
| Sectors TOTAL |
3262 |
|
|
| |
|
|
|
| Nasdaq100 |
100 |
CSV |
Fullname, Symbol |
| Nasdaq100 Tech |
41 |
CSV |
Fullname, Symbol |
| Nasdaq100 ExTech |
59 |
CSV |
Fullname, Symbol |
| Nasdaq100 Financial |
100 |
CSV |
Fullname, Symbol |
| |
|
|
|
| Indexes |
14 |
TXT |
Fullname, Symbol |
As stated in the pre-requistes section, they were downloaded from the Nasdaq Exchange site. Most of them can also be downloaded, in batches, from the Yahoo!Finance site http://finance.yahoo.com/indices?e=nasdaq by selecting the Components link on that page ( a one-off check showed that the lists used by the author and the lists available at Yahoo did not tally but they they were downloaded at different times, within the range of a week or two).

Note: The NasdaqHealthcare sector is not included in the Yahoo listings (the Healthcare Index symbol, ^IXHC, does, however, return prices and a component list when entered in a Get Quotes search). For this example, the Nasdaq lists were preferred, over the Yahoo lists, because of the superior downloading capabilities and (assumed) superior accuracy of the Nasdaq versions.
The list of sub-indexes, that are derived from the Nasdaq Composite, wasn’t available as a download at either site and was manually compiled by the author (refer to Table 2).
Table 2
| INDEX |
SYMBOL |
YAHOO SYMBOL |
| Nasdaq Composite |
IXIC |
^IXIC |
| Nasdaq Bank |
IXBK |
^IXBK |
| Nasdaq Biotech |
IXNBI |
^NBI |
| Nasdaq Computer |
IXCO |
^IXK |
| Nasdaq Healthcare |
IXHC |
^IXHC |
| Nasdaq Industrial |
IXID |
^IXID |
| Nasdaq Insurance |
IXIS |
^IXIS |
| Nasdaq Other Finance |
IXFN |
^IXFN |
| Nasdaq Telecommunications |
IXTC |
^IXUT |
| Nasdaq Transportation |
IXTR |
^IXTR |
| Nasdaq 100 |
IXNDX |
^NDX |
| Nasdaq 100 Tech |
NDXT |
^NDXT |
| Nasdaq 100 Ex Tech |
NDXX |
^NDXX |
| Nasdaq 100 Financial |
IXFIN |
^IXF |
MEMBERSHIP TESTS
Some planning is required when assigning symbols to Categories as the sub-Categories need to be unique and the order in which the assignments are made can affect the outcome (if the sub-groups are not unique symbols with joint membership will be moved to the most recent assignment leaving the sub-groups that are assigned first short). Mutual lists, that are not exclusive need, to be incorporated into the database at the Watch list level, where joint membership of sub-Categories is permitted. It is, therefore, wise to test membership at all levels before proceeding with the setup.
A test of all component lists , for mutual exclusivity, can be carried out, in Excel. Example files, suitable for this purpose, can be downloaded from the Attached Files section of this post (refer to MembershipTestGroups.xls, MembershipTestSectors.xls and MembershipTestSubIndexes.xls).
Using the membership test file the following results were obtained:
- 155 symbols in the Composite list do not have a match in the National Market and Capital Market (Nat/Cap) lists.
- 50 symbols in the Nat/Cap list do not have a match in the Composite list.
- The Nat/Cap lists are unique, relative to each other.
- There are two symbols in the Composite list that are not included in the Sector lists i.e. APRO and FTSW.
- 170 Biotech symbols are also members of the Healthcare sector.
- All the other Sector lists are unique, relative to each other.
- The adjusted count, when BioTech symbols are deducted from the Healthcare count, totals 3092 which equals the Composite total of 3094 minus 2 (refer to Table 3).
- The Nasdaq100 and the NasdaqFinancial100 are unique lists that are part of the NasdaqComposite.
- The Nasdaq100 Technology and the Nasdaq100 Ex-Tech are unique lists that together make up the Nasdaq100.
DATABASE DESIGN
Based on the membership test results the rational for the database design is:
- The Composite members will makeup the global database, at the All Symbols level, with the remaining Categories subordinate to that list.
- Since the Composite Index is based on one market the Market list is a surrogate for the global database.
- 14 Indexes, that track different subsets of the Composite, are not included in any lists and will be added to the database at the global level. This will increase the total number of symbols in the database to 3108 == 3094 (Composite) + 14 (Indexes).
- The Nat/Cap markets are major, mutually exclusive, lists that will comprise the next tier of categorization at the Group level.
- 155 symbols, that are not in the Nat/Cap lists, will remain unclassified at the Group level.
- The 50 symbols that are exclusive to the Nat/Cap list will not be added to the database so that the database remains faithful to the Composite at the global level.
- Sectors and Industries will be entered in a one to one relationship, since no information is available for Industry classifications.
- As symbols can not be members of more than one sub-Category, at the Sector/Industry level, the 170 symbols that have joint membership of the BioTech and Healthcare sectors will not be included in Healthcare (this will mean that the Healthcare sector, for this database, will not be a true surrogate of the Healthcare Sector Index).
- The complete Healthcare Sector list and the Nasdaq100 sub-Indexes will be included as Watch lists.
The operations required to setup the database are:
- - save a copy of the original broker files in the C:/Program Files/AmiBroker (installation) folder,
- - save the database specific broker files in the installation folder,
- - backup the database specific broker files into a spare folder in the installation folder (optional),
- - create a new database and manually name the Markets and Groups,
- - use the ASCII Wizard to import the Composite symbols (this adds symbols to the database, complete with Information),
- - import the Indexes into a Watch list folder using the ASCII Wizard (this adds symbols to the database, complete with Information),
- - use the ASCII Wizard to assign the Nat/Cap symbols to their Groups (this moves the symbols from the Unclassified sub-category to the Nat/Cap sub-categories within Groups),
- - backup the database specific files (constituent lists) into a spare folder in the installation folder (optional),
- - import the Sector lists into ‘temporary’ Watch lists, via the Watchlists folder,
- - import current data to the database,
- - perform quality control checks (test for NoQuotes and global database membership),
- - repair or delete NoQuotes,
- - and then assign symbols to sectors using the X_categoryAddSymbols formula,
- - quality check the sector assignments,
- - empty the ‘temporary’ Watch lists,
- - assign index symbols to the Indexes folder (move them from the temporary Indexes WL using the X_categoryAddSymbols formula),
- - manually assign the index symbols their respective Sector/Industry,
- - import the Composite sub-Indexes to ‘permanent’ Watch list folders,
- - and finally import historical data as required.
Refer to Table 3 for a ‘summary’ of the process.
Table 3
| COMPONENT LIST |
COUNT |
FILE TYPE |
CLASSIFICATION |
IMPORT METHOD |
IMPORT FILE TYPE |
REQUIRED CONTENT |
| Composite |
3094 |
CSV |
All symbols (global), Market |
Import Wizard |
CSV |
Fullname, Symbol |
| |
|
|
|
|
|
|
| Capital Market |
458 |
CSV |
Group |
Import and assign via Wizard |
CSV |
Symbol |
| National Market |
2531 |
CSV |
Group |
Import and assign via Wizard |
CSV |
Symbol |
| N&C Mkt TOTAL |
2989 |
|
|
|
|
|
| |
|
|
|
|
|
|
| Bank |
519 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| BioTech |
170 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Computer |
529 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Healthcare |
535 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Industrial |
1109 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Insurance |
64 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Other Finance |
94 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Telecommunications |
177 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Transportation |
65 |
CSV |
1 to 1 sector/industry |
assign via Watch list |
TLS |
Symbol |
| Sectors TOTAL |
3262 |
|
|
|
|
|
| adjusted Healthcare |
-170 |
|
|
|
|
|
| adjusted Sectors TOTAL |
3092 |
|
|
|
|
|
| |
|
|
|
|
|
|
| Nasdaq100 |
100 |
CSV |
Watch list |
|
TXT |
Symbol |
| Nasdaq100 Tech |
41 |
CSV |
Watch list |
|
TXT |
Symbol |
| Nasdaq100 ExTech |
59 |
CSV |
Watch list |
|
TXT |
Symbol |
| Nasdaq100 Financial |
100 |
CSV |
Watch list |
|
TXT |
Symbol |
| Indexes |
14 |
TXT |
Indexes |
Import Wizard and assign via Watch list |
CSV |
Fullname, Symbol |
Note: The Capital and National Market files do contain Symbol and Fullname information but since they are only being moved, from to one sub-Category to another, the Fullname can be ignored (the symbols already exist in the database and the Fullname information field was populated at the global level).
The Group assignment could have been done in other ways, however, for this example the Import Wizard was used, for this task, to demonstrate it’s assignment capabilities.
Once the user has a database structure ‘mapped out’ the creation process can start (additional effort at the ‘design’ stage will often save time later as unexpected occurrences, during the setup, can force a re-run or two.
CREATE A NEW DATABASE
The first step in the process is to create a new database.
To create the database:
1) Make a backup copy of the original broker.industries and broker.sector files in the C:/Program Files/AmiBroker (installation) folder (or the equivalent).
2) Download the broker.industries and broker.sector files attached to this post and Save them in the installation folder to replace the original versions.
Note: A handy tip is to create a new folder in the AmiBroker directory and save copies of the database specific broker files there, as a backup, before pasting them into the ‘working’ directory (save them in a Files folder or in a files folder with the same name as the database e.g. Data_NasdaqComposite_Files). The database backup files are then only one click away from the AmiBroker directory if they need to be checked, or reinstalled to the root folder following a mishap.
3) Create a new database called Data_NasdaqComposite, using the default EOD settings.

When the database is created the Sectors and Industries lists will automatically be set to the broker file specifications (the Sectors and Industries have a one to one relationship as no Industry information is available, for this example).

The Markets and Groups categories are not established when the database is created and they need to be set manually.
4) Check both categories and Edit the first name in the list as required (for this example the Markets default needs to be Nasdaq and the Groups default needs to be Unclassified).

Once the Markets and Groups have be named symbols, and symbol information, can be imported into the database at the global level.
To import from a CSV file using the Wizard:
1) Open the Import Wizard using the File > Import Wizard command from the menu bar.
2) Click on Pick files.

3) Select the file to be imported from the file browser window that pops up and click on Open.

Note: NasdaqComposite.csv is a copy of index_components.csv that was downloaded in the post: UKB >> The Nasdaq Indexes
The selected file will be listed in the Import Wizard’s information pane.

4) Click on Next >.
The Define Fields window will open with a ‘preview’ of the file format in the Data file sample pane.
In this example the file has a two header rows, the first data column contains the Name (Fullname) and the second column contains the Symbol (Ticker). The data columns are separated by a comma and there is no quotation data included.

5) Define the fields according to the file format:
- use the drop-down menus to set Column 1 to Fullname, Column 2 to Ticker and the remaining columns to Skip (ignore) anything else,
- set the Separator to Comma(,),
- pick Unclassified from the Group drop-down menu,
- skip the first two lines (title rows) by entering 2 into the Skip first: input box,
- check Log errors (optional),
- check Automatically add new symbols (all of the symbols are new to the database and need to be added),
- check No quotation data (the list does not contain any quotation data as only Tickers and Fullnames are to be imported).

When the settings are correct click on Next > and an Additional Settings window will open.

6) For this example there is no need to save the import format.
Click on Finish.
7) Click on Next > to complete the Symbol/Information importation.
All of the symbols are arranged in one market (Nasdaq), Unclassified at the Group level and listed under the default Sector/Industry (NasdaqBank 0) as expected.

Since the Indexes are not included in the composite list they also need to be imported, in ASCII format, to add the symbols and symbol specific information to the global database.
To enter the Index symbols to a Watch list and the database:
1) Use the Import Wizard to import the data from the NasdaqIndexes.CSV file (set the Group sub-category to Unclassified and the Watch list (WL) to List 0 using the drop-down menus) .
2) The index symbols will be imported into Watch list 0 and enter the database under the Nasdaq|Unclassified|NasdaqBank 0 sub-categories.
3) Rename the Watch list to Indexes.
4) Save the database using the File >> Save Database command.
Note: It isn’t essential to save at this stage but it is a good precaution to take before continuing on.
This establishes Data_NasdaqComposite as a ‘global’ database that represents a broad cross-section of Nasdaq listings plus the associated indexes.
From there it can be categorized according to personal preference.
CATEGORIZE THE DATABASE CONSTITUENTS
Setup Group Assignments
From the membership test results the outcome of entering the Group assignments should be to move most of the symbols from the Unclassified group to the National Market & Capital Market groups, leaving 155 symbols and 14 indexes behind as Unclassified. The 50 symbols that are exclusive to the Nat/Cap list will not be added to the database.
To assign symbols to Groups using the ASCII Wizard:
1) Enter a name for the Groups, in the order required, and click on O.K.
Note: The order is permanent i.e. it will not be automatically sorted by alphabetical order in the Workspace Symbol Tree.
2) Open the NationalMarket component file in the ASCII Wizard and pick National Market 1 from the Group drop-down menu, to assign the symbols to the relevant group. Then deselect Automatically add new symbols to prevent symbols that are unique to the NM list from being added to the database.
Select the other settings as determined by the file format.
Note: The lists are from a different source to the other lists, used in this example, and the columns are in a different order such that the Symbol column precedes the Name column (always look at the preview pane carefully and don’t take the formats for granted).
Since the Import Wizard is being used for assignment, rather than information input, there is no need to use any data field other than the Ticker (the Fullname data is ‘skipped’).

3) Click on Next >
An error report window will pop-up to notify the user that some symbols in the list were not imported.
4) Click on Yes to read the report.

Note: Readers who are working their way through the post might find minor differences, between their outcomes and the images used, as the author wrote the post over a period of weeks, using two computers and different file versions.
The report is in plain text format and it can be saved, or printed, for future reference.

5) Repeat the Group assignment procedure, using the Capital Market file, to finalize the Groups re-organization.

If a mistake is made in the number of lines skipped, when assigning symbols to sub-categories with the Wizard, the error can be corrected manually.
To manually reassign an Unclassified symbol e.g. EGHT to another sub-category:
1) Go to Symbol >> Organize assignments on the menu bar (the Assignments organizer window will open).
2) Select the Groups radio button then use the drop-down menu to pick Unclassified from the left hand list and Capital Market 2 from the right hand.
3) Scroll down the Unclassified list to find EGHT and select it before clicking on the Selected right arrow button to move the symbol to the nominated group.

When the Workspace Symbol Tree is refreshed it will reflect the new assignment for EGHT.
SETUP SECTOR AND INDUSTRY ASSIGNMENTS
Setting up the Sectors and Industries is a little more complicated and requires the use of an AFL formula.
The formula does the work of assigning symbols to the sectors but before it can be used some preparation is required:
- downloaded Industry lists, in CSV or Excel format, need to be converted into a Watch-list compliant (.tls) format and saved into the Database Watchlist Folder (in the installation directory),
- price data needs to be imported and redundant symbols deleted (AFL formulas will not work with symbols that do not contain quotes).
Once those criteria have been meet the database Watchlist folder lists can be simultaneously imported into the Symbol Tree Watch lists (from AmiBroker v5.00 upwards).
Note: it wasn’t the intention of the developer that users would take this path so it does involve a minor ‘workaround’ (use at your own risk – the author has experienced a minor glitch or two using this procedure).
To import Symbols into the Symbol Tree Watch lists:
1) Open the relevant file that contains the Sector specific symbol lists e.g. NasdaqBank 0.xls
2) Copy the symbols from the spreadsheet column and Paste them into a text editor, like NotePad, (this will produce a plain text file with a single symbol per line).

2) Edit out the title rows, if any, and Save the file as a .tls file in a backup folder in the AmiBroker directory (they can be stored in the same folder as the backup broker files e.g. Data_NasdaqComposite_Files).

3) Close AmiBroker.
4) Copy and Paste the Sector list files into the Database Watchlists Folder e.g. C:\Program Files\AmiBroker\Data_NasdaqComposite\WatchLists (it isn’t necessary to save them in any particular order).

3) Open AmiBroker again and the ticker lists will have been added to the Watchlist Master File (index.txt) which is also located in the Database WatchLists Folder.
Note: They will be added from List 64 on (inclusive). The first 64 lists (0-63 inclusive) have been reserved to maintain backward compatibility with older versions.

They will also take up their rightful place in the Workspace panel.

If the mouse pointer is hovered over a Watch list folder a tool-tip, with a report on the WL number and the symbol tally, will appear (the number of symbols per WL can be cross referenced to the records made at the design stage – refer to Table 3).
Downloading data and quality checking the database
Assigning symbols to Industries requires use of an AFL formula. Formulas will only work with symbols that contain at least one data point so it is necessary to import some data to the database. Current data will be used for this purpose since it downloads a lot quicker than historical data.
To download current data:
1) Open AmiQuote while AmiBroker is open with Data_NasdaqCombined as the selected database.
2) Get the tickers from AmiBroker using the Tools menu option and Automatically import data with Yahoo current as the select source (this will add one quote to all of the symbols that traded on the day).
Note: It is recommended to wait until after the daily close to download current data, for this purpose, so that stocks with low volume have a chance to register some trading activity during the day.
Once data has been imported it also provides an opportunity to remove, or repair, any redundant symbols in the database before downloading historical data (historical data will download faster if AmiQuote doesn’t have to report a lot of errors).
A list of the redundant symbols in the database can be made by using AmiBroker’s Data Purify tool.
To identify and quarantine redundant symbols:
1) Open the Database Purify tool (DPT) and enter the first symbol, from the All Symbols list, as the Reference symbol.
Note: Check that the symbol chosen as the reference does contain, at least, one quote.
2) Uncheck all of the report options, except for Report missing quotes.
3) Select All symbols and Last n = 1 as the settings and then click on Analyse.

A list of all stocks that DO NOT have a current quote will be returned.
4) Right click anywhere inside the list and pick Add all symbols to watch list from the context menu that opens.

Note: The DPT does not report a symbol count in the output list. Since AmiBroker doesn’t recognize No Quotes anywhere else the only way to obtain a count, for those who are using AB 4.91 and below, is to Copy the ‘list’ and Paste it into a spreadsheet program (for AB v4.92 and above the WL tool-tip will report the number of No Quotes symbols).
5) Select a vacant watch list to receive the output and click on OK.

Note: The importance of naming all Watch list folders as soon as they are ‘filled’ can readily be seen. In this example, if List 1 already contains data the outcome will be a bit of a mess that the user has to clean up (as noted by Dr Howard Bandy in his book Quantitative Trading Systems). So, in ‘real life’ the smart thing to do would be to name a Watch list folder "NoQuotes", prior to starting the database quality checks, and then send the DPT catch there.
All of the symbols identified as having no data will now be listed in Watch list 1.

Note: The redundant symbols will still remain in other Watch lists and Categories (assigning a symbol to a Watch list does not move it from anywhere else).
Sometimes a symbol list can contain a ‘rogue’ (unwanted) symbol that sneaks into the database by the backdoor (WL importing). Any symbols that were added to the database, via the Watch lists, will not have an associated Fullname (the Watch lists only contain Tickers without any additional information) so a test for symbols without a Fullname will find them).
A quick test, for global membership, can be carried out using the Explorer. For this example the test will be run against All symbols using the X_FullName formula.
To test All symbols in the global database for ‘true’ membership:
1) Run an exploration on All symbols using X_Fullname.

2) Sort the Results by clicking on the Fullname column. If there are any ‘rogue’ symbols present they will be sorted to the top of the list and have a blank in the Fullname cell. In this example there are no symbols without a Fullname which indicates that the database design and importation procedures were tight.

The number of symbols in the global database, that contain data, can be noted from the Status Bar at the bottom of the AA window.
Summing the symbol numbers, for stocks with and without data (NoQuotes), should equal the global database count (the Composite + Indexes tallies). For this database 2895 + 213 = = 3094 + 14 == 3108 (all present and correct!).
To construct a ‘working’ database it is advisable to ‘manually’ check each redundant symbol e.g. against Nasdaq’s lists or Yahoo’s lists. The reason for ‘failure’ to download current data should be found and corrections made, according to the preferences of the database owner (in some cases the symbol doesn’t exist and in others it will exist but have no volume for the day). The solutions, to problems encountered, can be wide ranging e.g. for traders who want liquidity, all ‘no volume for the day stocks’ can be deleted (they will be all that is left over in the ‘NoQuotes’ folder after ‘symbol does not exist’ stocks have been deleted or repaired), while those who want to trade the small caps, or low volume stocks, can ‘run’ a short historical download for the leftover ‘no daily volume’ stocks and decide what action to take on the results they obtain.
While it might not be a realistic option, for a ‘working’ database, all ‘NoQuotes’ symbols will be deleted for this example.
To delete NoQuotes:
1) Open the Symbol >> Organize assignments window.
2) Select the Watch lists radio button.
3) Pick NoQuotes from the left hand drop-down.
4) Hold down the Shift key while selecting the first and last entry in the list (the list will turn blue to indicate that all of the symbols have been selected).
5) Click on the Delete button.

A warning message will ask for confirmation of the delete.
6) Click on OK.

The selected symbols will be removed from all levels of the database.
The tool-tip can be used to sum the new Watch list counts and check the total against the global database total of 2895.
Assigning Watch list constituents to Industries
Once all of the symbols in the database contain data they can be assigned to their Industries using X_categoryAddSymbols v4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| /*X_CategoryAddSymbols v4*/
//assigns Watch list members to the Industry with exactly the same name as the Watch list
//Watch lists and Industries can be in any order
//manually enter the first and (last Watch list number +1) for Watch lists that contain assignment symbols
//tested OK with AB v5.0
Filter = 1;
for(WL = 64; WL < 73; WL++)//manually input the first and (last WL number + 1)
   {
    WLName = CategoryGetName(categoryWatchlist,WL);
    Ticker = WriteIf(InWatchList(WL), Name(),"");
    AddTextColumn(Ticker, WLName);
    IN = CategoryFind(WLName,categoryIndustry); //IndustryNumber to match selected WL Name
       if(InWatchList(WL))
          {
           CategoryAddSymbol("",categoryIndustry,IN);
          }
   } |
To assign symbols to their industries:
1) Hover the mouse pointer over the first and last Watch list folders, that contain assignment lists, to check the WL number.
2) Enter the first and (last Watch list number + 1) to the formula, as the loop variable and the counter upper limit.
3) Run X_categoryAddSymbols v4 in Explorer with All symbols, n last days and N = 1 selected.
The symbols will be assigned to Industries, according to their Watch list membership (the Watch lists constituents will be reported in the AA window).

4) Click on the Result pane Titles to sort the column by Watch list and scroll down to manually cross check WL membership against Sector membership.

The Results can also be exported to a spreadsheet for printing or saving for reference.
Quality checks on the assignment process can also be run using X_Fullname.
To check Sector assignments against Watch lists:
1) Check use filter in the AA window and click on Define to set the filter criteria.
The Filter settings window will open.
2) Click on Clear to remove the previous settings (Includes and Excludes should both be free of redundant settings).
3) Select a Sector from the drop-down list and click on OK.

4) Run an Exploration using n last days and n = 1.
5) Leave the Automatic Analysis window open and right click on the corresponding Watch list folder, to open the context menu, then alphabetically Sort the list.

The Sector count, from the AA window status bar, can be checked against the corresponding Watch list count and the list members can be checked against each other by scrolling the lists.

Once the Sectors have been checked, and all of the symbols assigned correctly, the ‘temporary’ Watch lists can be emptied.
To empty Watch lists:
1) Right click on the Watch list folder and select Erase (make empty) from the context menu that opens.

2) Click on Yes to continue when a warning message opens.

Alternatively, to empty a larger number of Watch lists:
1) Close AmiBroker.
2) Delete all the temporary Watch list (.tls) files from the C:/Program Files/AmiBroker/WatchLists folder.
3) Open AmiBroker (the ‘temporary’ Watch lists will be empty and no longer visible in the Symbol Tree).
Note: Users can elect to view empty WL’s by right clicking on a WL folder and deselecting Hide Empty watchlists from the context menu that opens.

The next step, in setting up the Nasdaq Composite Database, is to move the symbols in the Indexes WL to the Indexes Category.
To assign symbols to the Index folder:
1) Open AA and set the filter to the Indexes Watch list.

2) Run categoryAddSymbol v5.0 as an Exploration.

The index symbols listed in Watch list 0 will be assigned to the Indexes folder.

3) Watch list 0 can now be emptied.
That completes the reorganization of the index symbols into their own category. They will also be listed at the top of the default sub-category in all the other categories (automatic alphabetical sorting brings them to the top). As they are an exclusive group they can be moved to their own sub-category at any level. For this example they will be left in the Unclassified sub-category at the Group level and individually moved to their corresponding Sector/Industry (this could also have been done earlier by including them in the Industry lists).
To move the Index symbols from the default Industry sub-category to their own Industry:
1) Go to Symbols >> Organize assignments and select the Industries radio button on the Assignments Organizer window that opens.
2) Pick NasdaqBank 0 (the default) from the left hand drop-down list and then select the index symbol to move.
3) Pick the target industry from the right hand drop-down and then click on the left to right arrow button to move the symbol to it.
4) Repeat the procedure for all of the indexes that have a corresponding industry sub-category.

After all of the Sector indexes have been assigned five index symbols remain in NasdaqBank 0 (the composite index and four N100 indexes). They can be moved by naming an Industry as Unclassified and using the Assignments organizer to move them to it.
When all of the assignments are complete, and the watch list folders have been emptied, the symbols that comprise the permanent watch lists can be imported.
To import ‘permanent’ Watch lists:
1) Rename WL’s to match the lists that are to be imported.
2) Go to Menu bar >> Symbol >> Watch list >> Import and the Select watch list(s) window will open.
3) Select the File radio button and click on OK (a file browser window will open).

4) Choose the required file from the list and click on OK (the symbols in the file will be imported into the selected WL).
Note: The file needs to be a text file with one ticker per line.

5) Repeat the process for the remaining WL’s including the original (complete) Healthcare Sector list.
Finally, the database can be saved and historical data downloaded by opening Amiquote, getting the ticker list from the open database and downloading the required range of quotes in the usual way.
CONCLUSION
That completes this tutorial that demonstrates one method of creating a database. It includes examples of the full range of graphical tools and basic skills that users require to allow them to customize their own databases, according to their needs and the data at their disposal. Some alternative methods of setting up a database will be dealt with, at a basic level, in future posts (including user defined ASCII importing and, possibly, low level ‘automation’).
ATTACHED FILES:
broker industries and broker sector files: brokersectors.txt and brokerindustries.txt
Nasdaq composite file: nasdaqcomposite.xls
Nasdaq markets file: nasdaqmarketssept2007.xls
Nasdaq National and Capital markets files: nasdaqcapitalsept2007.xls and nasdaqnationalsept2007.xls
Excel file used to compare Group membership: membershiptestgroups.xls
Excel file used to compare Sector membership: membershiptestsectors.xls
Excel file used to compare Index membership: membershiptestsubindexes.xls
Nasdaq Sector Indices files:
nasdaqbank-0.txt
nasdaqbiotech-1.txt
nasdaqcomputer-2.txt
nasdaqhealthcareminusbio-3.txt
nasdaqindustrial-4.txt
nasdaqinsurance-5.txt
nasdaqotherfinance-6.txt
nasdaqtelecommunications-7.txt
nasdaqtransportation-8.txt
nasdaqhealthcare.txt
Nasdaq Sub-Indexes files:
nasdaq100.txt
nasdaq100extech.txt
nasdaq100tech.txt
nasdaqfinancial100.txt

Loading ...