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'],
open=in_stock_df['open'],
high=in_stock_df['high'],
low=in_stock_df['low'],
close=in_stock_df['close']
))
# 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.update_xaxes(rangebreaks=[dict(values=dt_breaks)])
fig_title = in_stock + ' for period ' + in_period + ' for range ' + 'From: ' + str(in_stock_df.index[0]) +' To: ' + str(in_stock_df.index[-1])
fig.update_layout(title=fig_title)
Would appreciate any help/ guidance.