Knowledge Base | How to Load Option Chains from Yahoo Finance to Databases

How to Load Option Chains from Yahoo Finance to Databases

Yahoo Finance allows viewing option chain data online but has no download links.

So, available solutions load and parse option chain web pages from the Yahoo Finance website directly.

You can try two ready-to-use solutions to solve this task:

  1. Using Market Data Downloader.
  2. Using RTD.DB.

Market Data Downloader includes a preconfigured database and a solution for Microsoft SQL Server.

RTD.DB allows using Microsoft SQL Server, SQL Server Compact, Oracle Database, IBM DB2, MySQL, PostgreSQL, and NuoDB.

The RTD.DB download package includes SQL codes and batch files to create ready-to-use databases for all supported platforms.

The first method is oriented to loading all option chains of the selected tickers using the batch files on a schedule.

The second method is oriented to loading specified option contracts automatically based on refresh intervals.

You can use both methods to get desired results.

Loading Option Chains to Databases Using Market Data Downloader

Market Data Downloader includes a preconfigured project for loading option chains from Yahoo! Finance for US exchanges.

Quick steps:

  1. Download Market Data Downloader.
  2. Copy the MarketData folder from the downloaded package to the root of drive C:
  3. Edit symbols in files in the symbols folder like us-quotes.txt.
  4. Run the C:\MarketData\2-load-csv-us.cmd batch file.
  5. Check CSV files in the C:\MarketData\csv folder.

Market Data Downloader also includes a preconfigured database for Microsoft SQL Server and a ready-to-use batch file to import CSV data.

See Preconfigured Project.

Loading Option Chains to Databases Using RTD.DB

You can install RTD.DB using a standalone setup package:

  1. Download and install RTD.DB.
  2. Run RTD.DB using the link from 'Start,  All Programs, Gartle, RTD.DB'.

You will see the following application screen:

RTD.DB Screenshot

RTD.DB will start updating the preconfigured local Microsoft SQL Server Compact database with data from Yahoo Finance for currencies, stocks, and options.

For example, you can see the OptionDayHistoryYahoo row.

Click the Stop button.

Further, you have to make the following steps:

  1. Create an RTD database on your server.
  2. Configure a connection to your server.
  3. Configure updated database tables.
  4. Configure a list of option contracts to refresh.

Creating RTD Database

Steps:

  1. Open the folder of the unzipped download package.
  2. Open the RTD Database folder and open a folder for the target database platform.
  3. Run the 1-edit-config.cmd batch file and edit the connection strings to your database server.
  4. Run the 2-create-database.cmd batch file.
  5. Run the 3-rtd-setup.cmd batch file.
  6. Run the 4-rtd-list.cmd batch file.
  7. Run the 5-rtd-grant.cmd batch file.

As a result, you will have the RTD database on your target server.

If the files have other names, please, read the readme.txt in the setup folder.

Configuring Connections

Steps:

  1. Run RTD.DB if it is not started.
  2. Click the Connections button.
  3. Edit and enable the connection string to your server and disable the default SQL Server Compact database.
  4. Click the Save button and close the application.
  5. Click the RTD.DB Stop button and then click the Start button.

Here is a screenshot of the gConnectionManager application used for editing connecting strings.

Configuring RTD.DB connections using gConnectionManager

Configuring Updated Database Tables

The RTD database contains preconfigured tables for loading various data from various data sources with various time frames.

Steps to activate or deactivate loading data:

  1. Open the RTD database in your database manager.
  2. Open the rtd.RealTimeTables (rtd.real_time_tables) table in edit mode.
  3. Set 1 into the IS_DISABLED column to disable loading and set the value to NULL to enable loading.
  4. Save changes.
  5. Click the RTD.DB Stop button and then click the Start button.

Here is an example of the table for Microsoft SQL Server: 

RTD.DB Configuration Table for Microsoft SQL Server

See RTD.DB Database Configuration about configuration tables.

Editing Configuration Tables in Microsoft Excel

You can use Microsoft Excel to edit configuration tables if you have SaveToDB add-in installed.

Preparation steps:

  1. Open Microsoft Excel.
  2. Open the RTD Workbooks folder in the downloaded package.
  3. Open the workbook for your target server. For example, rtd-mysql.xlsx for MySQL.
  4. Open the SaveToDB tab, click Wizards menu, Change Connection Wizard.
  5. Specify a server, a database, and database credentials for your database. Click Next.
  6. Click Finish to change connections for the selected tables.
  7. Save the workbook to your location.

Configuration steps:

  1. Open the prepared workbook connected to your database.
  2. Open the RealTimeTables worksheet.
  3. Open the SaveToDB tab and click the Reload button.
  4. Set 1 into the IS_DISABLED column to disable loading and clear the value to enable loading.
  5. Open the SaveToDB tab and click the Save button.

Configuring List of Option Contracts to Refresh

As you can see above, option tables for Yahoo Finance are configured with the following code in the LOAD_CODE field:

SELECT Code FROM rtd.OptionListYahoo

You can change this SQL code for loading option codes from your existing table.

Or you can use the preconfigured rtd.OptionListYahoo table.

The rtd.OptionListYahoo table contains test option codes:

Option list for loading from Yahoo Finance

You can insert required option codes into the table using any available method.

Note that you can use the workbook prepared in the previous step. Just use the OptionListYahoo worksheet.

Note that you have to remove expired option codes from the table also.

Different editions of RTD.DB have different limits for a number of updated option codes.

The Personal edition ($100) allows updating option codes for up to 1000 stocks.

See RTD.DB Edition Comparison for details.

Getting Option Codes

RTD.DB loads option data for specified option codes. It does not load entire option chains automatically.

So if you need to load all option contracts for the specified symbols, you can use any solution to get option codes and to insert them into the rtd.OptionListTOS table.

You can solve this task using Market Data Downloader.

For example, for SQL Server, you can add the following SQL code to insert option codes from the OptionContacts table:

INSERT INTO RTD.rtd.OptionListYahoo
    (Code)
SELECT
    c.ContractName
FROM
    MarketData.yahoo.OptionContracts c
    LEFT OUTER JOIN RTD.rtd.OptionListYahoo t
        ON t.Code = c.ContractName COLLATE SQL_Latin1_General_CP1_CI_AS
WHERE
    t.Code IS NULL
    AND c.ExpDate > GETDATE()

Downloads

Products for Traders and Investors
RTD.DB
The app saves data from trading platforms like Thinkorswim to databases
Version: 5.23 | 06/27/2023 | 15.2MB | Getting Started | What's New | Edition Comparison
Download
MARKET.CSV
The app loads data from Yahoo Finance and MSN Money to CSV and SQL Server
Version: 2.24 | 08/23/2023 | 1.5MB | Getting Started | What's New | Edition Comparison
Download

Disclaimer

Yahoo Finance is a logo and registered trademark of Yahoo! Inc.