Package: candlestick-chart
Python Candlesticks Chart📈 Draw candlesticks charts right into your terminal, using Python!This is a portage from the greatcli-candlestick-chart(developed byJulien-R44, written in Rust).
You are looking at the Python 3.10+ version.Note: not tested on macOS, nor Windows (it will likely fail to render colors).Table of contents:Python Candlesticks ChartFeaturesIntallationDemonstrationBinary UsageExamplesAPIBinaryRead CSV from fileRead JSON from fileRead from stdinFeaturesAuto-fit to terminal sizePractical formatting for big, and tiny, numbersIntegration withRichSimple, yet customizable, APIExact same API as theRust version, plus somesugarSimple installation, no external dependenciesIntallationAs simple as:$python-mpipinstall-Ucandlestick-chartDemonstrationfromcandlestick_chartimportCandle,Chart# Add some candlescandles=[Candle(133.520004,133.610001,126.760002,129.410004),Candle(128.889999,131.740005,128.429993,131.009995),Candle(127.720001,131.050003,126.379997,126.599998),Candle(128.360001,131.630005,127.860001,130.919998),Candle(132.429993,132.630005,130.229996,132.050003),]# Create and display the chart# Optional keyword arguments: title, width, heightchart=Chart(candles,title="Optional title")# Set the chart titlechart.set_name("BTC/USDT")# Set customs colorschart.set_bear_color(1,205,254)chart.set_bull_color(255,107,153)chart.set_vol_bull_color(1,205,254)chart.set_vol_bear_color(255,107,153)# Set custom labels (empty string => label not displayed)chart.set_label("highest","ATH")chart.set_label("lowest","ATL")chart.set_label("average","")chart.set_label("volume","")# Volume pane settingschart.set_volume_pane_height(6)chart.set_volume_pane_enabled(False)# And, it is also responsive!new_width=200new_height=150chart.update_size(new_width,new_height)# By the way, did you know that you can add more candles in real-time?chart.update_candles(candles[:3])# Or completely replace current candleschart.update_candles(candles[:3],reset=True)# Set a custom color at price 52,348.63# from candlestick_chart.utils import fnumchart.set_highlight(fnum(52,348.63),"red")chart.set_highlight(fnum(52,348.63),(255,0,0))chart.set_highlight(fnum(52,348.63),"91m")chart.set_highlight(fnum(52,348.63),"91;47m")chart.draw()Binary UsageWhen installing the library, an executable is made available (candlestick-chart):$candlestick-chart--helpoptions:-h,--helpshowthishelpmessageandexit-m{stdin,csv-file,json-file},--mode{stdin,csv-file,json-file}Selectthemethodforretrievingthecandles.-fFILE,--fileFILE[MODE:*-file]Filetoreadcandlesfrom.--chart-nameCHART_NAMESetsthechartname.--bear-colorBEAR_COLORSetsthedescendingcandlescolorinhexadecimal.--bull-colorBULL_COLORSetstheascendingcandlescolorinhexadecimal.--versionshowprogram'sversionnumberandexitWhen requesting the JSON or stdin mode, the library expects a JSON with the following format:[{"open":28994.009766,"high":29600.626953,"low":28803.585938,"close":29374.152344},...]For all requests, here are supported fields:"open":float# mandatory"close":float# mandatory"high":float# mandatory"low":float# mandatory"volume":float"timestamp":floatExamplesAPIBasic example with CSV parsing: run with$ python examples/basic-from-csv-file.pyBasic example with JSON parsing: run with$ python examples/basic-from-json-file.pyBasic example with stdin parsing: run with$ ./examples/basic-from-stdin.shFetch candles from Binance: run with$ python examples/fetch-from-binance.pyIntegration with Rich: run with$ python examples/integrate-with-rich.pyUsing a custom chart renderer class: run with$ python examples/custom-renderer-class.pyBinaryRead CSV from file$candlestick-chart\--mode=csv-file\--file='./examples/BTC-USD.csv'\--chart-name='My BTC Chart'\--bear-color='#b967ff'\--bull-color='ff6b99'Read JSON from file$candlestick-chart\--mode=json-file\--file='./examples/BTC-chart.json'\--chart-name='My BTC Chart'\--bear-color='#b967ff'\--bull-color='ff6b99'Read from stdinecho'[{"open": 28994.009766,"high": 29600.626953,"low": 28803.585938,"close": 29374.152344},{"open": 29376.455078,"high": 33155.117188,"low": 29091.181641,"close": 32127.267578}]'|candlestick-chart\--mode=stdin\--chart-name='My BTC Chart'\--bear-color='#b967ff'\--bull-color='ff6b99'