Skip to main content

plotly_candlestick/
plotly_candlestick.rs

1use plotlars::{Axis, CandlestickPlot, CsvReader, Direction, Plot, Rgb};
2
3fn main() {
4    let stock_data = CsvReader::new("data/stock_prices.csv").finish().unwrap();
5
6    let increasing = Direction::new()
7        .line_color(Rgb(0, 200, 100))
8        .line_width(0.5);
9
10    let decreasing = Direction::new()
11        .line_color(Rgb(200, 50, 50))
12        .line_width(0.5);
13
14    CandlestickPlot::builder()
15        .data(&stock_data)
16        .dates("date")
17        .open("open")
18        .high("high")
19        .low("low")
20        .close("close")
21        .increasing(&increasing)
22        .decreasing(&decreasing)
23        .whisker_width(0.1)
24        .plot_title("Candlestick")
25        .y_title("price ($)")
26        .y_axis(&Axis::new().show_axis(true).show_grid(true))
27        .build()
28        .plot();
29}