Hello everyone!
I am trying to make a chart that would be updatable by user input. So the user can set any time and date for the beginning and end of time series, and it would update it. However, every time I would get a different chart, so it needs to be recalculated for any period. I’ve tried to do it using examples from the web-site, but nothing happens in the end. What am I doing wrong here?
Thank you!
fig = go.FigureWidget(make_subplots(
rows=2, cols=1,
shared_xaxes=True,
specs=[[{“type”: “Candlestick”}],
[{“type”: “table”}]]
))
textbox1 = widgets.Dropdown(
description='Start date: ',
value=table[0][1],
)
textbox2 = widgets.Dropdown(
description='End date: ',
value=table[1][1],
)
if len(self.strategy_params['signal_params']['curr_generators'].items()) == 1:
fig.add_trace(go.Candlestick(x=self._data.index,
open=self._data['Open'],
high=self._data['High'],
low=self._data['Low'],
close=self._data['Close']), row=1, col=1)
else:
single_cur = False
fig.add_trace(go.Scatter(x=self._data.index, y=self.calc_of_index()['strategy'], mode='lines', name='lines'),
row=1, col=1)
fig.add_trace(go.Scatter(x=self._data.index, y=self.balance_list['strategy'], mode='lines', name='lines'), row=1, col=1)
fig.add_trace(
go.Table(
header=dict(
values=[table[i][0] for i in range(len(table))],
font=dict(size=10),
align="left"
),
cells=dict(
values=[table[i][1] for i in range(len(table))],
align="left")
),
row=2, col=1
)
fig.update_layout(xaxis_rangeslider_visible=False, template='plotly_dark')
def response(change):
start = textbox1.value
end = textbox2.value
for currency in data.keys():
data[currency] = get_data('./data', currency, 'USD', '1h', 'Bitstamp',
start_date=start,last_date=end, update_data=False)
self.strategy_update()
signals = pd.Series(self._res.backtest_list[0].strategy.stack.algos[2].signals)
self._data_calculator(signals)
if single_cur:
fig.update_traces(x=self._data.index,
open=self._data['Open'],
high=self._data['High'],
low=self._data['Low'],
close=self._data['Close'], col=1)
textbox1.observe(response, names="value")
textbox2.observe(response, names="value")
container = widgets.HBox([textbox1, textbox2])
b = widgets.VBox([container, fig])