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.9.0.tar.gz (132.0 kB view hashes)

Uploaded Source

Built Distribution

market_prices-0.9.0-py3-none-any.whl (137.7 kB view hashes)

Uploaded Python 3

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