mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
initial attempt to load historic backtest results
This commit is contained in:
parent
f80ac13ab0
commit
bb21744232
|
@ -37,6 +37,7 @@ import {
|
|||
BlacklistResponse,
|
||||
ForceSellPayload,
|
||||
LoadingStatus,
|
||||
BacktestHistoryEntry,
|
||||
} from '@/types';
|
||||
|
||||
import {
|
||||
|
@ -104,6 +105,7 @@ export enum BotStoreGetters {
|
|||
backtestStep = 'backtestStep',
|
||||
backtestProgress = 'backtestProgress',
|
||||
backtestHistory = 'backtestHistory',
|
||||
backtestHistoryList = 'backtestHistoryList',
|
||||
selectedBacktestResultKey = 'selectedBacktestResultKey',
|
||||
}
|
||||
|
||||
|
@ -150,6 +152,8 @@ export enum BotStoreActions {
|
|||
deleteBlacklist = 'deleteBlacklist',
|
||||
startBacktest = 'startBacktest',
|
||||
pollBacktest = 'pollBacktest',
|
||||
getBacktestHistory = 'getBacktestHistory',
|
||||
getBacktestHistoryResult = 'getBacktestHistoryResult',
|
||||
removeBacktest = 'removeBacktest',
|
||||
stopBacktest = 'stopBacktest',
|
||||
setBacktestResultKey = 'setBacktestResultKey',
|
||||
|
@ -341,6 +345,9 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
[BotStoreGetters.backtestHistory](state: FtbotStateType): {} {
|
||||
return state.backtestHistory;
|
||||
},
|
||||
[BotStoreGetters.backtestHistoryList](state: FtbotStateType): BacktestHistoryEntry[] {
|
||||
return state.backtestHistoryList;
|
||||
},
|
||||
[BotStoreGetters.selectedBacktestResultKey](state: FtbotStateType): string {
|
||||
return state.selectedBacktestResultKey;
|
||||
},
|
||||
|
@ -468,6 +475,9 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
setBacktestResultKey(state: FtbotStateType, key: string) {
|
||||
state.selectedBacktestResultKey = key;
|
||||
},
|
||||
setBacktestHistory(state: FtbotStateType, backtestList) {
|
||||
state.backtestHistoryList = backtestList;
|
||||
},
|
||||
updateSysInfo(state, sysinfo: SysInfoResponse) {
|
||||
state.sysinfo = sysinfo;
|
||||
},
|
||||
|
@ -1053,6 +1063,18 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
return Promise.reject(err);
|
||||
}
|
||||
},
|
||||
async [BotStoreActions.getBacktestHistory]({ commit }) {
|
||||
const result = await api.get<BacktestHistoryEntry[]>('/backtest/history');
|
||||
commit('setBacktestHistory', result.data);
|
||||
},
|
||||
async [BotStoreActions.getBacktestHistoryResult]({ commit }, filename: string) {
|
||||
const result = await api.get<BacktestStatus>('/backtest/history/result', {
|
||||
params: { filename: filename },
|
||||
});
|
||||
if (result.data.backtest_result) {
|
||||
commit('updateBacktestResult', result.data.backtest_result);
|
||||
}
|
||||
},
|
||||
[BotStoreActions.setBacktestResultKey]({ commit }, key: string) {
|
||||
commit('setBacktestResultKey', key);
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
LogLine,
|
||||
SysInfoResponse,
|
||||
LoadingStatus,
|
||||
BacktestHistoryEntry,
|
||||
} from '@/types';
|
||||
|
||||
export interface FtbotStateType {
|
||||
|
@ -61,6 +62,7 @@ export interface FtbotStateType {
|
|||
backtestResult?: BacktestResult;
|
||||
selectedBacktestResultKey: string;
|
||||
backtestHistory: Record<string, StrategyBacktestResult>;
|
||||
backtestHistoryList: BacktestHistoryEntry[];
|
||||
sysinfo: SysInfoResponse | {};
|
||||
}
|
||||
|
||||
|
@ -107,6 +109,7 @@ const state = (): FtbotStateType => {
|
|||
backtestResult: undefined,
|
||||
selectedBacktestResultKey: '',
|
||||
backtestHistory: {},
|
||||
backtestHistoryList: [],
|
||||
sysinfo: {},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -166,3 +166,10 @@ export interface BacktestStatus {
|
|||
trade_count?: number;
|
||||
backtest_result?: BacktestResult;
|
||||
}
|
||||
|
||||
export interface BacktestHistoryEntry {
|
||||
filename: string;
|
||||
strategy: string;
|
||||
run_id: string;
|
||||
backtest_start_time: number;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,15 @@
|
|||
<!-- End Left bar -->
|
||||
|
||||
<div v-if="btFormMode == 'run'" class="flex-fill row d-flex flex-column bt-config">
|
||||
<button class="btn btn-secondary" @click="getBacktestHistory">Get historic results</button>
|
||||
<div v-if="backtestHistoryList">
|
||||
<div v-for="(res, idx) in backtestHistoryList" :key="idx">
|
||||
<button class="btn btn-secondary" @click="getBacktestHistoryResult(res.filename)">
|
||||
{{ res.filename }} {{ res.strategy }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2">
|
||||
<span>Strategy</span>
|
||||
<StrategySelect v-model="strategy"></StrategySelect>
|
||||
|
@ -308,6 +317,7 @@ import {
|
|||
PairHistoryPayload,
|
||||
PlotConfig,
|
||||
StrategyBacktestResult,
|
||||
BacktestHistoryEntry,
|
||||
} from '@/types';
|
||||
|
||||
import { getCustomPlotConfig, getPlotConfigName } from '@/shared/storage';
|
||||
|
@ -376,6 +386,8 @@ export default class Backtesting extends Vue {
|
|||
|
||||
@ftbot.Getter [BotStoreGetters.canRunBacktest]!: boolean;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.backtestHistoryList]!: BacktestHistoryEntry[];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action getPairHistory!: (payload: PairHistoryPayload) => void;
|
||||
|
||||
|
@ -386,10 +398,15 @@ export default class Backtesting extends Vue {
|
|||
|
||||
@ftbot.Action pollBacktest!: () => void;
|
||||
|
||||
@ftbot.Action getBacktestHistory!: () => void;
|
||||
|
||||
@ftbot.Action removeBacktest!: () => void;
|
||||
|
||||
@ftbot.Action stopBacktest!: () => void;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action getBacktestHistoryResult!: (filename: string) => void;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action setBacktestResultKey!: (key: string) => void;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user