Find the symbol for an industry or sector index
Author: superticker
Creation Date: 8/11/2017 7:01 PM
profile picture

superticker

#1
Is there a C# class that can do a reverse lookup to find the symbol for an industry or sector index? Basically it's a sorted (vectored) C# collection that can return the symbol ticker of an industry or sector when given the corresponding GICS code for a stock. If not available, I'm going to code one.

If there's a table that lists each industry index with its corresponding GICS code, that would be helpful in getting me started.

I want to do some sector/industry oriented trading, so I want to compare each stock to the index for its industry (and maybe sector).

If anyone can suggest any other available tools for sector/industry oriented trading with WL, please do so.
profile picture

Eugene

#2
So for example, the "Consumer Durables and Apparel" group has GICS code 2520 and you want to look up for some index symbol behind it. Do I get it right? Does it exist? I haven't seen such source but should you find one online I could help in getting it scraped.
profile picture

superticker

#3
QUOTE:
for example, the "Consumer Durables and Apparel" group has GICS code 2520 and you want to look up for some index symbol behind it.
That's basically "correct," but let's take it a step further by including the GICS code lookup function, GetIndustry(symbol), for the stock symbol. For example, I want to pass the symbol for Apple "AAPL" and have it return ".GSPCOPE", the index symbol for Technology, Hardware, Storage, & Peripherals (Apple's industry index).

Has anyone develop a C# class for doing that? If not, I can code it, and share the code. I just don't want to write code that's already been written. I thought about doing a sorted collection of struct {int, string} objects for the (1) GICS code and (2) index ticker symbols, but the problem is probably simpler than that. Simply declaring a sorted&paired "struct {int[], string[]}", then using an Array Find on the int[] to locate the int-index of the GICS code and looking that up in the string[] to fetch the corresponding index symbol should do it. The processor is more efficient at handling arrays than collections of objects, so an array solution is preferred.

The other reason for using an "array solution" is because this database is "static", so space never needs to be reallocated (and garbage collected). Collections are better when there's dynamic resizing and garbage collection is involved. (C# does a terrible job at resizing arrays. It just dumps the entire old array space and allocates a new one. StringBuilder avoids "some" of that for strings (dynamic char arrays), but it's still a problem.)

---

Eventually, I want to perform a decorrelation and cross-correlation on the stock and its industry index. But that's another problem. As a personal note, I have always traded from the decorrelated line. But I've always decorrelated against the S&P500. Now I want to do that against the industry index for the stock in question.

The cross-correlation analysis will reveal if the stock leads or lags its industry index. As a signal processing (DSP) guy, I've done a fair amount of cross-correlation analyses (It's a common practice.), but never on financial data. This will be a first for me.
profile picture

Eugene

#4
What exactly is "the index symbol for Technology, Hardware, Storage, & Peripherals (Apple's industry index)"? Is this some ETF or something? I still do not understand. Not sure if GICS contains it. You must be looking for some external resource.
profile picture

superticker

#5
QUOTE:
What exactly is "the index symbol for Technology, Hardware, Storage, & Peripherals (Apple's industry index)"?
It's ".GSPCOPE". I revised the post above (message #3) to include it.

QUOTE:
Not sure if GICS contains it.
It doesn't. So my goal is to add a class (really a "struct" because it's value based) that includes all the US industry indexes, which the WL GICS dictionary doesn't currently have. In addition, it needs to do a reverse lookup. I just added (revised) the example in the first paragraph in message #3 above.

The web link https://eresearch.fidelity.com/eresearch/markets_sectors/sectors/si_performance.jhtml?tab=siperformance lists all the US industry indexes and their corresponding ticker symbol. Do you know where I can get GICS codes for these industry index symbols to populate my struct{...}?
profile picture

pichu_1972

#6
I dont know if this can helps you.
You have the ICB class. in marketwatch, it contains sector/subsector for each US component
http://www.marketwatch.com/tools/industry/?bcind_ind=bc_top&bcind_period=3mo

For example AAPL:
http://www.marketwatch.com/tools/industry/stocklist.asp?bcind_ind=9572&bcind_period=3mo


Sector US Techn Hardware&Eqment DJUSTQ
Subsector USA Computer Hardware DJUSCR

You can download sector/subsector (DJUSXX) from quotemedia or from WSJ:


http://quotes.wsj.com/index/XX/NULL/DJUSTQ/historical-prices
profile picture

superticker

#7
QUOTE:
For example AAPL:
http://www.marketwatch.com/tools/industry/stocklist.asp?bcind_ind=9572&bcind_period=3mo

Sector US Techn Hardware&Eqment DJUSTQ
I can pull ".DJUSTQ" into WL okay. The problem is this index is specific only to stocks contained in the Dow. For example, I don't think Cypress Semiconductor is in there because it's not part of the Dow.

What I'm trying to do is match up each stock with its industry index via their GICS coding. So for Apple, that would be ".GSPCOPE", which is the index for Technology, Hardware, Storage, & Peripherals whether these stocks belong to the Dow or not.

The signal processing question is whether it's better to decorrelate and compare AAPL with .GSPCOPE or .DJUSTQ? But, however interesting, that's another discussion.

My more immediate problem is where can I find the GICS code for .GSPCOPE or .DJUSTQ so Wealth-Lab can connect these indexes to AAPL (Apple) for comparison and analysis?
profile picture

Eugene

#8
Note that my help to you is limited since I don't work with WLP and thus have no access to the WLP GICS.

WLD users (like me) can get sector, industry, NAICS/SIC/ISIC codes etc. using this convenient class:
Get symbol data from Morningstar.com (sector, industry, code etc.)

QUOTE:
Do you know where I can get GICS codes for these industry index symbols to populate my struct{...}?

You can get them from Wikipedia: Classification

Below is a quick and dirty attempt at scraping Fidelity's Sector/Industry page:

https://eresearch.fidelity.com/eresearch/markets_sectors/PerformanceIndustriesPopup.jhtml?tab=sector

Note: Check System.Xml and System.Web in Strategy's "References..." dialog before using. Assuming that Community Components is installed since it comes with another prerequisite - HtmlAgilityPack.dll

CODE:
Please log in to see this code.


It should produce the following output:

QUOTE:
Consumer Discretionary .GSPD
Consumer Staples .GSPS
Energy .GSPE
Financials .GSPF
Health Care .GSPA
Industrials .GSPI
Information Technology .GSPT
Materials .GSPM
Real Estate .GSPRE
Telecommunication Services .GSPL
Utilities .GSPU


You can also scrape symbol by industry by replacing URL in the code with this:

https://eresearch.fidelity.com/eresearch/markets_sectors/PerformanceIndustriesPopup.jhtml?tab=industry
profile picture

superticker

#9
Wow! You wrote code to scrap Fidelity's industry-index web link, then parse it. I'm impressed.
I only need to scrap it once to build my lookup-table struct{...} constructor.

Thanks also for the Wikipedia link! That's what I needed the most. With these two pieces of information, I should be able to build my lookup-table struct{...} that crosses stocks (via their symbol and GICS code) to their industry index: stock symbol -> GICS code -> industry-index symbol. I'm stoked. Thanks a million.
profile picture

Eugene

#10
Glad to have helped.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).