Skip to main content

Analysis of exchange-listed financial instruments

Project description



market_analy

PyPI Python Support Code style: ruff pre-commit.ci status

A python package for interactive charting and analysis of financial instruments.

Functionality includes defining and visualising trends.

Interactive charting is offered via guis created from widgets of the bqplot, ipywidgets and ipyvuetify libraries. Users can use the underlying parts to develop their own interactive charts and analyses. Contributions very much welcome! This is a WIP and it's anticipated that further analyses will be added.

There's a load of great financial libraries out there. This library isn't reinventing the wheel (not intentionally anyway), rather it principally provides functions and interactive charting that I think are useful and couldn't find elsewhere.

Video tutorials

The following videos cover what's on offer:

  • General tutorial demonstrates the functionality as of the initial release (February 2023).
  • Trends demonstrates functionality (added June 2023) to define and visualise trends.

Features subsequently added that do not feature in the tutorial videos:

  • Subplots (added Jun 2026) - customised subplots can be added underneath the main price chart (see 'subplots' part of charts module). By default the .plot method now includes a volume subplot.
  • Drawdown (added Sep 2024) - price charts include a drawdown indicator that be set to reflect different periods or removed from the plot (see Quickstart).

Quickstart

All analyses can be accessed via the classes Analysis (single instrument analyses) and Compare (to compare multiple instruments). For example:

from market_prices import PricesYahoo
from market_analy import Analysis,  Compare

prices = PricesYahoo("MSFT")
# OR if Yahoo API endpoints are not all currently available in your region...
prices = PricesYahoo("MSFT", calendars="XNYS", delays=0)
analy = Analysis(prices)
gui = analy.plot(months=18)

https://github.com/user-attachments/assets/9d03b38d-9da2-4668-8126-e6a33a66c269

trend_kwargs = {
    "prd":60,
    "ext_break":0.05,
    "ext_limit":0.03,
    "min_bars":5,
}
gui = analy.trends_chart(
    "1D",
    trend_kwargs,
    years=3,
)

https://github.com/maread99/market_analy/assets/56914820/998c7f46-20f5-43f1-8b82-c857c0702cee

comp = Compare(PricesYahoo("MSFT, AMZN, TSLA"))
# OR if Yahoo API endpoints are not all currently available in your region...
comp = Compare(PricesYahoo("MSFT, AMZN, TSLA", calendars="XNYS", delays=0))
gui = comp.plot(hours=30)

https://user-images.githubusercontent.com/56914820/220773790-1fdabf13-25bb-4205-acc2-6bac9b832dae.mp4

gui = comp.chg_every_interval("20T", days=5, chart=True)

https://user-images.githubusercontent.com/56914820/220773802-ae329259-4a4e-4e5e-8d02-d4ee88b8b452.mp4

For further documentation see the video tutorials and the analysis module.

Installation and environment

It's recommended that market-analy is installed to a new virtual environment created using venv.

The package can be installed to the activated environment via pip:

$ pip install market-analy

Plots are intended to be created in JupyterLab (they will not load in a notebook opened in VSCode). The 'jupyter' optional dependencies can be specified to additionally install jupyter and jupyterlab to the target environment.

$ pip install market-analy[jupyter]

Alternatively, it's possible to use an existing JupyterLab installation (>=3.0) in a separate environment to that in which market_analy is installed. In this case:

  • The following dependencies should additionally be installed in the environment to which JupyterLab is installed:
    • ipyvuetify
    • bqplot
  • A kernel should be created for the environment to which market_analy was installed. Executing the following, with any virutal environment activated, will create a kernel and make it available to all installed versions of jupyterlab.
    • python -m ipykernel install --user --name mkt_analy --display-name "market analy env"

:warning: If starting JupyterLab from a different environment to the environment in which market_analy is installed then the same versions of ipyvuetify and bqplot must be installed to both environments. If either of these packages is subsequently upgraded in one environment then it must also be upgraded in the other. (This is due to the potential for conflicts between the versions in the JupyterLab environment, which are responsible for the frontend, and those in the market_analy environment where the backend is defined.)

Color scheme

The color scheme assumes the package is being used with the JupyterLab dark theme. There are no plans to provide a 'light theme' option (although a contribution would certainly be welcome from anyone seeking one).

market-prices dependency

market-analy depends on the market-prices library for price data. This provides for functionality including:

  • defining analysis periods in terms of number of sessions and trading minutes rather than calendar days and times.
  • complete data sets regardless of liquidity (regular data points during market hours, no data points outside of market hours).

Most of the arguments available to the market-prices get function can be passed directly to the market_analy functions. See the market-prices documentation for further info.

Release schedule, bugs, development and feedback

The first beta version of market_analy was released Feb 2023. Functionality to define and visually interrogate trends was added in June 2023. The drawdown indicator was added in September 2024. Customisable subplots were added in September 2026, with a volume subplot included under the main price chart by default.

The project remains immature. Whilst it's not anticipated that major changes will be made to the existing public side, they could be. All that's under-the-bonnet is subject to change as the project evolves. The guis module in particular might not permit much further development without overhauling the current inheritance-based approach to a compositional one.

The test suite is somewhat limited. It's pretty much guaranteed that there are bugs. Please raise an issue if you find one or come across unexpected behaviour.

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

Disclaimers

market-analy should not be assumed sufficiently reliable to undertake 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. The market-analy package is used entirely at the user's own risk.

The default market_prices.PricesYahoo class gets data from publically available Yahoo APIs. See the Disclaimers section of the market-prices README for conditions of use, including restrictions.

Alternative packages

  • awesome-quant offers an extensive listing of libraries for all things finance.

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_analy-0.7.tar.gz (593.8 kB view details)

Uploaded Source

Built Distribution

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

market_analy-0.7-py3-none-any.whl (136.2 kB view details)

Uploaded Python 3

File details

Details for the file market_analy-0.7.tar.gz.

File metadata

  • Download URL: market_analy-0.7.tar.gz
  • Upload date:
  • Size: 593.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for market_analy-0.7.tar.gz
Algorithm Hash digest
SHA256 b0432f78ba816cef24f941572afab60834ab278a35ffa6293ebe63172db5678d
MD5 3581c8ba46fee760b7257725661ddd73
BLAKE2b-256 e9aac8af1cf3a898b320ec3c4f7d06fe5b58acfbab09e71207ec6c0d28fd9b21

See more details on using hashes here.

File details

Details for the file market_analy-0.7-py3-none-any.whl.

File metadata

  • Download URL: market_analy-0.7-py3-none-any.whl
  • Upload date:
  • Size: 136.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for market_analy-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3a6bed2237a4f7daa73ff7e55854a1984a5b5e17b1b63bda186545398b39da9c
MD5 bcff3820ee9419aa3ba8d2a0a220e52e
BLAKE2b-256 b667ad268951e159d7f6bf9c57ef4efcc453b233ad097ddc8e1b347350904eea

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