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.0.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.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yfoptions_dl-1.0.0.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.20.1 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.0.tar.gz
Algorithm Hash digest
SHA256 4c055d290cf9cbd331494320fbed28562d8303db210443d007a77988e99fab55
MD5 3411e1bb64ab7a98294566b42d71c10c
BLAKE2b-256 1161dd35e262b8b5b5ffde772fa8ffb956fc715915958031fe6d8d33341ea216

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yfoptions_dl-1.0.0-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.20.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f00a0c9308c0660bf6d7db149567662bebbebde65a4cdd386ae1fc5f31228e
MD5 b9aba1420b430981da4a78d36aa434c5
BLAKE2b-256 6e2c3ca1bae944a98e61c34a4a166fd0435f5f067f4944e45ee1b52aad1aa708

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