24 lines
832 B
Python
24 lines
832 B
Python
from chart import Chart
|
|
from pandas import Series
|
|
from plotly.graph_objects import Candlestick
|
|
from typing import List
|
|
|
|
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 traces(self) -> List[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')
|
|
)] |