Fix backtestresult in UI for now

This commit is contained in:
Matthias 2020-12-05 17:42:22 +01:00
parent cc7309d96e
commit 3013a33423
2 changed files with 24 additions and 3 deletions

View File

@ -591,7 +591,18 @@ export default {
const result = await api.get('/backtest');
commit('updateBacktestRunning', result.data.running);
if (result.data.running === false && result.data.backtest_result) {
commit('updateBacktestResult', result.data.backtest_result);
// TODO: This should be aligned in the backend, which would allow us to remove this whole block
const backtestresult = result.data.backtest_result;
for (let i = 0, len = backtestresult.strategy_comparison.length; i < len; i += 1) {
const { key } = backtestresult.strategy_comparison[i];
for (let j = 0, len = backtestresult.strategy[key].trades.length; j < len; j += 1) {
// eslint-disable-next-line @typescript-eslint/camelcase
backtestresult.strategy[key].trades[j].profit_ratio =
backtestresult.strategy[key].trades[j].profit_percent;
}
}
commit('updateBacktestResult', backtestresult);
}
},
async removeBacktest({ commit }) {

View File

@ -133,7 +133,15 @@
:show-title="true"
/>
</div>
<div v-if="hasBacktestResult && btFormMode == 'visualize'" class="text-center w-100 mt-2">
<div
v-if="hasBacktestResult && btFormMode == 'visualize'"
class="container-fluid row text-center w-100 mt-2"
>
<PairSummary
class="col-md-2"
:pairlist="selectedBacktestResult.pairlist"
:trades="selectedBacktestResult.trades"
/>
<CandleChartContainer
:available-pairs="selectedBacktestResult.pairlist"
:historic-view="!!true"
@ -142,7 +150,7 @@
:timerange="timerange"
:strategy="strategy"
:trades="selectedBacktestResult.trades"
class="candle-chart-container"
class="col-md-10 candle-chart-container"
>
</CandleChartContainer>
</div>
@ -158,6 +166,7 @@ import CandleChartContainer from '@/components/charts/CandleChartContainer.vue';
import StrategyList from '@/components/ftbot/StrategyList.vue';
import ValuePair from '@/components/ftbot/ValuePair.vue';
import CumProfitChart from '@/components/charts/CumProfitChart.vue';
import PairSummary from '@/components/ftbot/PairSummary.vue';
import {
BacktestPayload,
@ -178,6 +187,7 @@ const ftbot = namespace('ftbot');
CumProfitChart,
StrategyList,
ValuePair,
PairSummary,
},
})
export default class Backtesting extends Vue {