Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get stock option chains using YQL?

I am trying to get stock option chains from Yahoo using YQL. I have tried this command in the YQL console:

select * from yahoo.finance.options

However, I get this error XML:

<?xml version="1.0" encoding="UTF-8"?>
<error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:lang="en-US">
    <diagnostics>
        <publiclyCallable>true</publiclyCallable>
    </diagnostics> 
    <description>No definition found for Table yahoo.finance.options</description>
</error>

It looks like this table doesn't exist anymore. Does anyone know what the correct table is?

like image 698
Programmer_D Avatar asked Oct 07 '12 22:10

Programmer_D


2 Answers

You have to provide at least one where clause to make this query work. Like this:

select * from yahoo.finance.options where  symbol='MMM'

or,

select * from yahoo.finance.options where  symbol='A'

or,

select * from yahoo.finance.options where  symbol='YHOO'

All the above queries work fine. If you want more specific data then you have to provide more conditions to filter out your desired data out of the whole data.

like image 106
K M Rakibul Islam Avatar answered Oct 08 '22 19:10

K M Rakibul Islam


yahoo.finance.options is a community table. To read about community tables check here. From the link I just posted:

In order to use YQL with the community tables, you must pass in the datatables env file. You can do this on the YQL console as part of a YQL statement, or by passing in a query parameter.

The YQL console to test this can be found here

like image 30
Karan Ashar Avatar answered Oct 08 '22 19:10

Karan Ashar