I am trying to remove the datetime gaps in my candlestick (the gaps are the time periods when the stock market is closed, hence there are not data). Can't seem to find a good solution for using plotly graph object. Is there a feasible way to do so?
My code is as follows (using plotly graph object):
import dash
import dash_core_components as dcc
import dash_table
import pandas as pd
import dash_html_components as html
import numpy as np
from dash.dependencies import Output, Input, State
import plotly.graph_objects as go
import yfinance as yf
import plotly.express as px
from datetime import datetime, timedelta
from pytz import timezone
import dash_bootstrap_components as dbc
df= yf.Ticker('aapl')
df = df.history(interval="5m",period="5d")
df["Datetime"] = df.index
trace1 = {
'x': df.Datetime,
'open': df.Open,
'close': df.Close,
'high': df.High,
'low': df.Low,
'type': 'candlestick',
'name': 'apple,
'showlegend': False
}
data = [trace1]
# Config graph layout
layout = go.Layout({
'title': {
'text': str(input_value) + ' Stock',
'font': {
'size': 15
}
},
'plot_bgcolor': '#2E2E2E'
})
fig = go.Figure(data=data, layout=layout)
fig.update_layout(xaxis_rangeslider_visible=False)
if __name__ == '__main__':
app.run_server(debug=True)