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.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: trend_lines_generator-1.0.2.tar.gz
  • Upload date:
  • Size: 6.9 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.2.tar.gz
Algorithm Hash digest
SHA256 1646739c918aad758a1c8e447f8a7c1d37509a771135d60e3bb65a7929e7ec78
MD5 1b8f4c5e53701bcdee09fca0aa260bea
BLAKE2b-256 0723378d2d0c9e1575f82561f7b429988d756a336169099960c4c7b3d8d236eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trend_lines_generator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4596003e7f1121ebe27d19ca5cb23ede1e4758f2cd03f9a454d72ebaa93f548d
MD5 efa99b454a4683f2bd2c205ccfafdfa7
BLAKE2b-256 42d099fc79ac4d5e6b0a47b484646369e28236b26baf0667fc66f0313e39376a

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