Utility to chart options data

pasha

Active Member
#1
Since the earlier thread is not available, I thought of starting this to help in charting options data.
Any programmers interested to help, please keep the following considerations in view.
The file from NSE uses the first field as either futures or options, so the application must skip over all lines that have the first field as FUT(xxx) and read only lines that have the first field as OPT(xxx).
The following line needs to be merged into
OPTIDX, BANKNIFTY, 31-Aug-2006, 3410, CE

OPTIDX,CE3410BANKNIFTYAug06, and other fields stay the same.
New file is to be automatically saved.
Pretty easy to do from VB, sadly I don't have a copy.
Any volunteers?
 
#2
pasha said:
Since the earlier thread is not available, I thought of starting this to help in charting options data.
Any programmers interested to help, please keep the following considerations in view.
The file from NSE uses the first field as either futures or options, so the application must skip over all lines that have the first field as FUT(xxx) and read only lines that have the first field as OPT(xxx).
The following line needs to be merged into
OPTIDX, BANKNIFTY, 31-Aug-2006, 3410, CE

OPTIDX,CE3410BANKNIFTYAug06, and other fields stay the same.
New file is to be automatically saved.
Pretty easy to do from VB, sadly I don't have a copy.
Any volunteers?
Hello Pasha,

As I am not much familiar with future & option, I donot understand your point completely. But the job you need is simple. Please upload here (or send me) sample file (what input & output you need), I will make a utility for you.

Regards

K S Kachhwaha
[email protected]
 

pkjha30

Well-Known Member
#3
pasha said:
Since the earlier thread is not available, I thought of starting this to help in charting options data.
Any programmers interested to help, please keep the following considerations in view.
The file from NSE uses the first field as either futures or options, so the application must skip over all lines that have the first field as FUT(xxx) and read only lines that have the first field as OPT(xxx).
The following line needs to be merged into
OPTIDX, BANKNIFTY, 31-Aug-2006, 3410, CE

OPTIDX,CE3410BANKNIFTYAug06, and other fields stay the same.
New file is to be automatically saved.
Pretty easy to do from VB, sadly I don't have a copy.
Any volunteers?
Hi Pasha
Given below is the downloaded copy of derivatives data from NSE
Could you specify what else fields are required for charting files
INSTRUMENT SYMBOL EXPIRY_DT STRIKE_PR OPTION_TYP OPEN HIGH LOW CLOSE SETTLE_PR CONTRACTS VAL_INLAKH OPEN_INT CHG_IN_OI TIMESTAMP
FUTSTK WOCKPHARMA 26-Oct-06 0 XX 0 0 0 346.45 349.5 0 0 0 0 07-Aug-06
OPTIDX BANKNIFTY 31-Aug-06 3400 CE 0 0 0 212.3 754.4 0 0 0 0 07-Aug-06

Do give a sample file as asked by CEM
Pankaj
 

pasha

Active Member
#4
Hi Cem and Pankaj,
The F&O bhavcopy in csv format can be downloaded here
http://www.nseindia.com/bhavcopy/BhavHandler?segment=1

Line Sample
F1 F2 F3 F4 F5
OPTIDX, BANKNIFTY, 31-Aug-2006, 3410, CE

Cem, I don't know if you are using VB, but this is the sequence
Read file into array
Ignore all lines where field1 contains FUT
Read all lines where field1 contains OPT
Convert "31-Aug-2006" to Aug06
Do string merge of first 5 fields (from line above) to F5F4F2F3 without the delimiters.
Field 6 onwards as it is, no change
Save new array to file.

Thanks for helping, I hope this is clear enough.
Once the NSE csv has been processed, it should be importable by any software for charting.
 

pkjha30

Well-Known Member
#5
Hi pasha

Below is the output I got from the little routine for converting derivatives file on optidex

OPTIDX,CE3400BANKNIFTYAug06,0,0,0,212.3,686.7,0,0,0,0,1-AUG-2006,
OPTIDX,CE3410BANKNIFTYAug06,0,0,0,207.15,677.65,0,0,0,0,1-AUG-2006,
OPTIDX,CE3420BANKNIFTYAug06,0,0,0,202.1,668.65,0,0,0,0,1-AUG-2006,
OPTIDX,CE3430BANKNIFTYAug06,0,0,0,197.15,659.7,0,0,0,0,1-AUG-2006,
OPTIDX,CE3440BANKNIFTYAug06,0,0,0,223.15,650.8,0,0,0,0,1-AUG-2006,
OPTIDX,CE3450BANKNIFTYAug06,0,0,0,396.1,641.95,0,0,0,0,1-AUG-2006,
OPTIDX,CE3460BANKNIFTYAug06,0,0,0,391.35,633.1,0,0,0,0,1-AUG-2006,
OPTIDX,CE3470BANKNIFTYAug06,0,0,0,386.7,624.35,0,0,0,0,1-AUG-2006,
OPTIDX,CE3480BANKNIFTYAug06,0,0,0,382.05,615.6,0,0,0,0,1-AUG-2006,
OPTIDX,CE3490BANKNIFTYAug06,0,0,0,377.45,606.9,0,0,0,0,1-AUG-2006,
OPTIDX,CE3500BANKNIFTYAug06,0,0,0,372.9,598.25,0,0,0,0,1-AUG-2006,
OPTIDX,CE3510BANKNIFTYAug06,0,0,0,415.35,589.65,0,0,0,0,1-AUG-2006,


