{"id":20441823,"url":"https://github.com/furechan/mintalib","last_synced_at":"2025-04-12T23:33:04.974Z","repository":{"id":57768107,"uuid":"518952337","full_name":"furechan/mintalib","owner":"furechan","description":"Minimal Technical Analysis Library for Python","archived":false,"fork":false,"pushed_at":"2024-04-26T01:28:07.000Z","size":4919,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-27T01:32:18.440Z","etag":null,"topics":["cython","indicators","python","technical-analysis"],"latest_commit_sha":null,"homepage":"","language":"Cython","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}},"created_at":"2022-07-28T18:20:47.000Z","updated_at":"2024-04-27T01:32:18.440Z","dependencies_parsed_at":"2024-03-16T15:13:55.608Z","dependency_job_id":"9e76634a-b146-4320-8747-303a41fb87c5","html_url":"https://github.com/furechan/mintalib","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"b7de427f84a0d962a6364db7dd6f7d86299c7e62"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmintalib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmintalib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmintalib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furechan%2Fmintalib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furechan","download_url":"https://codeload.github.com/furechan/mintalib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647258,"owners_count":21139081,"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":["cython","indicators","python","technical-analysis"],"created_at":"2024-11-15T09:35:12.754Z","updated_at":"2025-04-12T23:33:04.967Z","avatar_url":"https://github.com/furechan.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal Technical Analysis Library for Python\n\nThis package offers a curated list of technical analysis indicators and timeseries calculations\nall implemented in cython for improved performance. The library is built around `numpy` arrays,\nand is compatible with `pandas` dataframes and series.\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 [ta-lib](https://pypi.org/project/TA-Lib/).\n\n\n## Structure\n\nThe `mintalib` package contains three main modules:\n\n- [mintalib.core](/docs/mintalib.core.md)\n    core calculation rountines implemented in cython, with names like `calc_sma`, `calc_ema`, etc ...  \n- [mintalib.functions](/docs/mintalib.functions.md)\n    wrapper functions to compute calculations on series and dataframes, with names like `sma`, `ema`, etc ...\n- [mintalib.indicators](/docs/mintalib.indicators.md)\n    composable interface to indicators with names like `SMA`, `EMA`, etc ...\n\n\n## List of Indicators\n\n| Name       | Description                                      |\n|:-----------|:-------------------------------------------------|\n| ABS        | Absolute Value                                   |\n| ADX        | Average Directional Index                        |\n| ALMA       | Arnaud Legoux Moving Average                     |\n| ATR        | Average True Range                               |\n| AVGPRICE   | Average Price                                    |\n| BBANDS     | Bollinger Bands                                  |\n| BOP        | Balance of Power                                 |\n| CCI        | Commodity Channel Index                          |\n| CLAG       | Confirmation Lag                                 |\n| CMF        | Chaikin Money Flow                               |\n| CROSSOVER  | Cross Over                                       |\n| CROSSUNDER | Cross Under                                      |\n| CURVE      | Curve (quadratic regression)                     |\n| DEMA       | Double Exponential Moving Average                |\n| DIFF       | Difference                                       |\n| DMI        | Directional Movement Indicator                   |\n| EMA        | Exponential Moving Average                       |\n| EVAL       | Expression Eval (pandas only)                    |\n| EXP        | Exponential                                      |\n| FLAG       | Flag Value                                       |\n| HMA        | Hull Moving Average                              |\n| KAMA       | Kaufman Adaptive Moving Average                  |\n| KELTNER    | Keltner Channel                                  |\n| KER        | Kaufman Efficiency Ratio                         |\n| LAG        | Lag Function                                     |\n| LOG        | Logarithm                                        |\n| LROC       | Logarithmic Rate of Change                       |\n| MACD       | Moving Average Convergenge Divergence            |\n| MAD        | Rolling Mean Absolute Deviation                  |\n| MAV        | Generic Moving Average                           |\n| MAX        | Rolling Maximum                                  |\n| MDI        | Minus Directional Index                          |\n| MFI        | Money Flow Index                                 |\n| MIDPRICE   | Mid Price                                        |\n| MIN        | Rolling Minimum                                  |\n| NATR       | Average True Range (normalized)                  |\n| PDI        | Plus Directional Index                           |\n| PPO        | Price Percentage Oscillator                      |\n| PRICE      | Generic Price                                    |\n| QSF        | Quadratic Series Forecast (quadratic regression) |\n| RMA        | Rolling Moving Average (RSI style)               |\n| ROC        | Rate of Change                                   |\n| RSI        | Relative Strength Index                          |\n| RVALUE     | R-Value (linear regression)                      |\n| SAR        | Parabolic Stop and Reverse                       |\n| SHIFT      | Shift Function                                   |\n| SIGN       | Sign                                             |\n| SLOPE      | Slope (linear regression)                        |\n| SMA        | Simple Moving Average                            |\n| STDEV      | Standard Deviation                               |\n| STEP       | Step Function                                    |\n| STOCH      | Stochastic Oscillator                            |\n| STREAK     | Consecutive streak of ups or downs               |\n| SUM        | Rolling sum                                      |\n| TEMA       | Triple Exponential Moving Average                |\n| TRANGE     | True Range                                       |\n| TSF        | Time Series Forecast (linear regression)         |\n| TYPPRICE   | Typical Price                                    |\n| UPDOWN     | Flag for value crossing up \u0026 down levels         |\n| WCLPRICE   | Weighted Close Price                             |\n| WMA        | Weighted Moving Average                          |\n\n\n## Using Functions\n\nFunctions are available as lower case methods like `sma`, `ema`, etc ...\nThe best way to use this module is to alias it to a short name\nlike `ta` and access all functions as attributes.\n\n```python\nimport mintalib.functions as ta\n```\n\nThe first parameter of a function is either `prices` or `series` depending on whether\nthe functions expects a dataframe of prices or a single series.\n\nFunctions that expect series data can be applied to a prices dataframe, in which case they use \nthe column specified with the `item` parameter or by default the 'close' column.\n\nA `prices` dataframe can be a pandas dataframe or a dictionary of numpy arrays.\nThe column names for prices are expected to include `open`, `high`, `low`, `close`, `volume` all in **lower case**.\n\nA `series` can be a pandas series or any iterable compatible with numpy arrays.\n\nFunctions automatically wrap the result to match the type and the index of the input data when applicable.\n\n\n```python\nimport yfinance as yf\nimport mintalib.functions as ta\n\n# fetch prices (eg with yfinance)\nprices = yf.Ticker('AAPL').history('5y')\n\n# convert column and index names to lower case\nprices = prices.rename(columns=str.lower).rename_axis(index=str.lower)\n\n# compute indicators\nsma50 = ta.sma(prices, 50)  # SMA of 'close' with period 50\nsma200 = ta.sma(prices, 200)  # SMA of 'close' with period 200\nhigh200 = ta.max(prices, 200, item='high')  # MAX of 'high' with period 200\n```\n\n\n## Using Indicators\n\nIndicators are available via the `indicators` module, with similar names as functions but in **upper case**.\n\nIndicators offer a composable interface where a function is bound with its calculation parameters. When instantiated with parameters an indicator yields a callable that can be applied to prices or series data.\n\nAn indicator is a callable that accepts a series or a prices dataframe as a single parameter. You can also use the `@` operator as syntactic sugar to apply an indicator to its parameter. \n\nSo for example `SMA(50) @ prices` can be used to compute the 50 period simple moving average on `prices`, instead of the more verbose `SMA(50)(prices)`. \n\n```python\nfrom mintalib.indicators import ROC, SMA, EMA\n\nsma50 = SMA(50) @ prices    # SMA of 'close' with period 50\nsma200 = SMA(200) @ prices  # SMA of 'close' with period 200\nhigh200 = MAX(200, item='high') @ prices    # MAX of 'high' with period 200\n```\n\n\nThe `@` operator can also be used to chain indicators, where for example `ROC(1) @ EMA(20)` means `ROC(1)` applied to `EMA(20)`.\n\n\n```python\nfrom mintalib.indicators import ROC, SMA, EMA\n\ntrend = ROC(1) @ EMA(20) @ prices\n```\n\n\nWith pandas dataframes you can compose and apply multiple indicators in one call using the `assign` dataframe method.\n\n```python\nimport yfinance as yf\n\nfrom mintalib.indicators import EMA, SMA, ROC, RSI, EVAL\n\n# fetch prices (eg with yfinance)\nprices = yf.Ticker('AAPL').history('5y')\n\n# convert column and index names to lower case\nprices = prices.rename(columns=str.lower).rename_axis(index=str.lower)\n\n# compute and append indicators to prices\n# note that calculations can use results from prior indicators\nresult = prices.assign(\n    sma50 = SMA(50),\n    sma200 = SMA(200),\n    rsi = RSI(14),\n    trend = ROC(1) @ EMA(20),\n    flag = EVAL(\"sma50 \u003e sma200\")\n)\n```\n\n\n## Example Notebooks\n\nYou can find example notebooks in the `examples` folder. \n\n\n## Installation\n\nYou can install this package with pip\n\n```console\npip install mintalib\n```\n\n## Dependencies\n\n- python \u003e= 3.9\n- pandas\n- numpy\n\n\n## Related Projects\n\n- [ta-lib](https://github.com/mrjbq7/ta-lib) Python wrapper for TA-Lib\n- [qtalib](https://github.com/josephchenhk/qtalib) Quantitative Technical Analysis Library\n- [numpy](https://github.com/numpy/numpy) The fundamental package for scientific computing 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\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurechan%2Fmintalib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurechan%2Fmintalib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurechan%2Fmintalib/lists"}