From b26a484c3543d3d88f613d857e24a8b0fb1774f9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 5 Apr 2021 19:59:14 +0200 Subject: [PATCH] Add backtest stopping support --- src/store/modules/ftbot/index.ts | 11 ++++++++++- src/views/Backtesting.vue | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts index 40c81d58..43e440cf 100644 --- a/src/store/modules/ftbot/index.ts +++ b/src/store/modules/ftbot/index.ts @@ -622,7 +622,16 @@ export default { commit('resetBacktestHistory'); try { const result = await api.delete('/backtest'); - commit('updateBacktestRunning', result.data.running); + commit('updateBacktestRunning', result.data); + return Promise.resolve(result.data); + } catch (err) { + return Promise.reject(err); + } + }, + async stopBacktest({ commit }) { + try { + const result = await api.get('/backtest/abort'); + commit('updateBacktestRunning', result.data); return Promise.resolve(result.data); } catch (err) { return Promise.reject(err); diff --git a/src/views/Backtesting.vue b/src/views/Backtesting.vue index ac37c15d..cc6a9f67 100644 --- a/src/views/Backtesting.vue +++ b/src/views/Backtesting.vue @@ -190,6 +190,13 @@ > Load backtest result + stop Backtest void; + @ftbot.Action stopBacktest!: () => void; + // eslint-disable-next-line @typescript-eslint/no-unused-vars @ftbot.Mutation setBacktestResultKey!: (key: string) => void; formatPercent = formatPercent; get canRunBacktest() { - return this.botState.runmode === RunModes.WEBSERVER; + return this.botState?.runmode === RunModes.WEBSERVER; } get hasBacktestResult() {