nested sorting in excel

MoneyPlanters

New Member
Joined
Apr 9, 2011
Messages
41
Every day, the National Stock Exchange of India publishes a document called the “Bhavcopy” which is a summary of the market activity for the day. In this case we are interested in the “Bhavcopy” for the ‘Futures and Options’ segment of the market, which is available from http://nseindia.com/content/fo/fo.zip. OR http://nseindia.com/archives/archives.htm. (Select BHAVCOPY for the derivatives segment) This will download a zipped file which when extracted will deliver a CSV file / Access file as attached. There are around 234 stocks listed in the ‘Futures and Options’ segment out of which we are interested only in the following 32.

Sl No
Name
Symbol
1
S&P CNX Nifty
NIFTY
2
Reliance Industries Limited
RELIANCE
3
Reliance Power Limited
RPOWER
4
State Bank of India
SBIN
5
Larsen & Toubro Limited
LT
6
Unitech Limited
UNITECH
7
Suzlon Energy Limited
SUZLON
8
Tata Steel Limited
TATASTEEL
9
ICICI Bank Limited
ICICIBANK
10
Balrampur Chini Mills Limited
BALRAMCHIN
11
Bharti Airtel Limited
BHARTIARTL
12
Bharat Heavy Electricals Limited
BHEL
13
Cairn India Limited
CAIRN
14
Chambal Fertilizers & Chemicals Limited
CHAMBLFERT
15
DLF Limited
DLF
16
GMR Infrastructure Limited
GMRINFRA
17
Housing Development and Infrastructure Limited
HDIL
18
Hindustan Unilever Limited
HINDUNILVR
19
IDBI Bank Limited
IDBI
20
Infrastructure Development Finance Company Limited
IDFC
21
Idea Cellular Limited
IDEA
22
IFCI Limited
IFCI
23
Infosys Technologies Limited
INFOSYSTCH
24
Jaiprakash Associates Limited
JPASSOCIAT
25
Mahanagar Telephone Nigam Limited
MTNL
26
NTPC Limited
NTPC
27
Oil & Natural Gas Corporation Limited
ONGC
28
Power Grid Corporation of India Limited
POWERGRID
29
Punj Lloyd Limited
PUNJLLOYD
30
Reliance Communications Limited
RCOM
31
Shree Renuka Sugars Limited
RENUKA
32
Steel Authority of India Limited
SAIL

http://nseindia.com/content/fo/fo_underlyinglist.htm

Each scrip will have three futures contracts and several options contracts relevant to itself. Let me illustrate with an example. Let us consider State Bank of India (CODE: SBIN)

SBIN is the code for the stock in the cash segment, which is the normal stock listing. Now, there will be three SBIN future contracts, one for the current month, another for the near month and yet another for the far month. For example as on today, the 11th of June 2011, SBIN will have the following three futures contracts: SBIN June, SBIN July and SBIN August. As we can see that these names are related to the current date. The contract for a given month expires on the last Thursday of that month and simultaneously, a new contract for the third next month gets introduced. If the last Thursday is a holiday then it expires on the previous trading day. SBIN June will cease to exist after 30th June 2011 and SBIN Sept will come into existence. This date is known as the expiry date.

Similarly, we have options contracts, which also expire in the same manner. However, each stock will have several options contracts unlike Futures which will always be three in number. There is no limit to the number of options contracts that can exist. We have two types of options, a CALL and a PUT. Then we have something called a STRIKE PRICE and as mentioned earlier, the EXPIRY DATE.

Here are a few examples of options contracts for SBIN.

SBIN 2300 CALL JUNE
SBIN 1300 PUT AUGUST
SBIN 2200 CALL JUNE

And so on.. There are other types of options as well, which we are not concerned with at the moment.

This much for the nomenclature of Futures and Options Contracts.

My objective is as follows:
Please note that we are concerned with OPTIONS contracts only.

We have to create three columns on the excel sheet/access database for % change in Open Interest, % change in price (closing price) and % change in volume. Now this will require interlinking the Bhavcopies, since % change will need to refer to the parameters for the previous day.

After this is done, I will need to implement a nested sorting as follows : Which contracts have had the maximum change in Open Interest AND then by volume/ % change in volume and then by price/ % change in price. I may choose to change the order of the sorting criteria. I guess this can easily be done with the help of filters. The main task is to keep interconnecting the Bhavcopies that are downloaded everyday, keeping in mind that the contracts expire at the end of the month.

If possible, graphing a few parameters like Open Interest, Price and Volume would be of immense help.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top