{"id":20441815,"url":"https://github.com/furechan/mplchart","last_synced_at":"2025-07-17T01:32:42.846Z","repository":{"id":57747421,"uuid":"522679343","full_name":"furechan/mplchart","owner":"furechan","description":"Classic Stock Charts in Python","archived":false,"fork":false,"pushed_at":"2025-07-01T05:52:02.000Z","size":69281,"stargazers_count":38,"open_issues_count":5,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-01T06:32:43.274Z","etag":null,"topics":["candlesticks","charting","finance","indicators","matplotlib","python","technical-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furechan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-08T19:23:42.000Z","updated_at":"2025-07-01T05:52:06.000Z","dependencies_parsed_at":"2022-09-06T03:21:00.272Z","dependency_job_id":"e9c4845f-4463-4394-b7ad-73abe35a1773","html_url":"https://github.com/furechan/mplchart","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"83b55d1efb41c7f037d3769db8e85bf1e0e459c4"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/furechan/mplchart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmplchart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmplchart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmplchart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmplchart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furechan","download_url":"https://codeload.github.com/furechan/mplchart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmplchart/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265558465,"owners_count":23787940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["candlesticks","charting","finance","indicators","matplotlib","python","technical-analysis"],"created_at":"2024-11-15T09:35:11.850Z","updated_at":"2025-07-17T01:32:42.837Z","avatar_url":"https://github.com/furechan.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Classic Stock Charts in Python\n\n\nCreate classic technical analysis stock charts in Python with minimal code.\nThe library is built around [matplotlib](https://github.com/matplotlib/matplotlib)\nand [pandas](https://github.com/pandas-dev/pandas). \nCharts can be defined using a declarative interface,\nbased on a set of drawing primitives like `Candleststicks`, `Volume`\nand technical indicators like `SMA`, `EMA`, `RSI`, `ROC`, `MACD`, etc ...\n\n\n\u003e **Warning**\n\u003e This project is experimental and the interface can change.\n\u003e For a similar project with a mature api you may want to look into\n\u003e [mplfinance](https://pypi.org/project/mplfinance/).\n\n\n![Showcase Chart](/output/showcase.svg \"Showcase\")\n\n\n## Typical Usage\n\n```python\n# Candlesticks chart with SMA, RSI and MACD indicators\n\nimport yfinance as yf\n\nfrom mplchart.chart import Chart\nfrom mplchart.primitives import Candlesticks, Volume\nfrom mplchart.indicators import SMA, EMA, ROC, RSI, MACD\n\nticker = 'AAPL'\nprices = yf.Ticker(ticker).history('5y')\n\nmax_bars = 250\n\nindicators = [\n    Candlesticks(),\n    Volume(),\n    SMA(50),\n    SMA(200),\n    RSI(),\n    MACD(),\n]\n\nchart = Chart(title=ticker, max_bars=max_bars)\nchart.plot(prices, indicators)\nchart.show()\n```\n\n\n## Conventions\n\nPrices data is expected to be presented as a pandas DataFrame\nwith columns `open`, `high`, `low`, `close` `volume`\nand a datetime index named `date` or `datetime`.\n\nEven though the chart object automatically converts price\ncolumn names to lower case before calling any indicator,\nif you intend on using indicators independently from the chart object,\nyou must use prices dataframes with all lower case column names!\n\n\n\n## Drawing Primitives\n\nThe library contains drawing primitives that can be used like an indicator in the plot api.\nPrimitives are classes and must be instantiated as objects before being used with the plot api.\n\n```python\n# Candlesticks chart \n\nfrom mplchart.chart import Chart\nfrom mplchart.primitives import Candlesticks\n\nindicators = [Candlesticks()]\nchart = Chart(title=title, max_bars=max_bars)\nchart.plot(prices, indicators)\n```\n\nThe main drawing primitives are :\n- `Candlesticks` for candlestick plots\n- `OHLC` for open, high, low, close bar plots\n- `Price` for price line plots\n- `Volume` for volume bar plots\n- `Peaks` to mark peaks and valleys\n- `SameAxes` to use same axes as last plot\n- `NewAxes` to use new axes above or below\n- `LinePlot` draw an indicator as line plot\n- `AreaPlot` draw an indicator as area plot\n- `BarPlot` draw an indicator as bar plot\n- `ZigZag` lines between pivot points\n\n\n\n\n## Builtin Indicators\n\nThe libary includes some standard technical analysis indicators implemented in pandas/numpy.\nIndicators are classes and must be instantiated as objects before being used with the plot api.\n\nSome of the indicators included are:\n\n- `SMA` Simple Moving Average\n- `EMA` Exponential Moving Average\n- `WMA` Weighted Moving Average\n- `HMA` Hull Moving Average\n- `ROC` Rate of Change\n- `RSI` Relative Strength Index\n- `ATR` Average True Range\n- `ATRP` Average True Range Percent\n- `ADX` Average Directional Index\n- `DMI` Directional Movement Index\n- `MACD` Moving Average Convergence Divergence\n- `PPO` Price Percentage Oscillator \n- `CCI` Commodity Channel Index\n- `BOP` Balance of Power\n- `CMF` Chaikin Money Flow\n- `MFI` Money Flow Index\n- `SLOPE` Slope (linear regression)\n- `STOCH` Stochastic Oscillator\n- `BBANDS` Bollinger Bands\n- `KELTNER` Keltner Channel\n- `DEMA` Double Exponential Moving Average\n- `TEMA` Triple Exponential Moving Average\n\n\n\n## Talib Functions\n\nIf you have [ta-lib](https://github.com/mrjbq7/ta-lib) installed you can use the library abstract functions as indicators.\nThe indicators are created by calling `Function` with the name of the indicator and its parameters.\n\n```python\n# Candlesticks chart with talib indicators\n\nfrom mplchart.primitives import Candlesticks\nfrom talib.abstract import Function\n\nindicators = [\n    Candlesticks(),\n    Function('SMA', 50),\n    Function('SMA', 200),\n    Function('RSI'),\n    Function('MACD'),\n]\n```\n\n\n## Override indicator rendering with the plotting primitives\n\nMost indicators are drawn as line plots with default colors and settings. You can override the rendering of an indicator by piping it with the `|` operator into a primitive like `LinePlot`, `AreaPlot` or `BarPlot` as in the example below. If the indicator returns a dataframe instead of a series you need to specify an `item` (column name) in the primitive.\n\n\n```python\n# Customizing indicator style with LinePlot\n\nfrom mplchart.indicators import SMA, EMA, ROC\nfrom mplchart.primitives import Candlesticks, LinePlot\n\nindicators = [\n    Candlesticks(),\n    SMA(20) | LinePlot(style=\"dashed\", color=\"red\", alpha=0.5, width=3)\n]\n```\n\n\n## Override target axes with `NewAxes` and `SameAxes` primitives\n\nIndicators usually plot in a new axes below, except for a few indicators that plot by default in the main axes. You can change the target axes for any indicator by piping it into an axes primitive as in the example below.\n\n```python\n# Plotting two indicators on the same axes with SameAxes primitive\n\nfrom mplchart.indicators import SMA, EMA, ROC\nfrom mplchart.primitives import Candlesticks, SameAxes\n\nindicators = [\n    Candlesticks(),\n    ROC(20),\n    ROC(50) | SameAxes(),\n]\n```\n\n\n## Custom Indicators\n\nAny callable that accepts a prices dataframe and returns a series or dataframe can be used as an indicator.\nYou can also implement a custom indicator as a subclass of `Indicator`.\n\n```python\n# Custom Indicator Example\n\nfrom mplchart.model import Indicator\nfrom mplchart.library import calc_ema\n\nclass DEMA(Indicator):\n    \"\"\"Double Exponential Moving Average\"\"\"\n\n    same_scale: bool = True\n    # boolean, whether the indicator can be drawn\n    # on the same axes as the prices\n\n    def __init__(self, period: int = 20):\n        self.period = period\n\n    def __call__(self, prices):\n        series = self.get_series(prices)\n        ema1 = calc_ema(series, self.period)\n        ema2 = calc_ema(ema1, self.period)\n        return 2 * ema1 - ema2\n```\n\n\n## Examples\n\nYou can find example notebooks and scripts in the `examples` folder. \n\n## Installation\n\nYou can install this package with pip\n\n```console\npip install mplchart\n```\n\n## Dependencies\n\n- python \u003e= 3.9\n- matplotlib\n- pandas\n- numpy\n\n\n## Related Projects \u0026 Resources\n- [stockcharts.com](https://stockcharts.com/) Classic stock charts and technical analysis reference\n- [mplfinance](https://pypi.org/project/mplfinance/) Matplotlib utilities for the visualization, and visual analysis, of financial data\n- [matplotlib](https://github.com/matplotlib/matplotlib) Matplotlib: plotting with Python\n- [pandas](https://github.com/pandas-dev/pandas) Flexible and powerful data analysis / manipulation library for Python\n- [yfinance](https://github.com/ranaroussi/yfinance) Download market data from Yahoo! Finance's API\n- [ta-lib](https://github.com/mrjbq7/ta-lib) Python wrapper for TA-Lib\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurechan%2Fmplchart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurechan%2Fmplchart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurechan%2Fmplchart/lists"}