Skip to main content

Thin python wrapper to retrieve and work with Yahoo! finance data

Project description

yfbasic

A thin python wrapper to retrieve price action data from the Yahoo! finance API.

There are similar packages available that does this, most notably yfinance. The purpose of this package is to present the raw data as typed objects to be consumed as desired.

Getting started

The interface is straight forward, just import and query.

import yfbasic

data = yfbasic.query("GME")

The supporting parameters are typed as well.

import yfbasic
from yfbasic import Range, Interval

data = yfbasic.query("GME", range=Range.r1mo, interval=Interval.i1h)

You can use query_threaded to parallelise the data retrieval.

import yfbasic

symbols = ("GME", "AMC", "TSLA")

data = yfbasic.query_threaded(symbols)

Working with the data

The data is modelled directly of the structure returned by the yahoo api. This makes it a bit more low level to work with, but the package makes no presumptions about how you intend to work with the data.

The best way to understand the data is to look at the data structure directly.

Error handling

If we look at the Chart data model it contains two optional parameters, result and error which means we need to do application side checking of the data. To satisfy type safety we need to at least verify the existence of results by checking data.chart.results . If we want insight into any API side errors we could verify and action upon data.chart.error

import yfbasic

data = yfbasic.query("GME")

# verifying the API produced results.
if data.chart.result:
    result = data.chart.result[0]
    quotes = result.indicators.quote[0]

    # getting price action data
    timestamps = result.timestamp
    open = quotes.open
    close = quotes.close
    high = quotes.high
    low = quotes.low
    volume = quotes.volume

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

yfbasic-0.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

yfbasic-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file yfbasic-0.2.0.tar.gz.

File metadata

  • Download URL: yfbasic-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.10.26-1-MANJARO

File hashes

Hashes for yfbasic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 43ec4301c095dd11e5f89c5ce6c42b0be9340bbb70dbc1e64f3eb8869cee461a
MD5 9260b9404106883981823476d1373f9b
BLAKE2b-256 b39059aac6f88abb28587e0f54c2382a8f41d636240f7e75273b36c8c454526a

See more details on using hashes here.

File details

Details for the file yfbasic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: yfbasic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.10.26-1-MANJARO

File hashes

Hashes for yfbasic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 252a99e1c3beb7175868cf090a4cdb5f44d449bc78b3432c8811cb7004d26c6d
MD5 7359a19857113c080bf2fbbd33919c9a
BLAKE2b-256 575eca833a663f6d43797b55a06461b0d0f9d1e60a12901d2c490db2ab281bf1

See more details on using hashes here.

Supported by

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