bobotig / py-candlestick-chart Goto Github PK
View Code? Open in Web Editor NEWDraw candlesticks charts right into your terminal, using Python!
Home Page: https://pypi.org/project/candlestick-chart
License: MIT License
Draw candlesticks charts right into your terminal, using Python!
Home Page: https://pypi.org/project/candlestick-chart
License: MIT License
Hello! When trying to run the example you post, I get the following error.
TypeError: Candle.init() takes 1 positional argument but 5 were given
Thanks!
WSL debian 11;
pasted demonstration to mychart.py and commented out 5 lines containing "fnum".
Does not recognize current height, width of the terminal.
Does not draw 5 candles but one single vertical red line.
cat /etc/issue;echo $TERM; python3 mychart.py | less -SR
Debian GNU/Linux 11 \n \l
xterm-256color
xterm -fs 11 -fa DejaVuSansMono
cat /etc/issue;echo $TERM; python3 mychart.py
xterm
HI, nice tool ! Thanks for sharing it.
I've noticed a small bug while using the cli:
If I don't provide a chart name, it crashes without providing much info:
> candlestick-chart -m json-file -f candles.json
Traceback (most recent call last):
File "/home/jose/charts/.venv/bin/candlestick-chart", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/jose/charts/.venv/lib/python3.11/site-packages/candlestick_chart/__main__.py", line 59, in main
chart.draw()
File "/home/jose/charts/.venv/lib/python3.11/site-packages/candlestick_chart/chart.py", line 57, in draw
print(self._render())
^^^^^^^^^^^^^^
File "/home/jose/charts/.venv/lib/python3.11/site-packages/candlestick_chart/chart.py", line 53, in _render
return self.renderer.render(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jose/charts/.venv/lib/python3.11/site-packages/candlestick_chart/chart_renderer.py", line 104, in render
output.append(chart.info_bar.render(chart_data.main_candle_set, chart_data.width))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jose/charts/.venv/lib/python3.11/site-packages/candlestick_chart/info_bar.py", line 60, in render
" | ".join(
TypeError: object of type 'NoneType' has no len()
>
It works if a name is provided:
> candlestick-chart -m json-file -f candles.json --chart-name __NAME__
and even with an empty name:
> candlestick-chart -m json-file -f candles.json --chart-name ''
It looks like the default value for the argument should be a string, changing this line seems to fix it
parser.add_argument("--chart-name", help="Sets the chart name.", default="")
I'm using the latest version from PyPI:
> candlestick-chart --version
candlestick-chart 2.6.0
Chart.update_candles()
behavior could be improved by adding an optional keyword argument: reset: bool = False
.
The initial behavior will change:
Chart.update_candles(some_candles)
will add some_candles
to the existing candle set.Chart.update_candles(some_candles, reset=True)
will replace the existing candle set with some_candles
.not work in python 3.8
Hi, Dear @BoboTiG ๐
This is a great project!!! I wonder that does this project support draw EMA lines, like EMA 20...
if NOT, Do you have a plan to support this feature?
thank you very much for your project
Traceback (most recent call last):
# ...
File "candlestick_chart/chart.py", line 36, in __rich_console__
yield Group(*AnsiDecoder().decode(self._render()))
File "candlestick_chart/chart.py", line 40, in _render
return self.renderer.render(self)
File "candlestick_chart/chart_renderer.py", line 82, in render
output.extend(
File "candlestick_chart/chart_renderer.py", line 83, in <genexpr>
self._render_candle(candle, y, chart.y_axis) for candle in candles
File "candlestick_chart/chart_renderer.py", line 39, in _render_candle
high_y, low_y, max_y, min_y = y_axis.price_to_heights(candle)
File "candlestick_chart/y_axis.py", line 27, in price_to_heights
(candle.high - min_value) / diff * height, # high_y
ZeroDivisionError: float division by zero
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ 24 โ โ diff = candle_set.max_price - min_value โ
โ 25 โ โ โ
โ 26 โ โ return ( โ
โ โฑ 27 โ โ โ (candle.high - min_value) / diff * height, # high_y โ
โ 28 โ โ โ (candle.low - min_value) / diff * height, # low_y โ
โ 29 โ โ โ (max_open - min_value) / diff * height, # max_y โ
โ 30 โ โ โ (min_open - min_value) / diff * height, # min_y โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ locals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ candle = <candlestick_chart.candle.Candle object at 0x7fa58053d360> โ โ
โ โ candle_set = CandleSet( โ โ
โ โ โ candles=[<candlestick_chart.candle.Candle object at 0x7fa58053d360>], โ โ
โ โ โ min_price=8.340877714580442e-06, โ โ
โ โ โ max_price=8.340877714580442e-06, โ โ
โ โ โ min_volume=21994.401431846, โ โ
โ โ โ max_volume=21994.401431846, โ โ
โ โ โ variation=0.0, โ โ
โ โ โ average=8.340877714580442e-06, โ โ
โ โ โ last_price=8.340877714580442e-06, โ โ
โ โ โ cumulative_volume=21994.401431846 โ โ
โ โ ) โ โ
โ โ chart_data = <candlestick_chart.chart_data.ChartData object at 0x7fa580ea3470> โ โ
โ โ diff = 0.0 โ โ
โ โ height = 32 โ โ
โ โ max_open = 8.340877714580442e-06 โ โ
โ โ min_open = 8.340877714580442e-06 โ โ
โ โ min_value = 8.340877714580442e-06 โ โ
โ โ self = YAxis( โ โ
โ โ โ chart_data=<candlestick_chart.chart_data.ChartData object at โ โ
โ โ 0x7fa580ea3470> โ โ
โ โ ) โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Rich integration will be tackled soon.
Is it possible to run a continuous streaming candle with python
Copied demonstration code into chart.py and tried to run it:
$ python3 chart.py
Traceback (most recent call last):
File "/home/helgein/projects_python/python312/candlechart/chart.py", line 1, in <module>
from candlestick_chart import Candle, Chart, fnum
ImportError: cannot import name 'fnum' from 'candlestick_chart' (/home/sru/.pyenv/versions/3.12.0/lib/python3.12/site-packages/candlestick_chart/__init__.py
There is a mismatch with the Rust version: when displaying the info bar, our version is computing values using the visible candle set. Actually, it should rather use the main candle set.
Our version (incorrect):
Rust version (correct): https://github.com/Julien-R44/cli-candlestick-chart/blob/9ea785c1a9fe5e2357bfe1411150ad0a7e009135/src/info_bar.rs#L19
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.