freyastreamlit / streamlit-lightweight-charts

Streamlit wrapper for lightweight-charts
MIT License
146 stars 31 forks source link

When dataframehas more rows, getting a blank candlestick chart #33

Closed baluinfo86 closed 1 year ago

baluinfo86 commented 1 year ago

Is there any settings that need to enabled when dataframe has more rows, in order to display the candle stick charts properly?

image

freyastreamlit commented 1 year ago

Not sure I understand the question, there are no known limits... (that's an unique feature of lightweight-charts)

Looking at your empty chart, my guess is that are more than one candle with same datetime/timestamp - on that case lightweight-charts does not show any candles - typical issue that doesn't give any feedback

The best way is to give UNIX timestamp in nano seconds - something like:

df_chart['time'] = df_chart['time'].astype(int) / 10**9  # Convert to UNIX timestamp

so you can build a series like:

seriesCandlestickChart = [{
    "type": 'Candlestick',
    "data": [
        { "open": 10, "high": 10.63, "low": 9.49, "close": 9.55, "time": 1642427876 },
        { "open": 9.55, "high": 10.30, "low": 9.42, "close": 9.94, "time": 1642514276 },
        { "open": 9.94, "high": 10.17, "low": 9.92, "close": 9.78, "time": 1642600676 },
        { "open": 9.78, "high": 10.59, "low": 9.18, "close": 9.51, "time": 1642687076 },
baluinfo86 commented 1 year ago

Thanks a lot for the reply, seems duplicate entries was causing the issue. Able to filter the dataframe for duplicate and able to render the chart

freyastreamlit commented 1 year ago

Great stuff

Best,

Joe Rosa