trend-classifier


Nametrend-classifier JSON
Version 0.1.10 PyPI version JSON
download
home_pageNone
SummaryPackage for automated signal segmentation, trend classification and analysis.
upload_time2024-03-21 10:39:21
maintainerNone
docs_urlNone
authorNone
requires_python<=3.13,>=3.9
licenseMIT
keywords trend timeseries classification segmentation analysis algotrading finance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Trend classifier
![](https://img.shields.io/pypi/v/trend-classifier.svg)
![](https://img.shields.io/pypi/pyversions/trend-classifier.svg)
![](https://img.shields.io/pypi/l/trend-classifier.svg)
![](https://img.shields.io/pypi/dm/trend-classifier.svg)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/izikeros/trend_classifier/main.svg)](https://results.pre-commit.ci/latest/github/izikeros/trend_classifier/main)
[![Black formatter](https://github.com/izikeros/trend_classifier/actions/workflows/black.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/black.yml)
[![flake8](https://github.com/izikeros/trend_classifier/actions/workflows/flake8.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/flake8.yml)
[![pytest](https://github.com/izikeros/trend_classifier/actions/workflows/pytest.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/pytest.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/081a20bb8a5201cd8faf/maintainability)](https://codeclimate.com/github/izikeros/trend_classifier/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/081a20bb8a5201cd8faf/test_coverage)](https://codeclimate.com/github/izikeros/trend_classifier/test_coverage)

Library for automated signal segmentation, trend classification and analysis.

## Installation

1. The package is pip-installable. To install it, run:

   ```sh
   pip3 install trend-classifier
   ```

## Usage
### Pandas DataFrame Input
usage:
```python
import yfinance as yf
from trend_classifier import Segmenter

# download data from yahoo finance
df = yf.download("AAPL", start="2018-09-15", end="2022-09-05", interval="1d", progress=False)

x_in = list(range(0, len(df.index.tolist()), 1))
y_in = df["Adj Close"].tolist()

seg = Segmenter(x_in, y_in, n=20)
seg.calculate_segments()
```

For graphical output use `Segmenter.plot_segments()`:
```python
seg.plot_segments()
```

![Segmentation example](https://github.com/izikeros/trend_classifier/blob/main/img/screenshoot_1.jpg?raw=true)

After calling method `Segmenter.calculate_segments()` segments are identified and information is stored in `Segmenter.segments` as list of Segment objects. Each Segment object. Each Segment object has attributes such as 'start', 'stop' - range of indices for the extracted segment, slope and many more attributes that might be helpful for further analysis.

Exemplary info on one segment:
```python
from devtools import debug
debug(seg.segments[3])
```
and you should see something like this:
```
    seg.segments[3]: Segment(
        start=154,
        stop=177,
        slope=-0.37934038908585044,
        offset=109.54630934894907,
        slopes=[
            -0.45173184100846725,
            -0.22564684358754555,
            0.15555037018051593,
            0.34801127785130714,
        ],
        offsets=[
            121.65628807526804,
            83.56079272220015,
            17.32660986821478,
            -17.86417581658647,
        ],
        slopes_std=0.31334199799377654,
        offsets_std=54.60900279722876,
        std=0.933497081795997,
        span=82.0,
        reason_for_new_segment='offset',
    )
```
export results to tabular format (pandas DataFrame):
```python
seg.segments.to_dataframe()
```
![](https://github.com/izikeros/trend_classifier/blob/main/img/to_dataframe.jpg?raw=true)

(**NOTE:** for clarity reasons, not all columns are shown in the screenshot above)

## Alternative approach
- Smooth out the price data using the Savitzky-Golay filter,
- label the highs and lows.
- higher highs and higher lows indicates an uptrend.

The requirement here is than you need OHLC data for the assets you would like to analyse.

## License

[MIT](LICENSE) © [Krystian Safjan](https://safjan.com/).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "trend-classifier",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<=3.13,>=3.9",
    "maintainer_email": null,
    "keywords": "trend, timeseries, classification, segmentation, analysis, algotrading, finance",
    "author": null,
    "author_email": "Krystian Safjan <ksafjan@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5e/f8/cbe3682c1b02daa8f6f62f11780ce2b63938610b3d3f7ed45b238f6d9545/trend-classifier-0.1.10.tar.gz",
    "platform": null,
    "description": "# Trend classifier\n![](https://img.shields.io/pypi/v/trend-classifier.svg)\n![](https://img.shields.io/pypi/pyversions/trend-classifier.svg)\n![](https://img.shields.io/pypi/l/trend-classifier.svg)\n![](https://img.shields.io/pypi/dm/trend-classifier.svg)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/izikeros/trend_classifier/main.svg)](https://results.pre-commit.ci/latest/github/izikeros/trend_classifier/main)\n[![Black formatter](https://github.com/izikeros/trend_classifier/actions/workflows/black.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/black.yml)\n[![flake8](https://github.com/izikeros/trend_classifier/actions/workflows/flake8.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/flake8.yml)\n[![pytest](https://github.com/izikeros/trend_classifier/actions/workflows/pytest.yml/badge.svg)](https://github.com/izikeros/trend_classifier/actions/workflows/pytest.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/081a20bb8a5201cd8faf/maintainability)](https://codeclimate.com/github/izikeros/trend_classifier/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/081a20bb8a5201cd8faf/test_coverage)](https://codeclimate.com/github/izikeros/trend_classifier/test_coverage)\n\nLibrary for automated signal segmentation, trend classification and analysis.\n\n## Installation\n\n1. The package is pip-installable. To install it, run:\n\n   ```sh\n   pip3 install trend-classifier\n   ```\n\n## Usage\n### Pandas DataFrame Input\nusage:\n```python\nimport yfinance as yf\nfrom trend_classifier import Segmenter\n\n# download data from yahoo finance\ndf = yf.download(\"AAPL\", start=\"2018-09-15\", end=\"2022-09-05\", interval=\"1d\", progress=False)\n\nx_in = list(range(0, len(df.index.tolist()), 1))\ny_in = df[\"Adj Close\"].tolist()\n\nseg = Segmenter(x_in, y_in, n=20)\nseg.calculate_segments()\n```\n\nFor graphical output use `Segmenter.plot_segments()`:\n```python\nseg.plot_segments()\n```\n\n![Segmentation example](https://github.com/izikeros/trend_classifier/blob/main/img/screenshoot_1.jpg?raw=true)\n\nAfter calling method `Segmenter.calculate_segments()` segments are identified and information is stored in `Segmenter.segments` as list of Segment objects. Each Segment object. Each Segment object has attributes such as 'start', 'stop' - range of indices for the extracted segment, slope and many more attributes that might be helpful for further analysis.\n\nExemplary info on one segment:\n```python\nfrom devtools import debug\ndebug(seg.segments[3])\n```\nand you should see something like this:\n```\n    seg.segments[3]: Segment(\n        start=154,\n        stop=177,\n        slope=-0.37934038908585044,\n        offset=109.54630934894907,\n        slopes=[\n            -0.45173184100846725,\n            -0.22564684358754555,\n            0.15555037018051593,\n            0.34801127785130714,\n        ],\n        offsets=[\n            121.65628807526804,\n            83.56079272220015,\n            17.32660986821478,\n            -17.86417581658647,\n        ],\n        slopes_std=0.31334199799377654,\n        offsets_std=54.60900279722876,\n        std=0.933497081795997,\n        span=82.0,\n        reason_for_new_segment='offset',\n    )\n```\nexport results to tabular format (pandas DataFrame):\n```python\nseg.segments.to_dataframe()\n```\n![](https://github.com/izikeros/trend_classifier/blob/main/img/to_dataframe.jpg?raw=true)\n\n(**NOTE:** for clarity reasons, not all columns are shown in the screenshot above)\n\n## Alternative approach\n- Smooth out the price data using the Savitzky-Golay filter,\n- label the highs and lows.\n- higher highs and higher lows indicates an uptrend.\n\nThe requirement here is than you need OHLC data for the assets you would like to analyse.\n\n## License\n\n[MIT](LICENSE) \u00a9 [Krystian Safjan](https://safjan.com/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Package for automated signal segmentation, trend classification and analysis.",
    "version": "0.1.10",
    "project_urls": {
        "Bug Tracker": "https://github.com/izikeros/trend_classifier/issues",
        "Source": "https://github.com/izikeros/trend_classifier"
    },
    "split_keywords": [
        "trend",
        " timeseries",
        " classification",
        " segmentation",
        " analysis",
        " algotrading",
        " finance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "edffe7f2af95e80bd789679b236653a51c33dc7f30aa626f5d43aecdbe19b9ea",
                "md5": "53d38b07f60eef0b9511be015336a287",
                "sha256": "abf413602e7731f51ed3388f56d5780c17b89a73e124b1c00785584bc0605b41"
            },
            "downloads": -1,
            "filename": "trend_classifier-0.1.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "53d38b07f60eef0b9511be015336a287",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<=3.13,>=3.9",
            "size": 3977,
            "upload_time": "2024-03-21T10:39:20",
            "upload_time_iso_8601": "2024-03-21T10:39:20.516953Z",
            "url": "https://files.pythonhosted.org/packages/ed/ff/e7f2af95e80bd789679b236653a51c33dc7f30aa626f5d43aecdbe19b9ea/trend_classifier-0.1.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ef8cbe3682c1b02daa8f6f62f11780ce2b63938610b3d3f7ed45b238f6d9545",
                "md5": "9cf77f8216d6eca42ac3ae0367ad80ac",
                "sha256": "27aff31d9711faccbe69b3815a0cd0898e8aa93594b66fa3279206bf9846fe67"
            },
            "downloads": -1,
            "filename": "trend-classifier-0.1.10.tar.gz",
            "has_sig": false,
            "md5_digest": "9cf77f8216d6eca42ac3ae0367ad80ac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<=3.13,>=3.9",
            "size": 5515,
            "upload_time": "2024-03-21T10:39:21",
            "upload_time_iso_8601": "2024-03-21T10:39:21.775487Z",
            "url": "https://files.pythonhosted.org/packages/5e/f8/cbe3682c1b02daa8f6f62f11780ce2b63938610b3d3f7ed45b238f6d9545/trend-classifier-0.1.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-21 10:39:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "izikeros",
    "github_project": "trend_classifier",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "trend-classifier"
}
        
Elapsed time: 0.23912s