Display candlestick chart in your terminal.

Overview

cli-candlestick-chart

CI Latest version

This module allows you to display candle charts directly in your terminal.

I did this project mainly to learn Rust, so the code is may be not very good at some places.

Usage

Add this to your Cargo.toml

[dependencies]
cli-candlestick-chart = "0.1"
use cli_candlestick_chart::{Candle, Chart};

fn main() {
    // Add some candles
    let candles: Vec<Candle> = vec![
        Candle::new(133.520004, 133.610001, 126.760002, 129.410004),
        Candle::new(128.889999, 131.740005, 128.429993, 131.009995),
        Candle::new(127.720001, 131.050003, 126.379997, 126.599998),
        Candle::new(128.360001, 131.630005, 127.860001, 130.919998),
        Candle::new(132.429993, 132.630005, 130.229996, 132.050003),
        Candle::new(129.190002, 130.169998, 128.500000, 128.979996),
        Candle::new(128.500000, 129.690002, 126.860001, 128.800003),
        Candle::new(128.759995, 131.449997, 128.490005, 130.889999),
        Candle::new(130.800003, 131.000000, 128.759995, 128.910004),
        Candle::new(128.779999, 130.220001, 127.000000, 127.139999),
        Candle::new(127.779999, 128.710007, 126.940002, 127.830002),
        Candle::new(128.660004, 132.490005, 128.550003, 132.029999),
        Candle::new(133.800003, 139.669998, 133.589996, 136.869995),
        Candle::new(136.279999, 139.850006, 135.020004, 139.070007),
        Candle::new(143.070007, 145.089996, 136.539993, 142.919998),
        Candle::new(143.600006, 144.300003, 141.369995, 143.160004),
        Candle::new(143.429993, 144.300003, 140.410004, 142.059998),
        Candle::new(139.520004, 141.990005, 136.699997, 137.089996),
        Candle::new(135.830002, 136.740005, 130.210007, 131.960007),
        Candle::new(133.750000, 135.380005, 130.929993, 134.139999),
    ];

    // Create and display the chart
    let mut chart = Chart::new(candles);

    // Set the chart title
    chart.set_name(String::from("BTC/USDT"));

    // Set customs colors
    chart.set_bear_color(1, 205, 254);
    chart.set_bull_color(255, 107, 153);

    chart.draw();
}
Comments
  • Python version

    Python version

    Hello Julien,

    This is an amazing library, thanks a lot for your work! :heart_on_fire:

    I was looking for an similar solution on Python, and found nothing I was really interested in. So here it is, I created a Python version of your project: https://github.com/BoboTiG/py-candlestick-chart

    I hope it is OK on your side, it will be kept open-source, nothing fancy more. I plan to ease integration with Textual/Rich, which are other cool terminal libraries on Python.

    Let me know if you find any issue with my move, otherwise I'll delete my repository ;)

    Cheers,

    Mickaël

    question 
    opened by BoboTiG 1
  • Project compatibility

    Project compatibility

    Hi So your project idea is quite great actually to have chart draw in terminal. Perhaps, if you can also add an appimage version, that could be very nice to run on all linux. thanks

    opened by docop 1
  • Some tickers inaccessible

    Some tickers inaccessible

    Some valid tickers lead to panic when fetching from Yahoo Finance, even though they are valid. Observed that on exchanges outside the US. Examples are PETR4.SA and GGBR4.SA.

    Maybe Alpha Vantage would be able to deal with those better? I know Yahoo has a history of making things difficult for this kind of use.

    Sometimes other tickers (such as ETH-USD) also break, but that appears to be random or based on time of request.

    opened by lmlask 1
  • Fix imports and publicness of types

    Fix imports and publicness of types

    Generally it is bad practice to have public fields that contain private types. You should also import types directly. Also the CandleType type was not public.

    opened by zethra 1
  • Serde as a feature flag

    Serde as a feature flag

    If you make main an example like I suggested in #1, you can also make serde an optional dependency that can be turned on with a feature flag. this further reduces the number of dependencies.

    opened by zethra 0
  • Make main an example/Remove extra dependacies

    Make main an example/Remove extra dependacies

    main.rs should probably be an example the the examples folder. Also, it looks like the csv library is only used in that example, and can therefore be moved to dev-dependacies,reducing the number of depencies.

    opened by zethra 0
  • example: tui-rs integration

    example: tui-rs integration

    Thanks you for this wonderful crate!

    I'm trying to use it in tui-rs, another wonderful crate. And I did some (mininal) changes:

    • render the chart into string, without println!.
    • explicit width and height, making terminal_size optional.
    • some cleanups (clippy, smaller output)
    • add an example how to use it with tui-rs.

    I just hope it help, and it's totally fine if you close PR.

    opened by flisky 0
  • Feature Request: Add additional lines for custom indicators

    Feature Request: Add additional lines for custom indicators

    Hi,

    Thanks for the amazing work. Is there any plan to support additional lines to the chart for custom indicators? That would open doors to various kinds of technical analysis visualization.

    For example, horizon/vertical lines, or arbitrary time-series data such as Moving Average. I imagine the data can be embedded in the JSON data stream along with the current OHLC fields.

    enhancement 
    opened by NLKNguyen 2
