Want to create different sectoral indices. Help?

I want to create different sectoral indices like sugar,cement,telecommunications etc.

But the problem is that in the final indices which is created by add to composite function, it is just adding the open,high,low,close of all the stocks. This is correct, but in such a case it is giving weightage according to the stock prices. So higher the stock price, higher its weightage. I want the stocks to give weightage according to their market cap. This market cap is their in excel which I have. How do I import this data to the amibroker and then create the new index based on the market capital ?

Here is the code which I used to create index just by adding OHLC data

AddToComposite(L, "Sugar" ,"L");
AddToComposite(O, "Sugar" ,"O");
AddToComposite(H, "Sugar" ,"H");
AddToComposite(C, "Sugar" ,"C");
AddToComposite(V, "Sugar" ,"V");
Buy=Sell=Short=Cover=0;
Filter=1;

First of all make sure you use tilde "~" at the beginning of composite name as written in manual http://www.amibroker.com/guide/a_addtocomposite.html. This way composites are placed at the end of symbol list and prevents conflicts with existing symbols.

To create cap-weighted index you need to incorporate fundamental data. The example below assumes that you have fundamentals in your database (see http://www.amibroker.com/guide/h_fundamental.html).

You can calculate capitalization this way:

mCap = GetFnData("SharesOut") * Close;

Then – you can use this value in composite calculation, something like:

mCap = GetFnData("SharesOut") * Close;
AddToComposite( mCap , "~capitalisation_sum", "X");

But remember that it's not really 100% correct approach with fixed SharesOut figures (you should have historical values for that in order to perform historical analysis).

1 Like

Thanks for the reply sir, but I do not have the fundamental data yet. I am trying to find it for NSE which is seemingly very tough. I have asked it from many people but they hardly get it for indian stocks.
Since I only need market cap of the stocks ( and not any other fundamental data) I am thinking of manually creating a csv file having stock name in the first column and market cap on the second column.

Will the above csv file solve the issue ?
Kindly let me know Capture

Did you carefully read this: http://www.amibroker.com/guide/h_fundamental.html ?
If you followed the instructions you would know how to download fundamental data for pretty much every symbol that Yahoo has. And Yahoo definitely has fundamental data for NSE: https://finance.yahoo.com/quote/20MICRONS.NS/key-statistics?p=20MICRONS.NS and can be downloaded using AmiQuote.

I tried to do the same, but I am getting failed results. Can you please tell me what can be the reason for this ?

image

You are using outdated version of AmiQuote. You need to use always the newest version (3.31) at the moment. And use "Fundamental Extra" mode.

I installed the latest version (3.31) of it.

image

Here first of all, I am not getting yahoo basis fundamental as my source. So I chose Yahoo fundamental extra.
Then in only 4-5 symbols it showed imported which when I opened in notepad, all the figures are NA and the rest of the symbols are not even tried to download since it says that trial version does not allow the same.

Please help sir

Help someone please.....

@thetrader,

register amiquote first using your key.

also, check your 4-5 symbols have downloaded the India prices or US/other listing prices. this could happen probably because you haven't defined the symbol translation to yahoo. Read about symbol translation from user-defined tickers to yahoo symbols. Once registered and symbol translation defined, you should be able to get prices for all.

image

1 Like

You did not bother to actually click on the link I have given earlier: https://finance.yahoo.com/quote/20MICRONS.NS/key-statistics?p=20MICRONS.NS

If you did you will notice that ALL NSE symbols on Yahoo use .NS suffix so you MUST have .NS suffix in ALL your symbols.

See also the MANUAL: http://www.amibroker.com/guide/h_amiquote.html

It clearly says:

Please note that Yahoo uses suffixes for non-US stocks. So in order to get quotes for non-US symbol you would need to add appropriate suffix to the ticker symbol. The suffixes in alphabetical order are (you can click on link to get the symbol list for each exchange) : .AS - Amsterdam, .AX - Australia (ASX), .BC - Barcelona, .BE - Berlin, .BO - Bombay, .BM - Breman, .BR - Brussels, .BA - Buenos Aires, .CL - Calcuta, .CR - Caracas, .V - CDNX, .CO - Copenhagen, .D - Dusseldorf, .F - Frankfurt, .H - Hamburg, .HA - Hanover, .HK - Hong Kong, .I - Ireland, .JK - Jakarta, .KA - Karachi, .KQ - Kosdaq, .KS - KSE, .KL - Kuala Lumpur, .L - London, .LM - Lima, .LS - Lisbon, .MA - Madrid, .MX - Mexico, .MI - Milan, .MU - Munich, .NS - NSE, .NZ - New Zeland, .OL - Oslo, .PA - Paris , .SN - Santiago, .SS - Shanghai, .SZ Shenzhen, .ST - Stockholm, .SG - Stutgart, .TW - Taiwan, .TA - Tel Aviv, .TO - Toronto, .VA - Valencia, .VI - Viena, .DE - XETRA, .S - Zurich.

1 Like

Hi,

I'm looking for the .ST - Stockholm tickers list and found the above instructions, but when I click on those it is going to Yahoo home page. Anyone has the same problem or the link has been changed?

Thanks!