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