From afbaa4104473146d9cb386329c4cd6a705f0c6b9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 28 Feb 2021 09:53:51 +0100 Subject: [PATCH] Support new backtest options --- src/components/ftbot/BacktestResultView.vue | 32 +++++++++++++++++-- src/types/backtest.ts | 4 +-- src/views/Backtesting.vue | 35 ++++++++++++++------- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/components/ftbot/BacktestResultView.vue b/src/components/ftbot/BacktestResultView.vue index 5a45db64..85ef5f07 100644 --- a/src/components/ftbot/BacktestResultView.vue +++ b/src/components/ftbot/BacktestResultView.vue @@ -76,6 +76,12 @@ export default class BacktestResultView extends Vue { return sortedTrades; } + formatPriceStake(price) { + return `${formatPrice(price, this.backtestResult.stake_currency_decimals)} ${ + this.backtestResult.stake_currency + }`; + } + get bestPair(): string { const trades = this.getSortedTrades(this.backtestResult); const value = trades[trades.length - 1]; @@ -96,9 +102,9 @@ export default class BacktestResultView extends Vue { // { metric: 'First trade Pair', value: this.backtestResult.backtest_best_day }, { metric: 'Total Profit', - value: `${formatPercent(this.backtestResult.profit_total)} | ${formatPrice( + value: `${formatPercent(this.backtestResult.profit_total)} | ${this.formatPriceStake( this.backtestResult.profit_total_abs, - )} ${this.backtestResult.stake_currency}`, + )}`, }, { metric: 'Trades per day', value: this.backtestResult.trades_per_day }, @@ -131,8 +137,14 @@ export default class BacktestResultView extends Vue { value: humanizeDurationFromSeconds(this.backtestResult.loser_holding_avg), }, { metric: 'Max Drawdown', value: formatPercent(this.backtestResult.max_drawdown) }, + { + metric: 'Max Drawdown ABS', + value: this.formatPriceStake(this.backtestResult.max_drawdown_abs), + }, { metric: 'Drawdown start', value: this.backtestResult.drawdown_start }, { metric: 'Drawdown end', value: this.backtestResult.drawdown_end }, + { metric: 'Min balance', value: this.formatPriceStake(this.backtestResult.csum_min) }, + { metric: 'Max balance', value: this.formatPriceStake(this.backtestResult.csum_max) }, { metric: 'Market change', value: formatPercent(this.backtestResult.market_change) }, { @@ -177,6 +189,22 @@ export default class BacktestResultView extends Vue { { setting: 'Sell profit only', value: this.backtestResult.sell_profit_only }, { setting: 'Sell profit offset', value: this.backtestResult.sell_profit_offset }, { setting: 'Enable protections', value: this.backtestResult.enable_protections }, + { + setting: 'Starting balance', + value: this.formatPriceStake(this.backtestResult.starting_balance), + }, + { + setting: 'Final balance', + value: this.formatPriceStake(this.backtestResult.final_balance), + }, + { + setting: 'Avg. stake amount', + value: this.formatPriceStake(this.backtestResult.avg_stake_amount), + }, + { + setting: 'Total trade volume', + value: this.formatPriceStake(this.backtestResult.total_volume), + }, ]; } diff --git a/src/types/backtest.ts b/src/types/backtest.ts index 2f547488..0de72b18 100644 --- a/src/types/backtest.ts +++ b/src/types/backtest.ts @@ -7,7 +7,7 @@ export interface BacktestPayload { timeframe?: string; max_open_trades?: number; // TODO: Should be number or unlimited - stake_amount?: number; + stake_amount?: number | string; dry_run_wallet?: number; enable_protections?: boolean; } @@ -106,7 +106,7 @@ export interface StrategyBacktestResult { max_drawdown_low: number; max_drawdown_high: number; - cusm_min: number; + csum_min: number; csum_max: number; winner_holding_avg: number; diff --git a/src/views/Backtesting.vue b/src/views/Backtesting.vue index cae3439a..8ca2e8d9 100644 --- a/src/views/Backtesting.vue +++ b/src/views/Backtesting.vue @@ -102,13 +102,20 @@ label-align-sm="right" label-for="stake-amount" > - +
+ Unlimited stake + + +
@@ -280,6 +286,8 @@ export default class Backtesting extends Vue { maxOpenTrades = ''; + stakeAmountUnlimited = false; + stakeAmount = ''; startingCapital = ''; @@ -346,10 +354,15 @@ export default class Backtesting extends Vue { // eslint-disable-next-line @typescript-eslint/camelcase btPayload.max_open_trades = openTradesInt; } - const stakeAmount = Number(this.stakeAmount); - if (stakeAmount) { + if (this.stakeAmountUnlimited) { // eslint-disable-next-line @typescript-eslint/camelcase - btPayload.stake_amount = stakeAmount; + btPayload.stake_amount = 'unlimited'; + } else { + const stakeAmount = Number(this.stakeAmount); + if (stakeAmount) { + // eslint-disable-next-line @typescript-eslint/camelcase + btPayload.stake_amount = stakeAmount; + } } const startingCapital = Number(this.startingCapital);