Releases(0.4.1)
Owner
Julien
Julien
Rust code for T-Display S3 AMOLED, ESP32-S3 board with RM67162 AMOLED display

T-Display S3 AMOLED What is it? This is a Rust BSP for the Lilygo's T-Display S3 AMOLED board. RM67162 AMOLED driver in QSPI mode RM67162 AMOLED drive

BH1XUW 4 Jun 28, 2023
Display a random Shiba from your terminal whenever you feel the need to. Because why not?

Shiba CLI Command-line interface (CLI) to display a random Shiba Inu whenever needed, by just running shiba on your terminal. How To Use • How Does It

null 17 Sep 25, 2022
Display financial Data on The Terminal

tuinance Tuinance is a performant TUI program to display financial data, written completely in Rust. All data is gathered through the Yahoo Finance AP

Juho 10 May 31, 2022
Rust crate that allows you to display status & progress information in a terminal

status-line This crate allows you to display status & progress information in a terminal This crate handles the problem of displaying a small amount o

Piotr Kołaczkowski 20 Dec 27, 2022
A terminal clock that uses 7-segment display characters

Seven-segment clock (7clock) 7clock.3.mp4 This is a clock for terminals that uses the Unicode seven-segment display characters added in Unicode 13.0.

Wesley Moore 4 Nov 11, 2022
on-screen keyboard display for your coding streams.

⌨ OSKD (On-screen key display) OSKD is an on-screen keyboard display that can be used during streams. It provides an intuitive and easy-to-use interfa

Sammwy 46 May 6, 2023
A monitor (service) for your monitor (display). Intercepts window behaviour when monitor configuration changes.

Mon-Mon A monitor (service) for your monitor (display). Listens for changes to display configuration (e.g. plugging in an additional screen) and allow

dan 5 Sep 29, 2023
Display near-real-time satellite imagery on your desktop.

Satpaper Display near-real-time satellite imagery on your desktop. (Click to see full-size version) Satpaper generates live wallpapers for your deskto

null 148 Oct 10, 2023
ask.sh: AI terminal assistant that can read and write your terminal directly!

ask.sh: AI terminal assistant that read from & write to your terminal ask.sh is an AI terminal assistant based on OpenAI APIs such as GPT-3.5/4! What'

hmirin 5 Jun 20, 2023
Print your git contributions in your terminal, blazingly fast

Takoyaki Blazingly fast git contribution graph in your terminal Features ✔️ Customizable ✔️ Plugins to support a bunch of cloud based git repositories

kyeboard 13 Feb 6, 2023
Get your github contributions right in your terminal, blazingly fast!

GitColorScripts Get your github contributions right in your terminal! Installation Install via yay yay -S gitcolorscripts Install manually Download t

VoidCupboard 56 Jul 12, 2023
CLI app to display list of trending anime, music charts or recommend anime to watch or song to listen to.

Description Anitrendz is a cli app that uses data from the anitiop api to list the top anime and songs or recommend a random anime to watch or song to

Jimmy 9 Jun 11, 2022
Display ZFS datasets' I/O in real time

ztop Display ZFS datasets' I/O in real time Overview ztop is like top, but for ZFS datasets. It displays the real-time activity for datasets. The buil

Alan Somers 40 Nov 23, 2022
Rust command line utility to quickly display useful secrets in a Kubernetes namespace

kube-secrets This is a command line utility for quickly looking at secrets in a Kubernetes namespace that are typically looked at by humans. It specif

Frank Wiles 8 Feb 10, 2022
Lemurs - A lightweight TUI display/login manager written in Rust 🐒

Lemurs ?? A TUI Display/Login Manager written in Rust WIP: Whilst the project is working and installable, there are still a lot of bugs and limitation

Gijs Burghoorn 136 Jan 1, 2023
🌈🙈 HDR -> display

?? ?? notorious6 Experiments in mapping HDR stimulus to display via shaders and stuff. Building and running Should work on Windows and Linux ( ?? not

Tomasz Stachowiak 23 Dec 7, 2022
A simple program that provides DBus interface to control display temperature and brightness under wayland without flickering

wl-gammarelay-rs Like wl-gammarelay, but written in rust, runs on a single thread, has three times less SLOC and uses DBus (for simplicity). Dbus inte

Max Verevkin 33 Nov 23, 2022
Command line linguistic tools: display pronunciation, convert between regional norms of orthography

Command line linguistic tools: display pronunciation, convert between regional norms of orthography; support for multiple modern and ancient languages: English, Latin, Polish, Quechua, Tikuna

Piotr Bajdek 7 Nov 28, 2022
Can we display bevy_ui code with bevy_ui?

bevy_prototype_syntax_highlighting Can we render bevy_ui code with bevy_ui? Yes we can! License The source code of this repository is dual-licensed un

null 4 Aug 31, 2022