From 186e064f03a44d3d19dc7fa09d134c903834d559 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Fri, 5 Jan 2024 06:21:28 -0800 Subject: [PATCH] Add subplot example for reference when using plotly dash --- subplot_example.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 subplot_example.py diff --git a/subplot_example.py b/subplot_example.py new file mode 100644 index 0000000..2bfdb21 --- /dev/null +++ b/subplot_example.py @@ -0,0 +1,29 @@ +from database.ohlc import ohlc +from datetime import datetime, timedelta + +from candlestick_chart import CandlestickChart +from line import Line +from line_chart import LineChart +from plot import figure_with_subplots + +end_date = datetime.today().date() +start_date = (end_date - timedelta(days = 90)) +data = ohlc('SPX.XO', '1d', start_date = start_date, end_date = end_date) + +candlestick_chart = CandlestickChart( + x = data['Timestamp'], + opens = data['Open'], + highs = data['High'], + lows = data['Low'], + closes = data['Close'], + title = 'SPX' +) + +line_chart = LineChart( + x = data['Timestamp'], + lines = [Line(data['Close'], name = 'Close')], + title = 'SPX (Close)' +) + +# For use in plotly dash. +figure_with_subplots([[candlestick_chart], [line_chart]]).show(config = {'displayModeBar': False}) \ No newline at end of file