Add backtest stopping support

This commit is contained in:
Matthias 2021-04-05 19:59:14 +02:00
parent d24cdd4fac
commit b26a484c35
2 changed files with 20 additions and 2 deletions

View File

@ -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);

View File

@ -190,6 +190,13 @@
>
Load backtest result
</b-button>
<b-button
variant="primary"
class="mx-1"
:disabled="!backtestRunning"
@click="stopBacktest"
>stop Backtest</b-button
>
<b-button
variant="primary"
class="mx-1"
@ -363,13 +370,15 @@ export default class Backtesting extends Vue {
@ftbot.Action removeBacktest!: () => 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() {