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()
For each time in the serie:
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
Close
Hashes for trend_lines_generator-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332a7b9df2ffdbab1dc1057657e1400201896aa316f2653ec6184431508ce7e6 |
|
MD5 | e72b9e9b3b7fecd855d51fd7983711b6 |
|
BLAKE2b-256 | d0aa715a63fb14bbe3755a6b03750768ddf0aab046a203faf4e5bbed8bc419b1 |
Close
Hashes for trend_lines_generator-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d108a0a30b1a154528ab7dd71cb9b873458d63a8833370e78c441ea44bca5ad0 |
|
MD5 | db283c43a93192dcd7358dfe8c626759 |
|
BLAKE2b-256 | c158ffc6bf9bf9c85bdac414ed3e4a4b549a92d1383b231ce9c0dda1b88972ad |