Issue in displaying multi day data with range breaks

Hi ,
I am a first time user of plotly.

I am trying to display multiple day stock data - OHLC and 3 moving average.
If I do not use the rangebreaks, then the data is showing correctly.
However if I use range breaks, then only first day data is being displayed.

fig = go.Figure(go.Candlestick(
    x=in_stock_df.index, #  ['datetimestamp'],

# removing all empty dates
# build complete timeline from start date to end date
period_frequency_dict = config.c_g_period_python_freq_dict
frequency = period_frequency_dict.get(f_period) # maps broker period to python frequency
dt_all = pd.date_range(start=in_stock_df.index[0], end=in_stock_df.index[-1], freq=frequency)

# retrieve the dates that ARE in the original datset
dt_obs = [d.strftime("%Y-%m-%d %H:%M:%S") for d in pd.to_datetime(in_stock_df.index)]

# define dates with missing values
dt_breaks = [d for d in dt_all.strftime("%Y-%m-%d %H:%M:%S").tolist() if not d in dt_obs]
fig.add_trace(go.Scatter(x=in_stock_df.index, y=in_stock_df['ema10'],opacity=0.7,
                         line=dict(color='blue', width=2),name='EMA10'))
fig.add_trace(go.Scatter(x=in_stock_df.index, y=in_stock_df['ema20'], opacity=0.7,
                         line=dict(color='orange', width=2), name='EMA20'))
fig.add_trace(go.Scatter(x=in_stock_df.index, y=in_stock_df['hma50'], opacity=0.7,
                         line=dict(color='orange', width=2), name='HMA50'))
fig_title = in_stock + ' for period ' + in_period + ' for range ' + 'From: ' + str(in_stock_df.index[0]) +' To: '  + str(in_stock_df.index[-1])

Would appreciate any help/ guidance.

Got the solution from another thread - How to use rangebreaks for a datetime index at levels smaller than 1 hour?

Issue resolved.

1 Like