Skip to main content

Meaningful OHLCV datasets

Project description

market_prices

PyPI Python Support Code style: black

A python library to create meaningful OHLCV datasets.

Works out-the-box with prices from the Yahoo Finance API (see Disclaimers).

screenshot

Features include:

  • Include securities trading on different exchanges with differing opening hours across different time zones.
  • Request the period covered by a dataset in terms of either:
    • trading time (minutes and hours)
    • number of sessions
    • calendar time (weeks, months and years)
  • Request data at ANY interval (pretty much).
  • Use properties and functions of the pd.DataFrame.pt accessor to interrogate and operate directly on price tables.
  • Anchor indices either:
    • on each (sub)session open.
    • on the period end and work back (crossing sessions).
  • Price tables indexed with a pandas IntervalIndex that defines both sides of the time interval covered by each row.
  • Respects breaks in exchanges that observe separate morning and afternoon subsessions.
  • Indices excluded for any periods when no underlying exchange is open.
  • Fills missing prices, by security, within the bounds of trading hours (zero leakage).
    • Optionally fills missing values outside of trading hours (for multiple securities with different opening hours).
  • Efficient data-usage (only requests data required and only requests any data point once).

Installation

$ pip install market_prices

pip will also take care of installing any missing dependencies.

Although not a dependency, it's anticipated that market_prices will be used within a Jupyter environment (JupyterLab or a Jupyter Notebook).

Tutorials / Documentation

market_prices comes with a host of notebook tutorials that show example usage and explain every aspect of what's on offer. Check out quickstart.ipynb for a taster.

All tutorials and other documentation are indexed here.

Each method's own documentation is also pretty comprehensive.

exchange_calendars

market_prices is nothing without exchange_calendars.

exchange_calendars provides market_prices:

  • Knowledge of underlying exchanges' opening times.
  • A wealth of functionality to interrogate exchanges' sessions and trading minutes.

This knowledge and functionality allows market_prices to:

  • Index prices according to exchanges' opening hours.
  • Evaluate periods defined in terms of trading minutes or sessions.

Calendar maintenance

If you come across missing prices or sessions then the first port of call is to check that the associated calendar is accurate - it may need updating.

  • If prices are not included for a session, the calendar may be assuming that day is a holiday.
  • If prices are included on a day when the exchange was closed, the calendar is probably assuming that day represents a trading session. In this case prices for the non-trading day will have a constant value and a errors.PricesMissingWarning will have been raised when the prices were requested.

All calendars are maintained by user-contributions. If you find one that needs updating, PR the required changes over at exchange_calendars and it'll filter into market_prices on the next exchange_calendars release. Links to the workflow to update calendars can be found here.

The prices tutorial covers how market_prices associates calendars with symbols.

Release schedule, bugs, development and feedback

The first beta version of market_prices was released May 2022.

Whilst the test suite is pretty comprehensive, there will inevitably be bugs. Please do raise an issue with any that you come across. Even better, offer a PR! Contributions welcome.

Please use discussions to make any suggestions and offer general feedback.

A new beta release will be made to coincide with the release of exchange_calendars version 4.0. The public interface will remain unchanged although the minimum version of the exchange_calendars dependency will be advanced to 4.0 to allow for some of the internals to be cleaned up.

Disclaimers

market_prices should not be assumed sufficiently reliable to undertake market analysis intended to inform investment decisions. Users should inspect the source code and the test suite of the library and its dependencies in order to make their own assessment of the packages' suitability for their purposes. market_prices is used entirely at the user's own risk.

Yahoo APIs

The default PricesYahoo class requests data from publically available Yahoo APIs via the yahooquery package.

market_prices is NOT in any way affiliated, partnered, sponsored or endorsed by Yahoo. Users of the PricesYahoo class should make enquiries to satisfy themselves that they are eligible to receive data from Yahoo APIs and are in compliance with the license requirements and Terms of Service under which the Yahoo APIs may be accessed, to include restrictions concerning NO COMMERCIAL USE.

Users may find the following references useful in this respect. (These references should not be considered to definitively cover all terms and conditions related to the use of Yahoo APIs.)

Further, it should NOT be assumed that price data returned by the PricesYahoo class will accurately reflect data as provided by Yahoo APIs. In this respect users should make their own inspection of the source code and test suites of market_prices and its dependencies.

License

MIT License

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

market_prices-0.8.2.tar.gz (133.9 kB view details)

Uploaded Source

Built Distribution

market_prices-0.8.2-py3-none-any.whl (139.7 kB view details)

Uploaded Python 3

File details

Details for the file market_prices-0.8.2.tar.gz.

File metadata

  • Download URL: market_prices-0.8.2.tar.gz
  • Upload date:
  • Size: 133.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for market_prices-0.8.2.tar.gz
Algorithm Hash digest
SHA256 5c6fbf71a7890211b50d00f7e47ab6058e5c460d1386cf58d016b55a90c2de55
MD5 5daad4cd9e821a55ef8e8a253bbffb20
BLAKE2b-256 926c617aab0b1cdb99eccea9f87f95b699cd7a6fd3059e7098af028ea2416ec3

See more details on using hashes here.

File details

Details for the file market_prices-0.8.2-py3-none-any.whl.

File metadata

File hashes

Hashes for market_prices-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4065cc76932648e3c6f2bea12448851ae6a2826c3687c9059b55e24a11f3f140
MD5 7dbde3a7084db7fe8af906312501734c
BLAKE2b-256 310d164ffdaa1b59cd550e2715acd664097c587ca5729fc37195a7ec68a460cf

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