This approach suggested by Chris did not work for me. I got: HighchartsValueError: series_type expects a valid Highcharts series type. Received: <class 'highcharts_stock.options.series.candlestick.candlestickseries' So I did some reverse engineering of the code in the official git depository: https://github.com/highcharts-for-python/highcharts-for-python-demos/blob/master/highcharts-stock/hlc-and-ohlc-charts/hlc-chart.ipynb And converted my padas.DataFrame into JSON string representation. (I did not find any case in official documentaion where DataFame was used, if you know any please post it)
df = df[['date', 'open', 'high', 'low', 'close']]
df = df.dropna(subset=['date', 'open', 'high', 'low', 'close'])
df = df[::-1]
df['date'] = df['date'].apply(lambda date: int(dt.datetime.strptime(date, "%Y-%m-%d").timestamp() * 1000))
data_list = df.apply(lambda row: [int(row['date']), float(row['open']), float(row['high']), float(row['low']), float(row['close'])], axis=1).tolist()
json_string = json.dumps(data_list)
as_dicts = {
'range_selector': {
'selected': 2
},
'title': {
'text': 'AAPL Stock Price'
},
'navigator': {
'enabled': True
},
'series': [
{
'type': 'candlestick',
'name': 'AAPL Stock Price',
'data': json_string
}
]
}
chart = Chart.from_options(as_dicts)
chart.display()