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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: trend_lines_generator-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 8f394fe47d5427d2dc8524e21602bf07f64460c45e9e4f95c52a75fb0460ae92
MD5 93fc02e472a2d7a7b42054ea9a9352e3
BLAKE2b-256 4d2f6941e52853517f788c9a880259261bf947c7be0cd36f8601c45296ddeca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trend_lines_generator-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 529d0fe449e0173cc90a538e0375db4b331c585afd455acc112436ceede94734
MD5 5aa14dca5c4ed8a216f5af0e09d377a5
BLAKE2b-256 53cd1b06653a7d0d0a8e2cf63754ff19afd4be63125595bfa804d09e9af4c9dc

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