| AmiBroker Tips weekly newsletter.
Copyright (C)2000 Tomasz Janeczko.
All back issues available from:
Welcome to the 7th issue of AmiBroker Tips newsletter. This issue features
an article that (hopefully) will help you understand how sectors and industries
work in AmiBroker.
By the way: Do you find this newsletter useful? Have any comments/suggestions or article ideas. Please don't hesitate to drop a line to firstname.lastname@example.org
A new version (3.42) is available now for download from AmiBroker web site. Version 3.42 introduces very important bug fixes to previous versions. A bug was found in automation interface that affected Sharenet downloads when ticker name changes occurred. This version is the first one that handles changing ticker from the script correctly. Also a new setup now includes a new script for Sharenet downloader that displays now a list of erroneous lines found in the data. It is installed by default along with proper Custom Tools item setup so problems with previous version should finally disappear.
3 Tip of the week: Understanding sectors and industries
AmiBroker has an ability to assign stocks to different categories allowing you (when properly set up) to narrow your analysis searches to the stocks meeting certain selection criteria (thanks to Filter feature available in Quick Review and Automatic Analysis windows). The initial set up of categories may be a little bit complicated especially when you want to track several thousands stocks. This article will focus on setting up sectors and industries and assigning the stocks to them. First let me discuss some basic ideas.
3.1 Basics - predefined sectors and industries
AmiBroker comes with an example Dow Jones Industrials database holding all 30 components of this world's most famous market average. They are assigned to predefined sectors and industries. These sectors and industries are exactly the same as used on Yahoo finance site and here is a table which shows them all:
|Basic Materials (0)||Chemical Manufacturing|
|Chemicals - Plastics & Rubber|
|Containers & Packaging|
|Fabricated Plastic & Rubber|
|Forestry & Wood Products|
|Gold & Silver|
|Iron & Steel|
|Misc. Fabricated Products|
|Paper & Paper Products|
|Capital Goods (1)||Aerospace & Defense|
|Constr. - Supplies & Fixtures|
|Constr. & Agric. Machinery|
|Construction - Raw Materials|
|Misc. Capital Goods|
|Mobile Homes & RVs|
|Consumer Cyclical (3)||Apparel/Accessories|
|Appliance & Tool|
|Audio & Video Equipment|
|Auto & Truck Manufacturers|
|Auto & Truck Parts|
|Furniture & Fixtures|
|Jewelry & Silverware|
|Textiles - Non Apparel|
|Consumer/Non-Cyclical (4)||Beverages (Alcoholic)|
|Personal & Household Prods.|
|Oil & Gas - Integrated|
|Oil & Gas Operations|
|Oil Well Services & Equipment|
|Financial (6)||Consumer Financial Services|
|Insurance (Accident & Health)|
|Insurance (Prop. & Casualty)|
|Misc. Financial Services|
|Money Center Banks|
|Healthcare (7)||Biotechnology & Drugs|
|Medical Equipment & Supplies|
|Broadcasting & Cable TV|
|Casinos & Gaming|
|Hotels & Motels|
|Printing & Publishing|
|Real Estate Operations|
|Rental & Leasing|
|Retail (Catalog & Mail Order)|
|Retail (Department & Discount)|
|Retail (Home Improvement)|
|Security Systems & Services|
|Waste Management Services|
|Technology (9)||Communications Equipment|
|Computer Storage Devices|
|Electronic Instruments & Controls|
|Scientific & Technical Instr.|
|Software & Programming|
|Transportation (10)||Air Courier|
|Utilities (11)||Electric Utilities|
|Natural Gas Utilities|
It is important to understand the difference between a sector and an industry: industries "belong" to sectors, for example: "Air Courier", "Airline", "Railroads", "Trucking" industries belong to "Transportation" sector. So if a stock is assigned to given industry, it is "automatically" assigned also to the corresponding sector.
In the example DJIA database each stock is assigned to specific industry, for example GM (General Motors) is assigned to "Auto & Truck Manufacturers" industry, and this implicates that GM belongs to "Consumer/Cyclical" sector.
AmiBroker can handle up to 32 sectors and up to 256 industries.
3.2 How to assign stock to the industry?
You can change the industry to which given stock is assigned by using Stock->Information dialog (Industry combo box)
or using Stock->Organize Assignments.
The first method is fine if you want to change single stock settings. The latter is better if you want to move multiple stocks from one category to another.
3.3 How to define your own sectors and industries
Please go to Stock->Categories dialog, the last two tabs are "Sectors" and "Industries". First, switch to the "Sectors" tab and you will see the list of 32 sector names. You can now select the sector by clicking once on its name and edit the sector name by pressing ENTER or clicking "Edit name" button. Hit ENTER again to accept the name change.
After you renamed the sectors you can switch to the "Industries" tab. Similarly to the previous tab you can select the industry in the list and edit its name in the same manner. Here you can also assign the industry to the sector using "Sector" combo. Just select the sector to which you want to assign currently selected industry.
3.4 Where sector and industry information is stored?
Generally speaking this information is stored in AmiBroker database. The sector and industry names and settings are stored in the broker.workspace file (in the workspace folder), stock data files hold only the information about the assignment of the stock to given industry (IndustryID).
When you create a new workspace (a database) AmiBroker sets up your industries and sectors according to the templates stored in the "broker.sectors" and "broker.industries" files. These are simple text files that could be edited with plain text editor (such as Notepad). These files could be also used for quick, automatic setup of the sectors and industries. AmiBroker comes with predefined broker.sectors and broker.industries that follow described above convention (see the table). You can rewrite broker.sectors and broker.industries files to define your own default scheme. So, "broker.sectors" and "broker.industries" files are used as a template when creating new workspace. Once workspace is created these files are not taken into consideration. In this way you may have different categories in each workspace. If you want AmiBroker to load them into already existing workspace please delete broker.workspace file before opening the workspace. If you then open the workspace AmiBroker will read broker.sectors and broker.industries.
The layout of broker.sectors file is very simple: it is plain text file holding
sector names written line by line as shown below:
The layout of broker.industries is similar, but in addition to industry names there is a number at the beginning of each line:
1 Aerospace & Defense
10 Air Courier
3 Appliance & Tool
3 Audio & Video Equipment
3 Auto & Truck Manufacturers
3 Auto & Truck Parts
4 Beverages (Alcoholic)
4 Beverages (Non-Alcoholic)
7 Biotechnology & Drugs
8 Broadcasting & Cable TV
8 Business Services
8 Casinos & Gaming
0 Chemical Manufacturing
0 Chemicals - Plastics & Rubber
9 Communications Equipment
The numbers at front of industry names are "Sector IDs". Those numbers decide to which sector given industry belongs to. Because several industries may belong to one sector - you may need to put the same number for sector Id. Sector IDs are zero based, which means that 0 refers to the first line (sector name) of "broker.sectors" file, while 7 refers to the eighth line of this file. In the example above: "Advertising" industry belongs to "Services" sector, while "Aerospace & Defence" industry belongs to "Capital Goods" sector.
If you don't want to setup detailed industry information and want assign stocks only to sectors you can define one-to-one relationship between first 32 industries so they will be equivalent to sectors. Using the broker.sectors as show earlier in this article 1-1 broker.industries file would look like:
0 Basic Materials
1 Capital Goods
3 Consumer Cyclical
Note that this file is essentially the same as broker.sectors with the only difference that we have consecutive numbers prepended to each line. Using this kind of setup setting the industry will be equivalent to setting the sector.
3.5 Making it automatic
As described above stock and industries names and relationship can be easily set up quickly using "broker.sectors" and "broker.industries" files. It will save some work needed otherwise to enter this information in Stock->Categories window.
Unfortunately a lot more work is needed to assign all stocks to the industries even using Stock->Organize Assignments dialog. Fortunately there is a way to save a lot of work using AmiBroker automation interface and scripting. The detailed description of how to accomplish this task and ready-to-use script is presented in the 4th issue of AmiBroker Tips newsletter.
.... and that's all for this week - hope you enjoyed reading
AmiBroker Tips weekly newsletter. Issue 7/2000. Copyright (C)2000 Tomasz Janeczko. All back issues available from: http://www.amibroker.com/newsletter/