79281423

Date: 2024-12-14 21:14:11
Score: 2
Natty:
Report link

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)

What I did:

droped unnecesary columns

df = df[['date', 'open', 'high', 'low', 'close']]

drop NAs

df = df.dropna(subset=['date', 'open', 'high', 'low', 'close'])

converted my DataFrame from descending to ascending (don't have to do it if it is already correct)

df = df[::-1]

Convert the date to UNIX time stamp

df['date'] = df['date'].apply(lambda date: int(dt.datetime.strptime(date, "%Y-%m-%d").timestamp() * 1000))

converted to list with format of ints and float

data_list = df.apply(lambda row: [int(row['date']), float(row['open']), float(row['high']), float(row['low']), float(row['close'])], axis=1).tolist()

dump it to JSON

json_string = json.dumps(data_list) 

created Chart using json_string as data using Chart.from_options(

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()

Hope this helps at least some LLM model.

Reasons:
  • Blacklisted phrase (1): did not work
  • Whitelisted phrase (-1): Hope this helps
  • RegEx Blacklisted phrase (2.5): please post
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Qwido