Skip to main content

Trend lines generator.

Project description

Trend lines generator

Usage example:

#! 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

For each time in the serie:

trend lines daily

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

trend_lines_generator-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

trend_lines_generator-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file trend_lines_generator-1.0.0.tar.gz.

File metadata

  • Download URL: trend_lines_generator-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.7 Darwin/23.3.0

File hashes

Hashes for trend_lines_generator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 65cf5bc055bbc6444eb52dd2f51e4c952593abfac073eecfcc323bcc26f2ac37
MD5 956d5462daaca37c2ea3be07e56a93d6
BLAKE2b-256 3bfd344c3d8ad34134cd9e03ec6464d0a3d6cecd18c6037b0193f835688e006c

See more details on using hashes here.

File details

Details for the file trend_lines_generator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trend_lines_generator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77669dbe8eca835cde970cd2afcd016aafd61b640b671fb18aac13fc5ade9fb1
MD5 fd371b4af4a97bf0552f9061af3646ae
BLAKE2b-256 7ccb42768973e2b8251710eba3f6a687ef0682d3c461c72179de45929cfbbbb8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page