Support new backtest options

This commit is contained in:
Matthias 2021-02-28 09:53:51 +01:00
parent d2744755d2
commit afbaa41044
3 changed files with 56 additions and 15 deletions

View File

@ -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),
},
];
}

View File

@ -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;

View File

@ -102,13 +102,20 @@
label-align-sm="right"
label-for="stake-amount"
>
<b-form-input
id="stake-amount"
v-model="stakeAmount"
type="number"
placeholder="Use strategy default"
step="0.01"
></b-form-input>
<div class="d-flex">
<b-form-checkbox id="stake-amount-bool" v-model="stakeAmountUnlimited"
>Unlimited stake</b-form-checkbox
>
<b-form-input
id="stake-amount"
v-model="stakeAmount"
type="number"
placeholder="Use strategy default"
step="0.01"
:disabled="stakeAmountUnlimited"
></b-form-input>
</div>
</b-form-group>
<b-form-group
@ -120,7 +127,6 @@
<b-form-checkbox
id="enable-protections"
v-model="enableProtections"
:options="availableTimeframes"
></b-form-checkbox>
</b-form-group>
@ -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);