I am not clear abt what should be header or is it headerless file. Can TA software recognise and import file
This one is flat file.
Pankaj
 
Last edited:

pasha

Active Member
#6
Hi Pankaj,
The following is from the NSE bhavcopy, my comments are in brackets( )

INSTRUMENT,SYMBOL,EXPIRY_DT,STRIKE_PR,OPTION_TYP,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH,OPEN_INT,CHG_IN_OI,TIMESTAMP, (Keep this line)
FUTIDX,BANKNIFTY,31-Aug-2006,0,XX,4020,4135,4020,4109.3,4109.3,895,3649.96,94700,11200,7-AUG-2006, (Delete this line, starts with FUT)
FUTIDX,BANKNIFTY,28-Sep-2006,0,XX,0,0,0,4150,4176.85,0,0,100,0,7-AUG-2006, (Delete this line, starts with FUT)
...............
...............
................
................
FUTSTK,WOCKPHARMA,28-Sep-2006,0,XX,0,0,0,352.65,347.6,0,0,600,0,7-AUG-2006, (Delete this line, starts with FUT)
FUTSTK,WOCKPHARMA,26-Oct-2006,0,XX,0,0,0,346.45,349.5,0,0,0,0,7-AUG-2006, (Delete this line, starts with FUT)
OPTIDX,BANKNIFTY,31-Aug-2006,3400,CE,0,0,0,212.3,754.4,0,0,0,0,7-AUG-2006, (Ok, we start here and merge fields 2 to 5)
OPTIDX,BANKNIFTY,31-Aug-2006,3410,CE,0,0,0,207.15,744.8,0,0,0,0,7-AUG-2006,

Your example file is almost perfect, just leave the first line as it is and shift the date from field 9 to field 2
OPTIDX,CE3510BANKNIFTYAug06,0,0,0,415.35,589.65,0, 0,0,0,1-AUG-2006,
becomes
OPTIDX,CE3510BANKNIFTYAug06,1-AUG-2006,0,0,0,415.35,589.65,0, 0,0,0,
Excellent effort, my sincere thanks to you and I'm sure others will use it too.
If you are writing it in VB, could you put in a "process directory" choice, ie process all the files in a folder.
The processed file can be saved with the same name and a prefix, so fo07AUG2006bhav.csv could become pfo07AUG2006bhav.csv
 

pkjha30

Well-Known Member
#7
Hi pasha
Check this with headerline
I am giving chioce for OPTIDX or FUTIDX as I am sure both could be used seperately.

File naming convention is yyyymmdd.OPT.txt and yyyymmdd.FUT.txt.
txt could be csv as well by choice or manually it could be changed.

I have downloaded 11 derivatives files using my downloader. It will save file in yyyymmdd.csv format as that is accepted by many TA software. In same program I have converted it.
Let me know if any more specification is needed.
Pankaj
 
Last edited:

pasha

Active Member
#8
Hi Pankaj,
>I am giving chioce for OPTIDX or FUTIDX as I am sure both could be used seperately.
You are right, some users may want futures data only. Your option file is prefect, I can't say for the futures as I know nothing of it.
My connection is giving a lot of trouble today(courtesy BSNL) so I hope this message gets posted before it goes again.
 

pasha

Active Member
#9
Hi Pankaj,
I am not able to d/l your files to verify the header so just a couple of tips.
The number of fields in the header must match the number of fields in the data.
The 4 fields that are being merged into 1, need to be named TICKER(SYMBOL) in the header field.
The final header is this
INSTRUMENT,SYMBOL,DATE,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH, OPEN_INT,CHG_IN_OI,

In AB for equities the mainly used fields are
Name,Date,Open,High,Low,Close,Volume in any order

Edit:
Managed to d/l the file, and found this header
INSTRUMENT,SYMBOL,EXPIRY_DT,STRIKE_PR,OPTION_TYP,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH,OPEN_INT,CHG_IN_OI,TIMESTAMP,

It needs to be this
INSTRUMENT,SYMBOL,DATE,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH, OPEN_INT,CHG_IN_OI,
 
Last edited:

pkjha30

Well-Known Member
#10
Hi Pankaj,
I am not able to d/l your files to verify the header so just a couple of tips.
The number of fields in the header must match the number of fields in the data.
The 4 fields that are being merged into 1, need to be named TICKER(SYMBOL) in the header field.
The final header is this
INSTRUMENT,SYMBOL,DATE,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH, OPEN_INT,CHG_IN_OI,

In AB for equities the mainly used fields are
Name,Date,Open,High,Low,Close,Volume in any order

Edit:
Managed to d/l the file, and found this header
INSTRUMENT,SYMBOL,EXPIRY_DT,STRIKE_PR,OPTION_TYP,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH,OPEN_INT,CHG_IN_OI,TIMESTAMP,

It needs to be this
INSTRUMENT,SYMBOL,DATE,OPEN,HIGH,LOW,CLOSE,SETTLE_PR,CONTRACTS,VAL_INLAKH, OPEN_INT,CHG_IN_OI,
Hi pasha

Check this attachment
Pankaj
 
Last edited:

Similar threads