From 58289816465ddd391e9ae2f4a52287b2ca69290c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 7 Apr 2022 06:59:08 +0200 Subject: [PATCH] Add short backtesting results --- src/components/ftbot/BacktestResultView.vue | 25 +++++++++++++++++++++ src/types/backtest.ts | 7 ++++++ 2 files changed, 32 insertions(+) diff --git a/src/components/ftbot/BacktestResultView.vue b/src/components/ftbot/BacktestResultView.vue index b0c7f58b..414309b3 100644 --- a/src/components/ftbot/BacktestResultView.vue +++ b/src/components/ftbot/BacktestResultView.vue @@ -111,6 +111,29 @@ export default class BacktestResultView extends Vue { get backtestResultStats() { // Transpose Result into readable format + const shortMetrics = + this.backtestResult?.trade_count_short && this.backtestResult?.trade_count_short > 0 + ? [ + { metric: '___', value: '___' }, + { + metric: 'Long / Short', + value: `${this.backtestResult.trade_count_long} / ${this.backtestResult.trade_count_short}`, + }, + { + metric: 'Total profit Long', + value: `${formatPercent( + this.backtestResult.profit_total_long || 0, + )} | ${this.formatPriceStake(this.backtestResult.profit_total_long_abs)}`, + }, + { + metric: 'Total profit Short', + value: `${formatPercent( + this.backtestResult.profit_total_short || 0, + )} | ${this.formatPriceStake(this.backtestResult.profit_total_short_abs)}`, + }, + ] + : []; + return [ { metric: 'Total Profit', @@ -170,6 +193,8 @@ export default class BacktestResultView extends Vue { value: `${this.backtestResult.timedout_entry_orders} / ${this.backtestResult.timedout_exit_orders}`, }, + ...shortMetrics, + { metric: '___', value: '___' }, { metric: 'Min balance', value: this.formatPriceStake(this.backtestResult.csum_min) }, { metric: 'Max balance', value: this.formatPriceStake(this.backtestResult.csum_max) }, diff --git a/src/types/backtest.ts b/src/types/backtest.ts index 8c2e5ff7..86077334 100644 --- a/src/types/backtest.ts +++ b/src/types/backtest.ts @@ -127,6 +127,13 @@ export interface StrategyBacktestResult { winner_holding_avg: number; winning_days: number; + trade_count_long?: number; + trade_count_short?: number; + profit_total_long?: number; + profit_total_short?: number; + profit_total_long_abs?: number; + profit_total_short_abs?: number; + /** Start time of the backtest run */ backtest_run_start_ts: number; /** End time of the backtest run */