From 84bc78d16d7baa063803c78c4ea97b6457b47641 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Fri, 29 Dec 2023 05:38:45 -0800 Subject: [PATCH] Add candlestick chart type --- candlestick_chart.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 candlestick_chart.py diff --git a/candlestick_chart.py b/candlestick_chart.py new file mode 100644 index 0000000..b239fc3 --- /dev/null +++ b/candlestick_chart.py @@ -0,0 +1,23 @@ +from chart import Chart +from pandas import Series +from plotly.graph_objects import Candlestick + +class CandlestickChart(Chart): + + def __init__(self, x: Series, opens: Series, highs: Series, lows: Series, closes: Series): + self.x = x + self.opens = opens + self.highs = highs + self.lows = lows + self.closes = closes + + def trace(self) -> Candlestick: + return Candlestick( + x = self.x, + open = self.opens, + high = self.highs, + low = self.lows, + close = self.closes, # TODO: Make colors configurable. + increasing = dict(line = dict(color = 'limegreen', width = 1), fillcolor = 'limegreen'), + decreasing = dict(line = dict(color = 'red', width = 1), fillcolor = 'red') + ) \ No newline at end of file