diff --git a/src/components/ftbot/BacktestResultSelect.vue b/src/components/ftbot/BacktestResultSelect.vue
index ba3a530e..a6d136b9 100644
--- a/src/components/ftbot/BacktestResultSelect.vue
+++ b/src/components/ftbot/BacktestResultSelect.vue
@@ -3,14 +3,15 @@
Available results:
- {{ key }} {{ strat.total_trades }} {{ formatPercent(strat.profit_total) }}
+ {{ key }} {{ result.strategy.total_trades }}
+ {{ formatPercent(result.strategy.profit_total) }}
import { formatPercent } from '@/shared/formatters';
-import { StrategyBacktestResult } from '@/types';
+import { BacktestResultInMemory } from '@/types';
defineProps({
backtestHistory: {
required: true,
- type: Object as () => Record,
+ type: Object as () => Record,
},
selectedBacktestResultKey: { required: false, default: '', type: String },
});
diff --git a/src/stores/ftbot.ts b/src/stores/ftbot.ts
index 2fab593c..8f73b405 100644
--- a/src/stores/ftbot.ts
+++ b/src/stores/ftbot.ts
@@ -43,6 +43,7 @@ import {
PairlistEvalResponse,
PairlistsPayload,
PairlistsResponse,
+ BacktestResultInMemory,
} from '@/types';
import axios, { AxiosResponse } from 'axios';
import { defineStore } from 'pinia';
@@ -102,7 +103,7 @@ export function createBotSubStore(botId: string, botName: string) {
backtestTradeCount: 0,
backtestResult: undefined as BacktestResult | undefined,
selectedBacktestResultKey: '',
- backtestHistory: {} as Record,
+ backtestHistory: {} as Record,
backtestHistoryList: [] as BacktestHistoryEntry[],
sysInfo: {} as SysInfoResponse,
};
@@ -114,7 +115,8 @@ export function createBotSubStore(botId: string, botName: string) {
stakeCurrencyDecimals: (state) => state.botState?.stake_currency_decimals || 3,
canRunBacktest: (state) => state.botState?.runmode === RunModes.WEBSERVER,
isWebserverMode: (state) => state.botState?.runmode === RunModes.WEBSERVER,
- selectedBacktestResult: (state) => state.backtestHistory[state.selectedBacktestResultKey],
+ selectedBacktestResult: (state) =>
+ state.backtestHistory[state.selectedBacktestResultKey]?.strategy || {},
shortAllowed: (state) => state.botState?.short_allowed || false,
openTradeCount: (state) => state.openTrades.length,
isTrading: (state) =>
@@ -898,11 +900,16 @@ export function createBotSubStore(botId: string, botName: string) {
this.backtestResult = backtestResult;
// TODO: Properly identify duplicates to avoid pushing the same multiple times
Object.entries(backtestResult.strategy).forEach(([key, strat]) => {
- console.log(key, strat);
+ const metadata = backtestResult.metadata[key];
+ console.log(key, strat, metadata);
const stratKey = `${key}_${strat.total_trades}_${strat.profit_total.toFixed(3)}`;
+ const btResult: BacktestResultInMemory = {
+ metadata,
+ strategy: strat,
+ };
// this.backtestHistory[stratKey] = strat;
- this.backtestHistory = { ...this.backtestHistory, ...{ [stratKey]: strat } };
+ this.backtestHistory = { ...this.backtestHistory, ...{ [stratKey]: btResult } };
this.selectedBacktestResultKey = stratKey;
});
},
diff --git a/src/types/backtest.ts b/src/types/backtest.ts
index 5ea5cca9..864b6d1f 100644
--- a/src/types/backtest.ts
+++ b/src/types/backtest.ts
@@ -188,6 +188,14 @@ export interface BacktestMetadata {
run_id: string;
}
+/**
+ * Represents the in-memory result of a backtest.
+ */
+export interface BacktestResultInMemory {
+ strategy: StrategyBacktestResult;
+ metadata: BacktestMetadata;
+}
+
export interface BacktestResult {
strategy: Record;
strategy_comparison: Array>;