Skip to main content

Download option chain data from Yahoo Finance

Project description

yfoptions_dl

yfoptions_dl is a Python library for downloading daily option chain data from yahoo finance. Data is retrieved using yahoo finance's API, then parsed into a pandas dataframe.

Installing yfoptions_dl

The easiest way to install yfoptions_dl is from Python Package Index using pip:

pip install yfoptions_dl

Example

To get all available data fields:

  aapl = optionChain('aapl')
  >>> aapl.data_header
['contractSymbol', 'strike', 'currency', 'lastPrice', 'change', 'percentChange', 'volume', 'openInterest', 'bid', 'ask', 'contractSize', 'expiration', 'lastTradeDate', 'impliedVolatility', 'inTheMoney']

To get all available strikes for the front month options:

>>> aapl.strikes
[57.5, 58.75, 60.0, 61.25, 62.5, 63.75, 65.0, 66.25, 67.5, 68.75, 70.0, .....]

To get the entire call option chain:

>>> aapl.calls
         contractSymbol  strike  ...                       date  type
0   AAPL200925C00057500   57.50  ... 2020-09-22 16:24:11.085367     C
1   AAPL200925C00058750   58.75  ... 2020-09-22 16:24:11.085367     C
2   AAPL200925C00060000   60.00  ... 2020-09-22 16:24:11.085367     C
3   AAPL200925C00061250   61.25  ... 2020-09-22 16:24:11.085367     C
4   AAPL200925C00062500   62.50  ... 2020-09-22 16:24:11.085367     C
..                  ...     ...  ...                        ...   ...
26  AAPL230120C00180000  180.00  ... 2020-09-22 16:24:15.772460     C
27  AAPL230120C00185000  185.00  ... 2020-09-22 16:24:15.772460     C
28  AAPL230120C00190000  190.00  ... 2020-09-22 16:24:15.772460     C
29  AAPL230120C00195000  195.00  ... 2020-09-22 16:24:15.772460     C
30  AAPL230120C00200000  200.00  ... 2020-09-22 16:24:15.772460     C

[2119 rows x 17 columns]

To get hte entire put option chain:

>>> a.puts
             contractSymbol  strike  ...                       date  type
    0   AAPL200925P00057500   57.50  ... 2020-09-22 16:24:11.107355     P
    1   AAPL200925P00058750   58.75  ... 2020-09-22 16:24:11.107355     P
    2   AAPL200925P00060000   60.00  ... 2020-09-22 16:24:11.107355     P
    3   AAPL200925P00061250   61.25  ... 2020-09-22 16:24:11.107355     P
    4   AAPL200925P00062500   62.50  ... 2020-09-22 16:24:11.107355     P
    ..                  ...     ...  ...                        ...   ...
    18  AAPL230120P00140000  140.00  ... 2020-09-22 16:24:15.782454     P
    19  AAPL230120P00150000  150.00  ... 2020-09-22 16:24:15.782454     P
    20  AAPL230120P00155000  155.00  ... 2020-09-22 16:24:15.782454     P
    21  AAPL230120P00160000  160.00  ... 2020-09-22 16:24:15.782454     P
    22  AAPL230120P00200000  200.00  ... 2020-09-22 16:24:15.782454     P

    [2016 rows x 17 columns]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yfoptions_dl-1.0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yfoptions_dl-1.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file yfoptions_dl-1.0.2.tar.gz.

File metadata

  • Download URL: yfoptions_dl-1.0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for yfoptions_dl-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a4a6a7802c3dc3c3bf15d567f305092db9e1bb9bab7495baddd5e9e746919d1a
MD5 8c28e3c315cd8a03e31e640ce7b34229
BLAKE2b-256 b06ec787aabba9d37fb3761741b70ce9cda5a1e986504e9539d6cbac4d3a8c1a

See more details on using hashes here.

File details

Details for the file yfoptions_dl-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: yfoptions_dl-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for yfoptions_dl-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 30d2a90676434579ed95aabe93d0ab6f5c2f65155ea99fba7083e4187077f6cb
MD5 0781642ee0dcb902562f04f02f3ec579
BLAKE2b-256 5dd03f86633d0df1277e020a174aba2671e514ee3e0ddb4c7ff029c3f267146d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page