Knowledge Base | How to Load Option Chains from Google Finance to CSV

How to Load Option Chains from Google Finance to CSV

Option Chains at Google Finance

Google Finance publishes US stock option chains.

You can open https://www.google.com/finance/, search a ticker like GOOGL, and click the 'Option chain' link on the left panel.

You can use URLs like https://www.google.com/finance/option_chain?q=GOOGL to open pages with option chains directly.

Google Finance has no links to download option chains to CSV.

Also, last time Google Finance has a strange set of expiration dates.
So, we do not recommend to use it. You can use Yahoo Finance or MSN Money instead.

Undocumented URLs to Download Option Chains from Google Finance

Google Finance uses a web service to load option chains into web pages.

The web service returns JSON and has URLs like these:

https://www.google.com/finance/option_chain?q=GOOGL&output=json

https://www.google.com/finance/option_chain?q=GOOGL&output=json&expd=19&expm=01&expy=2018

You can use specialized download and parser utilities like gsqlcmd to download and convert JSON data to CSV.

For example, to get option chains use the command:

gsqlcmd convert ^
    "https://www.google.com/finance/option_chain?q=GOOGL&output=json" ^
    GOOGL.CSV /delay=200 /echoOutputFileName /pages=20 /rootPath=calls,puts

gsqlcmd in the webtocsv mode loads web data (JSON, XML, HTML, CSV) and converts the data to CSV.

Specify the /rootPath=calls,puts parser parameter that points to the JSON roots of call and put option chains.

gsqlcmd loads option chains for all expiration dates automatically. Just specify the /page=20 option.

Loading Option Chains from Google Finance with Batch Files

Create a text file like 'task.txt' and place tickers one by line like:

TICKERS.TXT
AAPL
FB
GOOGL
YHOO

Create a batch file like 'load.cmd' with the following commands:

LOAD.CMD
@echo off

@for /F %%i in (tickers.txt) do (
    gsqlcmd convert ^
        "https://www.google.com/finance/option_chain?q=%%i&output=json" ^
        %%i.JSON %%i.CSV /delay=200 /echoOutputFileName /pages=20 /rootPath=calls,puts
)

Run it. You will see the result:

C:>load.cmd
AAPL.CSV - 170 rows
FB.CSV - 159 rows
GOOGL.CSV - 298 rows
YHOO.CSV - 30 rows

As we talked above, Google Finance returns incomplete expiration dates.

Pay attention to the /delay parameter. Use the delay to avoid banning your IP due to frequent multiple automatic requests.

Downloads

Products for Option Traders
gsqlcmd
This tool downloads, converts, and imports data from Yahoo Finance and MSN Money
Version: 6.12 | 04/30/2024 | 14.6MB | www.savetodb.com
Download

Disclaimer

Google Finance is a logo and registered trademark of Google Inc.