2024-01-05 14:21:28 +00:00
|
|
|
from database.ohlc import ohlc
|
|
|
|
from datetime import datetime, timedelta
|
2024-01-30 19:16:06 +00:00
|
|
|
from plotting import CandlestickChart, figure_with_subplots, Line, LineChart
|
2024-01-05 14:21:28 +00:00
|
|
|
|
|
|
|
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})
|