{"id":13815163,"url":"https://github.com/BoboTiG/py-candlestick-chart","last_synced_at":"2025-05-15T07:32:02.222Z","repository":{"id":45645747,"uuid":"494400530","full_name":"BoboTiG/py-candlestick-chart","owner":"BoboTiG","description":"Draw candlesticks charts right into your terminal, using Python!","archived":false,"fork":false,"pushed_at":"2025-05-12T17:46:26.000Z","size":250,"stargazers_count":92,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T18:46:13.593Z","etag":null,"topics":["candle","candlestick-chart","chart","cli","console","options","python","python310","python311","python312","stock","stock-market","terminal","trading"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/candlestick-chart","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BoboTiG.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["BoboTiG"]}},"created_at":"2022-05-20T09:24:28.000Z","updated_at":"2025-05-12T17:46:29.000Z","dependencies_parsed_at":"2025-03-21T18:24:01.553Z","dependency_job_id":"8e535533-577a-4b6d-8a29-9a091ebd218e","html_url":"https://github.com/BoboTiG/py-candlestick-chart","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoboTiG%2Fpy-candlestick-chart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoboTiG%2Fpy-candlestick-chart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoboTiG%2Fpy-candlestick-chart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoboTiG%2Fpy-candlestick-chart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BoboTiG","download_url":"https://codeload.github.com/BoboTiG/py-candlestick-chart/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254295960,"owners_count":22047179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["candle","candlestick-chart","chart","cli","console","options","python","python310","python311","python312","stock","stock-market","terminal","trading"],"created_at":"2024-08-04T04:03:03.348Z","updated_at":"2025-05-15T07:32:02.214Z","avatar_url":"https://github.com/BoboTiG.png","language":"Python","funding_links":["https://github.com/sponsors/BoboTiG","https://www.patreon.com/mschoentgen"],"categories":["Python"],"sub_categories":[],"readme":"# Python Candlesticks Chart\n\n\u003e [!TIP]\n\u003e Become **my boss** to help me work on this awesome software, and make the world better:\n\u003e \n\u003e [![Patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge\u0026logo=patreon\u0026logoColor=white)](https://www.patreon.com/mschoentgen)\n\n📈 Draw candlesticks charts right into your terminal, using Python!\n\n![Preview](examples/screenshot.png)\n\nThis is a portage from the great [cli-candlestick-chart](https://github.com/Julien-R44/cli-candlestick-chart) (developed by [Julien-R44](https://github.com/Julien-R44), written in Rust).\nYou are looking at the Python 3.10+ version.\n\nNote: not tested on macOS, nor Windows (it will likely fail to render colors).\n\n**Table of contents**:\n- [Python Candlesticks Chart](#python-candlesticks-chart)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Demonstration](#demonstration)\n- [Binary Usage](#binary-usage)\n- [Examples](#examples)\n  - [API](#api)\n  - [Binary](#binary)\n    - [Read CSV from file](#read-csv-from-file)\n    - [Read JSON from file](#read-json-from-file)\n    - [Read from stdin](#read-from-stdin)\n  - [Developers](#developers)\n\n## Features\n\n- Auto-fit to terminal size\n- Practical formatting for big, and tiny, numbers\n- Integration with [Rich](https://github.com/Textualize/rich)\n- Simple, yet customizable, API\n- Exact same API as the [Rust version](https://github.com/Julien-R44/cli-candlestick-chart), plus some [sugar](#demonstration)\n- Simple installation, no external dependencies\n\n## Installation\n\n```bash\n$ python -m pip install -U candlestick-chart\n```\n\n## Demonstration\n\n```python\nfrom candlestick_chart import Candle, Chart\n\n\n# Add some candles\ncandles = [\n    Candle(open=133.520004, close=133.610001, high=126.760002, low=129.410004),\n    Candle(open=128.889999, close=131.740005, high=128.429993, low=131.009995),\n    Candle(open=127.720001, close=131.050003, high=126.379997, low=126.599998),\n    Candle(open=128.360001, close=131.630005, high=127.860001, low=130.919998),\n    Candle(open=132.429993, close=132.630005, high=130.229996, low=132.050003),\n]\n\n# Create and display the chart\n# Optional keyword arguments: title, width, height\nchart = Chart(candles, title=\"Optional title\")\n\n# Set the chart title\nchart.set_name(\"BTC/USDT\")\n\n# Set customs colors\nchart.set_bear_color(1, 205, 254)\nchart.set_bull_color(255, 107, 153)\nchart.set_vol_bull_color(1, 205, 254)\nchart.set_vol_bear_color(255, 107, 153)\n\n# Set custom labels (empty string =\u003e label not displayed)\nchart.set_label(\"highest\", \"ATH\")\nchart.set_label(\"lowest\", \"ATL\")\nchart.set_label(\"average\", \"\")\nchart.set_label(\"volume\", \"\")\n\n# Volume pane settings\nchart.set_volume_pane_height(6)\nchart.set_volume_pane_enabled(False)\n\n# And, it is also responsive!\nnew_width = 200\nnew_height = 150\nchart.update_size(new_width, new_height)\n\n# By the way, did you know that you can add more candles in real-time?\nchart.update_candles(candles[:3])\n# Or completely replace current candles\nchart.update_candles(candles[:3], reset=True)\n\n# Set a custom color at price 52,348.63\nchart.set_highlight(fnum(52_348.63), \"red\")\nchart.set_highlight(fnum(52_348.63), (255, 0, 0))\nchart.set_highlight(fnum(52_348.63), \"91m\")\nchart.set_highlight(fnum(52_348.63), \"91;47m\")\n\nchart.draw()\n```\n\n# Binary Usage\n\nWhen installing the library, an executable is made available (`candlestick-chart`):\n\n```bash\ncandlestick-chart --help\n\noptions:\n  -h, --help            show this help message and exit\n  -m {stdin,csv-file,json-file}, --mode {stdin,csv-file,json-file}\n                        Select the method for retrieving the candles.\n  -f FILE, --file FILE  [MODE:*-file] File to read candles from.\n  --chart-name CHART_NAME\n                        Sets the chart name.\n  --bear-color BEAR_COLOR\n                        Sets the descending candles color in hexadecimal.\n  --bull-color BULL_COLOR\n                        Sets the ascending candles color in hexadecimal.\n  --version             show program's version number and exit\n```\n\nWhen requesting the JSON or stdin mode, the library expects a JSON with the following format: \n\n```json\n[\n    {\n        \"open\": 28994.009766,\n        \"high\": 29600.626953,\n        \"low\": 28803.585938,\n        \"close\": 29374.152344\n    },\n    ...\n]\n```\n\nFor all requests, here are supported fields:\n\n```python\n\"open\": float  # mandatory\n\"close\": float  # mandatory\n\"high\": float  # mandatory\n\"low\": float  # mandatory\n\"volume\": float\n\"timestamp\": float\n```\n\n# Examples\n\n## API \n\n- [Basic example with CSV parsing](examples/basic_from_csv_file.py): run with `$ python examples/basic_from_csv_file.py`\n- [Basic example with JSON parsing](examples/basic_from_json_file.py): run with `$ python examples/basic_from_json_file.py`\n- [Basic example with stdin parsing](examples/basic_from_stdin.sh): run with `$ ./examples/basic_from_stdin.sh`\n- [Fetch candles from Binance](examples/fetch_from_binance.py): run with `$ python examples/fetch_from_binance.py`\n- [Integration with Rich](examples/integrate_with_rich.py): run with `$ python examples/integrate_with_rich.py`\n- [Using a custom chart renderer class](examples/custom_renderer_class.py): run with `$ python examples/custom_renderer_class.py`\n\n## Binary \n\n### Read CSV from file\n\n```bash\ncandlestick-chart \\\n    --mode=csv-file \\\n    --file='./examples/BTC-USD.csv' \\\n    --chart-name='My BTC Chart' \\\n    --bear-color='#b967ff' \\\n    --bull-color='ff6b99'\n```\n### Read JSON from file\n\n```bash\ncandlestick-chart \\\n    --mode=json-file \\\n    --file='./examples/BTC-chart.json' \\\n    --chart-name='My BTC Chart' \\\n    --bear-color='#b967ff' \\\n    --bull-color='ff6b99'\n```\n\n### Read from stdin\n\n```bash\necho '[\n  {\n    \"open\": 28994.009766,\n    \"high\": 29600.626953,\n    \"low\": 28803.585938,\n    \"close\": 29374.152344\n  },\n  {\n    \"open\": 29376.455078,\n    \"high\": 33155.117188,\n    \"low\": 29091.181641,\n    \"close\": 32127.267578\n  }\n]' | candlestick-chart \\\n    --mode=stdin \\\n    --chart-name='My BTC Chart' \\\n    --bear-color='#b967ff' \\\n    --bull-color='ff6b99'\n```\n\n## Developers\n\nSetup:\n\n```shell\npython -m venv venv\n. venv/bin/activate\npython -m pip install -U pip\n```\n\nInstall:\n\n```shell\npython -m pip install -e '.[test]'\n```\n\nTest:\n\n```shell\npython -m pytest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoboTiG%2Fpy-candlestick-chart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBoboTiG%2Fpy-candlestick-chart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoboTiG%2Fpy-candlestick-chart/lists"}