Fix historic selection bug

This commit is contained in:
Matthias 2022-09-14 20:44:29 +02:00
parent 2d6dc674a2
commit caad7e3ae2

View File

@ -85,7 +85,7 @@
v-if="btFormMode !== 'visualize' && showLeftBar" v-if="btFormMode !== 'visualize' && showLeftBar"
:backtest-history="botStore.activeBot.backtestHistory" :backtest-history="botStore.activeBot.backtestHistory"
:selected-backtest-result-key="botStore.activeBot.selectedBacktestResultKey" :selected-backtest-result-key="botStore.activeBot.selectedBacktestResultKey"
@selectionChange="setBacktestResult" @selectionChange="botStore.activeBot.setBacktestResultKey"
/> />
</transition> </transition>
</div> </div>
@ -411,9 +411,7 @@ export default defineComponent({
const pollInterval = ref<number | null>(null); const pollInterval = ref<number | null>(null);
const sliderPosition = ref<ChartSliderPosition>(); const sliderPosition = ref<ChartSliderPosition>();
const setBacktestResult = (key: string) => { const selectBacktestResult = () => {
botStore.activeBot.setBacktestResultKey(key);
// Set parameters for this result // Set parameters for this result
strategy.value = botStore.activeBot.selectedBacktestResult.strategy_name; strategy.value = botStore.activeBot.selectedBacktestResult.strategy_name;
selectedTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe; selectedTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe;
@ -422,6 +420,13 @@ export default defineComponent({
timerange.value = botStore.activeBot.selectedBacktestResult.timerange; timerange.value = botStore.activeBot.selectedBacktestResult.timerange;
}; };
watch(
() => botStore.activeBot.selectedBacktestResultKey,
() => {
selectBacktestResult();
},
);
const clickBacktest = () => { const clickBacktest = () => {
const btPayload: BacktestPayload = { const btPayload: BacktestPayload = {
strategy: strategy.value, strategy: strategy.value,
@ -487,7 +492,6 @@ export default defineComponent({
formatPercent, formatPercent,
hasBacktestResult, hasBacktestResult,
timeframe, timeframe,
setBacktestResult,
strategy, strategy,
selectedTimeframe, selectedTimeframe,
selectedDetailTimeframe, selectedDetailTimeframe,