How can I download option data given the new format introduced today. 10/23/14?

一世执手 提交于 2019-12-11 14:19:36

问题


Yahoo just broke all my option programs, dozens of them!

I used to download raw option pages in perl and parse them.

Today, 10/23/14, Yahoo introduced a new format for their option pages. A downloaded page now has no data, just javascript that loads stuff on the fly.

A browser (Firefox) processes that, and source viewed in the browser shows all the data, but I have no way of getting that into perl.

Is there some perl module which will simulate whatever the browser is doing, and hand me the processed page to parse?

I could get data from the CBOE, but that requires manual data entry on their web site, and I want to do this out of perl.

One nice thing about Yahoo is that I can address individual expiration date pages via the URL, but CBOE and others just return .aspx pages based on manual interaction. All the URLs look the same.

Other Yahoo pages, like stock history, provide URL-addressable downloadable CSV files. Is there anyway to get their option data like that?

Or is there some other site I could use?


回答1:


I was able to successfully execute the spreadsheet formula below from a google spreadsheet to pull option data into my spreadsheet (in the formula below, "Naked Put!A2" = TUP, and "Naked Put!C2 = 1/17/2015, which corresponds to the option chain for Tupperware for January, 2015):

=importXML("http://finance.yahoo.com/q/op?s="&UPPER('Naked Put'!A2)&"&date="&datevalue('Naked Put'!C2)*86400-date(1970,1,1)*86400,"//tr")

The resulting output is a table with rows for each strike price and columns filled with: Strike price, contract name, last price, bid, ask, volume, etc.

The problem you are seeing may be related to the fact that the new option page is formatted differently from the old option page. For example the option data is now stored in a html table construct.




回答2:


The new format is a spreadsheet based integer representation of the date. The integer number is the number of seconds since January 3, 1970. So to convert an option date (like November 22, 2014) to the new integer format, use the following (excel based) formula: =date(2014,11,22)*86400 - date(1970,1,3)*86400



来源:https://stackoverflow.com/questions/26539963/how-can-i-download-option-data-given-the-new-format-introduced-today-10-23-14

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!