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()
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
Built Distribution
File details
Details for the file trend_lines_generator-0.1.1.tar.gz
.
File metadata
- Download URL: trend_lines_generator-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fdb00102a22372059b52584b179485ea6d2171f628e71abdc8b0181f47b87c8 |
|
MD5 | a7200bf5043e6d9e98f366f6970755ce |
|
BLAKE2b-256 | 2be43dbeac666a21e15825cee9197969f4829f74b78fa7d15fe023e44d89fdd1 |
File details
Details for the file trend_lines_generator-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: trend_lines_generator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.10.8 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0817859689dffa3ed32d31ed5d6e5b43796ff8eab082c8ccb7aca73c0008eb9 |
|
MD5 | 7755f501e1379b12d8ca849fb5a28cd8 |
|
BLAKE2b-256 | 9be7f227573ab6c5882b820e12c4f645b1b150304eb1d0a41e169b4436a7d86b |