mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 03:25:15 +00:00
selected backtest result in store
This commit is contained in:
parent
2cc7c88975
commit
980edc2333
|
@ -23,6 +23,7 @@ import {
|
|||
Lock,
|
||||
RunModes,
|
||||
TradeResponse,
|
||||
StrategyBacktestResult,
|
||||
} from '@/types';
|
||||
|
||||
import {
|
||||
|
@ -48,6 +49,7 @@ export enum BotStoreGetters {
|
|||
isTrading = 'isTrading',
|
||||
isWebserverMode = 'isWebserverMode',
|
||||
refreshRequired = 'refreshRequired',
|
||||
selectedBacktestResult = 'selectedBacktestResult',
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -110,6 +112,9 @@ export default {
|
|||
[BotStoreGetters.refreshRequired](state: FtbotStateType): boolean {
|
||||
return state.refreshRequired;
|
||||
},
|
||||
[BotStoreGetters.selectedBacktestResult](state): StrategyBacktestResult {
|
||||
return state.backtestHistory[state.selectedBacktestResultKey];
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) {
|
||||
|
@ -190,7 +195,7 @@ export default {
|
|||
storeCustomPlotConfig(plotConfig);
|
||||
state.availablePlotConfigNames = getAllPlotConfigNames();
|
||||
},
|
||||
updateBacktestRunning(state, running: boolean) {
|
||||
updateBacktestRunning(state: FtbotStateType, running: boolean) {
|
||||
state.backtestRunning = running;
|
||||
},
|
||||
updateBacktestResult(state, backtestResult: BacktestResult) {
|
||||
|
@ -199,8 +204,12 @@ export default {
|
|||
Object.entries(backtestResult.strategy).forEach(([key, strat]) => {
|
||||
const xxx = `${key}_${strat.total_trades}_${strat.profit_total.toFixed(3)}`;
|
||||
state.backtestHistory[xxx] = strat;
|
||||
state.selectedBacktestResultKey = xxx;
|
||||
});
|
||||
},
|
||||
setBacktestResultKey(state: FtbotStateType, key: string) {
|
||||
state.selectedBacktestResultKey = key;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
ping({ commit, rootState }) {
|
||||
|
|
|
@ -44,6 +44,7 @@ export interface FtbotStateType {
|
|||
currentLocks?: LockResponse;
|
||||
backtestRunning: boolean;
|
||||
backtestResult?: BacktestResult;
|
||||
selectedBacktestResultKey: string;
|
||||
backtestHistory: Record<string, BacktestResult>;
|
||||
}
|
||||
const state: FtbotStateType = {
|
||||
|
@ -76,6 +77,7 @@ const state: FtbotStateType = {
|
|||
// backtesting
|
||||
backtestRunning: false,
|
||||
backtestResult: undefined,
|
||||
selectedBacktestResultKey: '',
|
||||
backtestHistory: {},
|
||||
};
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ export interface StrategyBacktestResult {
|
|||
|
||||
/** Start time of the backtest run */
|
||||
backtest_run_start_ts: number;
|
||||
/** ENd time of the backtest run */
|
||||
/** End time of the backtest run */
|
||||
backtest_run_end_ts: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,14 +145,16 @@
|
|||
</div>
|
||||
<div v-if="hasBacktestResult && btFormMode == 'results'" class="text-center w-100 mt-2">
|
||||
<div class="d-flex">
|
||||
<b-list-group-item
|
||||
v-for="[key, strat] in Object.entries(backtestHistory)"
|
||||
:key="key"
|
||||
button
|
||||
class="d-flex justify-content-between align-items-center py-1"
|
||||
>
|
||||
{{ key }} {{ strat.total_trades }} {{ formatPercent(strat.profit_total) }}
|
||||
</b-list-group-item>
|
||||
<b-list-group>
|
||||
<b-list-group-item
|
||||
v-for="[key, strat] in Object.entries(backtestHistory)"
|
||||
:key="key"
|
||||
button
|
||||
class="d-flex justify-content-between align-items-center py-1"
|
||||
>
|
||||
{{ key }} {{ strat.total_trades }} {{ formatPercent(strat.profit_total) }}
|
||||
</b-list-group-item>
|
||||
</b-list-group>
|
||||
</div>
|
||||
<BacktestResultView :strategy="strategy" :backtest-result="selectedBacktestResult" />
|
||||
</div>
|
||||
|
@ -172,23 +174,26 @@
|
|||
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"
|
||||
sort-method="profit"
|
||||
/>
|
||||
<CandleChartContainer
|
||||
:available-pairs="selectedBacktestResult.pairlist"
|
||||
:historic-view="!!true"
|
||||
:timeframe="timeframe"
|
||||
:plot-config="selectedPlotConfig"
|
||||
:timerange="timerange"
|
||||
:strategy="strategy"
|
||||
:trades="selectedBacktestResult.trades"
|
||||
class="col-md-10 candle-chart-container"
|
||||
>
|
||||
</CandleChartContainer>
|
||||
<p>Graph will always show the latest values for the selected strategy.</p>
|
||||
<div class="container-fluid row text-center">
|
||||
<PairSummary
|
||||
class="col-md-2"
|
||||
:pairlist="selectedBacktestResult.pairlist"
|
||||
:trades="selectedBacktestResult.trades"
|
||||
sort-method="profit"
|
||||
/>
|
||||
<CandleChartContainer
|
||||
:available-pairs="selectedBacktestResult.pairlist"
|
||||
:historic-view="!!true"
|
||||
:timeframe="timeframe"
|
||||
:plot-config="selectedPlotConfig"
|
||||
:timerange="timerange"
|
||||
:strategy="strategy"
|
||||
:trades="selectedBacktestResult.trades"
|
||||
class="col-md-10 candle-chart-container"
|
||||
>
|
||||
</CandleChartContainer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -215,6 +220,7 @@ import {
|
|||
|
||||
import { getCustomPlotConfig, getPlotConfigName } from '@/shared/storage';
|
||||
import { formatPercent } from '@/shared/formatters';
|
||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||
|
||||
const ftbot = namespace('ftbot');
|
||||
@Component({
|
||||
|
@ -274,6 +280,8 @@ export default class Backtesting extends Vue {
|
|||
|
||||
@ftbot.State backtestHistory!: StrategyBacktestResult[];
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.selectedBacktestResult]!: StrategyBacktestResult;
|
||||
|
||||
@ftbot.State history;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
@ -297,9 +305,9 @@ export default class Backtesting extends Vue {
|
|||
return Object.keys(this.backtestResult).length !== 0;
|
||||
}
|
||||
|
||||
get selectedBacktestResult(): StrategyBacktestResult {
|
||||
return this.backtestResult.strategy[this.strategy] || {};
|
||||
}
|
||||
// get selectedBacktestResult(): StrategyBacktestResult {
|
||||
// return this.backtestResult.strategy[this.strategy] || {};
|
||||
// }
|
||||
|
||||
get timeframe(): string {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue
Block a user