trend-lines-generator


Nametrend-lines-generator JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/nanvel/trend-lines-generator
SummaryTrend lines generator.
upload_time2024-06-23 09:30:36
maintainerNone
docs_urlNone
authorOleksandr Polieno
requires_python<4.0,>=3.10
licenseMIT
keywords trendlines trend lines trend ta resistance support technical indicators financial
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Trend lines generator

Usage example:
```python
#! pip install trend-lines-generator
import requests
import mplfinance as mpf
from pandas import DataFrame, to_datetime

from trend_lines import generate_trend_lines, Side


def main():
    columns = [
        ("ts", "int"),
        ("volume_quote", "float64"),
        ("open", "float64"),
        ("high", "float64"),
        ("low", "float64"),
        ("close", "float64"),
    ]
    url = "https://api.gateio.ws/api/v4/spot/candlesticks?currency_pair=MOVR_USDT&interval=1h&limit=100"
    response = requests.get(url)

    rows = response.json()

    df = (
        DataFrame([r[: len(columns)] for r in rows], columns=[i[0] for i in columns])
        .astype(dict(columns))
        .set_index("ts")
    )
    df.index = to_datetime(df.index, unit="s")

    lines = generate_trend_lines(low_series=df["low"], high_series=df["high"])

    x1 = df.index[0]
    x2 = df.index[-1]

    mpf.plot(
        df,
        type="candle",
        tight_layout=True,
        alines={
            "alines": [((x1, line.get_y(x1)), (x2, line.get_y(x2))) for line in lines],
            "colors": ["g" if line.side == Side.LOW else "r" for line in lines],
        },
    )


if __name__ == "__main__":
    main()
```

![trend lines](https://github.com/nanvel/trend-lines/raw/master/docs/trend_lines.png)

For each time in the serie:

![trend lines daily](https://github.com/nanvel/trend-lines/raw/master/docs/trend_lines_daily.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nanvel/trend-lines-generator",
    "name": "trend-lines-generator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "trendlines, trend lines, trend, ta, resistance, support, technical, indicators, financial",
    "author": "Oleksandr Polieno",
    "author_email": "polyenoom@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4d/2f/6941e52853517f788c9a880259261bf947c7be0cd36f8601c45296ddeca0/trend_lines_generator-1.0.3.tar.gz",
    "platform": null,
    "description": "# Trend lines generator\n\nUsage example:\n```python\n#! pip install trend-lines-generator\nimport requests\nimport mplfinance as mpf\nfrom pandas import DataFrame, to_datetime\n\nfrom trend_lines import generate_trend_lines, Side\n\n\ndef main():\n    columns = [\n        (\"ts\", \"int\"),\n        (\"volume_quote\", \"float64\"),\n        (\"open\", \"float64\"),\n        (\"high\", \"float64\"),\n        (\"low\", \"float64\"),\n        (\"close\", \"float64\"),\n    ]\n    url = \"https://api.gateio.ws/api/v4/spot/candlesticks?currency_pair=MOVR_USDT&interval=1h&limit=100\"\n    response = requests.get(url)\n\n    rows = response.json()\n\n    df = (\n        DataFrame([r[: len(columns)] for r in rows], columns=[i[0] for i in columns])\n        .astype(dict(columns))\n        .set_index(\"ts\")\n    )\n    df.index = to_datetime(df.index, unit=\"s\")\n\n    lines = generate_trend_lines(low_series=df[\"low\"], high_series=df[\"high\"])\n\n    x1 = df.index[0]\n    x2 = df.index[-1]\n\n    mpf.plot(\n        df,\n        type=\"candle\",\n        tight_layout=True,\n        alines={\n            \"alines\": [((x1, line.get_y(x1)), (x2, line.get_y(x2))) for line in lines],\n            \"colors\": [\"g\" if line.side == Side.LOW else \"r\" for line in lines],\n        },\n    )\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n![trend lines](https://github.com/nanvel/trend-lines/raw/master/docs/trend_lines.png)\n\nFor each time in the serie:\n\n![trend lines daily](https://github.com/nanvel/trend-lines/raw/master/docs/trend_lines_daily.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Trend lines generator.",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/nanvel/trend-lines-generator",
        "Repository": "https://github.com/nanvel/trend-lines-generator"
    },
    "split_keywords": [
        "trendlines",
        " trend lines",
        " trend",
        " ta",
        " resistance",
        " support",
        " technical",
        " indicators",
        " financial"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53cd1b06653a7d0d0a8e2cf63754ff19afd4be63125595bfa804d09e9af4c9dc",
                "md5": "5aa14dca5c4ed8a216f5af0e09d377a5",
                "sha256": "529d0fe449e0173cc90a538e0375db4b331c585afd455acc112436ceede94734"
            },
            "downloads": -1,
            "filename": "trend_lines_generator-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5aa14dca5c4ed8a216f5af0e09d377a5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 8588,
            "upload_time": "2024-06-23T09:30:34",
            "upload_time_iso_8601": "2024-06-23T09:30:34.956926Z",
            "url": "https://files.pythonhosted.org/packages/53/cd/1b06653a7d0d0a8e2cf63754ff19afd4be63125595bfa804d09e9af4c9dc/trend_lines_generator-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d2f6941e52853517f788c9a880259261bf947c7be0cd36f8601c45296ddeca0",
                "md5": "93fc02e472a2d7a7b42054ea9a9352e3",
                "sha256": "8f394fe47d5427d2dc8524e21602bf07f64460c45e9e4f95c52a75fb0460ae92"
            },
            "downloads": -1,
            "filename": "trend_lines_generator-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "93fc02e472a2d7a7b42054ea9a9352e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 6863,
            "upload_time": "2024-06-23T09:30:36",
            "upload_time_iso_8601": "2024-06-23T09:30:36.787902Z",
            "url": "https://files.pythonhosted.org/packages/4d/2f/6941e52853517f788c9a880259261bf947c7be0cd36f8601c45296ddeca0/trend_lines_generator-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-23 09:30:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nanvel",
    "github_project": "trend-lines-generator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "trend-lines-generator"
}
        
Elapsed time: 0.41800s