Sunday, January 9, 2011

Yahoo Options Data web scraper in matlab

I use Yahoo Option Chains Data to quickly check on the Option prices. I wrote a web scraper that conveniently fetches the Yahoo Option Chain Data into matlab. I hope it will be useful for some people.

UPDATE : I have edited the link below. It seems like the link was blocked for some reason.

Thanks

28 comments:

Anonymous said...

just knew this blog today, and it's great, good job!!

Jiong said...

Hi TRADINGWITHMATLAB,

Thanks for sharing. It is very useful.

But sometimes for option strategy backtesting, we want the historical price of a certain option. Do you have any idea how to get the historical price of an option from Yahoo or other source (like IB), just like what we get for stocks? This question puzzled me for a while.

Thanks a lot!

Jiong

Carly Fiorina said...

Hello,

Really it is very useful information for me, Please provide more details about it. Thanks...

Web Scrapers

Anonymous said...

Hey, very interesting......

Do you have this in python... I dont have MATLAB.

Alec Jeffery said...

Extremely useful! I've incorporated it to a volatility surface plotter, would you care to have that? I might publish it to the user exchange, but I'd like your approval first because you wrote a large part of the code.

Anonymous said...

The link to your m file seems broken, is it down permanently?

Anonymous said...

Yes, the link doesn't seem to work anymore. Can you please upload your file again? Thanks a lot!

Anonymous said...

Hi,

The code is fantastic. There are no errors in data fetching. However, its the way Yahoo works that messes up everything. For example on Friday, June 26, 2011, Yahoo says that an IBM option expires on say June 30, 2011. But if you look at the options symbols you will realize that it contains both, options that expire on June 30 and the ones that expire on July 14. That is why on a particular expiration, you can see two options with the same strike on yahoo. Just wanted to let you know. This had been a devilish for me and took me a long while to figure out.

Anonymous said...

Hi TradingwithMatlab,

Great blog.

The link to your m file seems broken, could you please restore it?
Thanks,
Shekhar

tracker77 said...

your link to the Matlab code is not available. Would it be possible to get an e-mailed copy?

thanks,

tracker77@gmail.com

Anonymous said...

Hello,

Can you post the matlab code for Get_Exp_Dates ?

Thanks a lot.

I like your blog very much.

david

Extract Data From Website said...

Hi Dude,

Web scrapers are programs that are able to gather information on the Internet. They are capable of web browsing, evaluated the content of the site, and then pulling the data points and put them in a structured database. The main advantage of using the web scraping tool it that it provides a very accurate and efficient results. Thank you...

alternative investment said...

great stuff!

Rod Lucas said...

I think that these labs are the best and well worth the money. They can teach you anything that you aren't understanding, from math labs to paper stock trading labs. It's awesome.

Anonymous said...

Nice piece of code

Anonymous said...

Thank you for this. Found it today and saved me a bunch of work.

Great blog, thanks for the useful information!

Erintrade said...

Thanks for sharing!

Anonymous said...

This is very cool code thanks for sharing it. When I tried using it on LVS as an example, I found that it fetched the first (front month) weekly options for LVS in January, then grabbed Feb monthlies, etc. In other words, it didn't retrieve the January monthly options, just skipped that series. Any ideas why the code does this? Thanks.

TradingwithMatlab said...

I didnt get the error. I am able to get all the option chains correctly.

TradingwithMatlab said...

I didnt get the error. I am able to get all the option chains correctly.

George Lentz said...

Work well with all options except for 'spy' seems to hangup

Stock Market Investment Strategies said...
This comment has been removed by a blog administrator.
Anonymous said...

An updates? On several stocks (i.e. AMZN) there is an error in R2014a. Possibly due to so many strikes or how some stocks have weeklies?

Warning: Usage of DATENUM with empty date strings is not supported.
Results may change in future versions.
> In datenum at 83
In Get_Yahoo_Options_Data>Get_Exp_Dates at 104
In Get_Yahoo_Options_Data at 41
Index exceeds matrix dimensions.

Error in Get_Yahoo_Options_Data>@(x)[x(:,1),num2cell(str2double(x(:,[2:8]))),x(:,9),num2cell(str2double(x(:,10:end)))] (line 46)
f = @(x)[x(:,1) num2cell(str2double(x(:,[2:8]))) x(:,9) num2cell(str2double(x(:,10:end)))];

Error in Get_Yahoo_Options_Data (line 47)
DataOut.data = cellfun(f,DataOut.data,'uni',false);

Tal F said...

On October 23 Yahoo! changed their format for options chain tables in HTML, and the file posted here no longer works.

Rehan Rehan said...

Issues surrounding Options Trading can never be over analysed. At one stage or another, every man woman or child will be faced with the issue of Options Trading. Until recently considered taboo amongst polite society, it is impossible to overestimate its impact on modern thought. Inevitably Options Trading is often misunderstood by the easily lead, whom I can say no more about due to legal restrictions. With the primary aim of demonstrating my considerable intellect I will now demonstrate the complexity of the many faceted issue that is Options Trading.

General Manager said...

Thanks for sharing about trading..
best options trading book

Aditi Vyas said...

Ways2Capital-Stock Option

Saanvi Nair said...

Trading is a good medium to earn money online. Either by doing your self or taking advices like Mcx tips , equity tips, stock tips from a firm