2020-07-26 11:44:34 +00:00
|
|
|
<template>
|
2021-07-04 17:57:19 +00:00
|
|
|
<div class="container-fluid" style="max-height: calc(100vh - 60px)">
|
2021-07-04 14:08:43 +00:00
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="row mb-2"></div>
|
2022-04-19 05:05:34 +00:00
|
|
|
<p v-if="!botStore.activeBot.canRunBacktest">
|
|
|
|
Bot must be in webserver mode to enable Backtesting.
|
|
|
|
</p>
|
2021-07-04 14:08:43 +00:00
|
|
|
<div class="row w-100">
|
|
|
|
<h2 class="col-4 col-lg-3">Backtesting</h2>
|
|
|
|
<div
|
2021-12-01 05:40:25 +00:00
|
|
|
class="col-12 col-lg-order-last col-lg-6 mx-md-5 d-flex flex-wrap justify-content-md-center justify-content-between mb-4"
|
2020-12-05 15:32:44 +00:00
|
|
|
>
|
2022-04-12 05:18:35 +00:00
|
|
|
<b-form-radio
|
2022-04-19 05:05:34 +00:00
|
|
|
v-if="botStore.activeBot.botApiVersion >= 2.15"
|
2022-04-12 05:18:35 +00:00
|
|
|
v-model="btFormMode"
|
|
|
|
name="bt-form-radios"
|
|
|
|
button
|
|
|
|
class="mx-1 flex-samesize-items"
|
|
|
|
value="historicResults"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="!botStore.activeBot.canRunBacktest"
|
2022-04-12 05:18:35 +00:00
|
|
|
>Load Results</b-form-radio
|
|
|
|
>
|
2021-07-04 14:08:43 +00:00
|
|
|
<b-form-radio
|
|
|
|
v-model="btFormMode"
|
|
|
|
name="bt-form-radios"
|
|
|
|
button
|
|
|
|
class="mx-1 flex-samesize-items"
|
|
|
|
value="run"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="!botStore.activeBot.canRunBacktest"
|
2021-07-04 14:08:43 +00:00
|
|
|
>Run backtest</b-form-radio
|
|
|
|
>
|
|
|
|
<b-form-radio
|
2022-04-13 17:55:27 +00:00
|
|
|
id="bt-analyze-btn"
|
2021-07-04 14:08:43 +00:00
|
|
|
v-model="btFormMode"
|
|
|
|
name="bt-form-radios"
|
|
|
|
button
|
|
|
|
class="mx-1 flex-samesize-items"
|
|
|
|
value="results"
|
|
|
|
:disabled="!hasBacktestResult"
|
|
|
|
>Analyze result</b-form-radio
|
|
|
|
>
|
|
|
|
<b-form-radio
|
|
|
|
v-model="btFormMode"
|
|
|
|
name="bt-form-radios"
|
|
|
|
button
|
|
|
|
class="mx-1 flex-samesize-items"
|
|
|
|
value="visualize-summary"
|
|
|
|
:disabled="!hasBacktestResult"
|
|
|
|
>Visualize summary</b-form-radio
|
|
|
|
>
|
|
|
|
<b-form-radio
|
|
|
|
v-model="btFormMode"
|
|
|
|
name="bt-form-radios"
|
|
|
|
button
|
|
|
|
class="mx-1 flex-samesize-items"
|
|
|
|
value="visualize"
|
|
|
|
:disabled="!hasBacktestResult"
|
|
|
|
>Visualize result</b-form-radio
|
|
|
|
>
|
|
|
|
</div>
|
2022-04-19 05:05:34 +00:00
|
|
|
<small
|
|
|
|
v-show="botStore.activeBot.backtestRunning"
|
2022-10-30 13:26:23 +00:00
|
|
|
class="text-end bt-running-label col-8 col-lg-3"
|
2022-04-19 05:05:34 +00:00
|
|
|
>Backtest running: {{ botStore.activeBot.backtestStep }}
|
|
|
|
{{ formatPercent(botStore.activeBot.backtestProgress, 2) }}</small
|
2020-12-05 15:32:44 +00:00
|
|
|
>
|
|
|
|
</div>
|
2021-03-11 18:17:09 +00:00
|
|
|
</div>
|
2021-06-25 18:00:40 +00:00
|
|
|
|
2021-05-23 14:25:31 +00:00
|
|
|
<div class="d-md-flex">
|
2021-03-11 18:17:09 +00:00
|
|
|
<!-- Left bar -->
|
|
|
|
<div
|
2022-11-18 18:48:15 +00:00
|
|
|
:class="`${showLeftBar ? 'col-md-3' : ''} sticky-top sticky-offset me-3 d-flex flex-column`"
|
2021-03-11 18:17:09 +00:00
|
|
|
>
|
|
|
|
<b-button
|
2021-06-25 18:00:40 +00:00
|
|
|
v-if="btFormMode !== 'visualize'"
|
2021-03-11 18:17:09 +00:00
|
|
|
class="align-self-start"
|
|
|
|
aria-label="Close"
|
|
|
|
size="sm"
|
|
|
|
@click="showLeftBar = !showLeftBar"
|
|
|
|
>{{ showLeftBar ? '<' : '>' }}</b-button
|
|
|
|
>
|
2021-06-24 18:46:24 +00:00
|
|
|
<transition name="fade" mode="in-out">
|
|
|
|
<BacktestResultSelect
|
|
|
|
v-if="btFormMode !== 'visualize' && showLeftBar"
|
2022-04-19 05:05:34 +00:00
|
|
|
:backtest-history="botStore.activeBot.backtestHistory"
|
|
|
|
:selected-backtest-result-key="botStore.activeBot.selectedBacktestResultKey"
|
2023-04-13 04:34:39 +00:00
|
|
|
@selection-change="botStore.activeBot.setBacktestResultKey"
|
2021-06-24 18:46:24 +00:00
|
|
|
/>
|
|
|
|
</transition>
|
2021-03-11 18:17:09 +00:00
|
|
|
</div>
|
|
|
|
<!-- End Left bar -->
|
2022-04-12 05:18:35 +00:00
|
|
|
<div
|
|
|
|
v-if="btFormMode == 'historicResults'"
|
|
|
|
class="flex-fill row d-flex flex-column bt-config"
|
|
|
|
>
|
|
|
|
<backtest-history-load />
|
|
|
|
</div>
|
2021-07-06 04:56:41 +00:00
|
|
|
<div v-if="btFormMode == 'run'" class="flex-fill row d-flex flex-column bt-config">
|
2021-05-24 09:34:48 +00:00
|
|
|
<div class="mb-2">
|
|
|
|
<span>Strategy</span>
|
2023-07-22 09:11:07 +00:00
|
|
|
<StrategySelect v-model="btStore.strategy"></StrategySelect>
|
2021-05-24 09:34:48 +00:00
|
|
|
</div>
|
2022-12-20 18:27:43 +00:00
|
|
|
<b-card :disabled="botStore.activeBot.backtestRunning">
|
2020-12-05 15:32:44 +00:00
|
|
|
<!-- Backtesting parameters -->
|
2020-09-25 04:22:34 +00:00
|
|
|
<b-form-group
|
2020-12-05 15:32:44 +00:00
|
|
|
label-cols-lg="2"
|
|
|
|
label="Backtest params"
|
|
|
|
label-size="sm"
|
2022-10-30 13:26:23 +00:00
|
|
|
label-class="fw-bold pt-0"
|
2020-12-05 15:32:44 +00:00
|
|
|
class="mb-0"
|
2020-07-27 05:19:45 +00:00
|
|
|
>
|
2021-05-23 15:06:04 +00:00
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Timeframe:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="timeframe-select"
|
|
|
|
>
|
2023-07-22 09:13:35 +00:00
|
|
|
<TimeframeSelect id="timeframe-select" v-model="btStore.selectedTimeframe" />
|
2021-08-14 18:18:06 +00:00
|
|
|
</b-form-group>
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Detail Timeframe:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="timeframe-detail-select"
|
|
|
|
title="Detail timeframe, to simulate intra-candle results. Not setting this will not use this functionality."
|
|
|
|
>
|
|
|
|
<TimeframeSelect
|
|
|
|
id="timeframe-detail-select"
|
2023-07-22 09:13:35 +00:00
|
|
|
v-model="btStore.selectedDetailTimeframe"
|
|
|
|
:below-timeframe="btStore.selectedTimeframe"
|
2021-08-14 18:18:06 +00:00
|
|
|
/>
|
2021-05-23 15:06:04 +00:00
|
|
|
</b-form-group>
|
2020-12-05 15:32:44 +00:00
|
|
|
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Max open trades:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="max-open-trades"
|
|
|
|
>
|
|
|
|
<b-form-input
|
|
|
|
id="max-open-trades"
|
2020-12-08 18:35:06 +00:00
|
|
|
v-model="maxOpenTrades"
|
2020-12-05 15:32:44 +00:00
|
|
|
placeholder="Use strategy default"
|
|
|
|
type="number"
|
|
|
|
></b-form-input>
|
|
|
|
</b-form-group>
|
2021-02-17 19:37:30 +00:00
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Starting capital:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="starting-capital"
|
|
|
|
>
|
|
|
|
<b-form-input
|
|
|
|
id="starting-capital"
|
|
|
|
v-model="startingCapital"
|
|
|
|
type="number"
|
|
|
|
step="0.001"
|
|
|
|
></b-form-input>
|
|
|
|
</b-form-group>
|
2020-12-05 15:32:44 +00:00
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Stake amount:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="stake-amount"
|
|
|
|
>
|
2021-02-28 08:53:51 +00:00
|
|
|
<div class="d-flex">
|
2021-03-10 15:09:55 +00:00
|
|
|
<b-form-checkbox
|
|
|
|
id="stake-amount-bool"
|
|
|
|
v-model="stakeAmountUnlimited"
|
|
|
|
class="col-md-6"
|
2021-02-28 08:53:51 +00:00
|
|
|
>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>
|
2020-12-05 15:32:44 +00:00
|
|
|
</b-form-group>
|
|
|
|
|
2021-01-06 19:25:38 +00:00
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Enable Protections:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="enable-protections"
|
|
|
|
>
|
|
|
|
<b-form-checkbox
|
|
|
|
id="enable-protections"
|
|
|
|
v-model="enableProtections"
|
|
|
|
></b-form-checkbox>
|
|
|
|
</b-form-group>
|
2022-12-20 18:21:23 +00:00
|
|
|
<b-form-group
|
2022-12-20 18:34:19 +00:00
|
|
|
v-if="botStore.activeBot.botApiVersion >= 2.22"
|
2022-12-20 18:21:23 +00:00
|
|
|
label-cols-sm="5"
|
|
|
|
label="Cache Backtest results:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="enable-cache"
|
|
|
|
>
|
|
|
|
<b-form-checkbox id="enable-cache" v-model="allowCache"></b-form-checkbox>
|
|
|
|
</b-form-group>
|
2022-12-20 06:13:08 +00:00
|
|
|
<template v-if="botStore.activeBot.botApiVersion >= 2.22">
|
|
|
|
<b-form-group
|
|
|
|
label-cols-sm="5"
|
|
|
|
label="Enable FreqAI:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="enable-freqai"
|
|
|
|
>
|
2022-12-20 06:18:49 +00:00
|
|
|
<template #label>
|
|
|
|
<div class="d-flex justify-content-center">
|
|
|
|
<span class="me-2">Enable FreqAI:</span>
|
|
|
|
<InfoBox
|
|
|
|
hint="Assumes freqAI configuration is setup in the configuration, and the strategy is a freqAI strategy. Will fail if that's not the case."
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-07-22 09:16:13 +00:00
|
|
|
<b-form-checkbox
|
|
|
|
id="enable-freqai"
|
|
|
|
v-model="btStore.freqAI.enabled"
|
|
|
|
></b-form-checkbox>
|
2022-12-20 06:13:08 +00:00
|
|
|
</b-form-group>
|
2022-12-20 18:44:14 +00:00
|
|
|
<b-form-group
|
2023-07-22 09:16:13 +00:00
|
|
|
v-if="btStore.freqAI.enabled"
|
2022-12-20 18:44:14 +00:00
|
|
|
label-cols-sm="5"
|
|
|
|
label="FreqAI identifier:"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="freqai-identifier"
|
|
|
|
>
|
|
|
|
<b-form-input
|
|
|
|
id="freqai-identifier"
|
2023-07-22 09:16:13 +00:00
|
|
|
v-model="btStore.freqAI.identifier"
|
2022-12-20 18:44:14 +00:00
|
|
|
placeholder="Use config default"
|
|
|
|
></b-form-input>
|
|
|
|
</b-form-group>
|
2022-12-20 18:11:31 +00:00
|
|
|
<b-form-group
|
2023-07-22 09:16:13 +00:00
|
|
|
v-if="btStore.freqAI.enabled"
|
2022-12-20 18:11:31 +00:00
|
|
|
label-cols-sm="5"
|
|
|
|
label="FreqAI Model"
|
|
|
|
label-align-sm="right"
|
|
|
|
label-for="freqai-model"
|
|
|
|
>
|
2023-07-22 09:16:13 +00:00
|
|
|
<FreqaiModelSelect
|
|
|
|
id="freqai-model"
|
|
|
|
v-model="btStore.freqAI.model"
|
|
|
|
></FreqaiModelSelect>
|
2022-12-20 18:11:31 +00:00
|
|
|
</b-form-group>
|
2022-12-20 06:13:08 +00:00
|
|
|
</template>
|
2021-01-06 19:25:38 +00:00
|
|
|
|
2020-12-08 18:35:06 +00:00
|
|
|
<!-- <b-form-group label-cols-sm="5" label="Fee:" label-align-sm="right" label-for="fee">
|
2020-12-05 15:32:44 +00:00
|
|
|
<b-form-input
|
|
|
|
id="fee"
|
|
|
|
type="number"
|
|
|
|
placeholder="Use exchange default"
|
|
|
|
step="0.01"
|
|
|
|
></b-form-input>
|
2020-12-08 18:35:06 +00:00
|
|
|
</b-form-group> -->
|
2021-05-24 09:03:36 +00:00
|
|
|
<hr />
|
2023-07-22 09:15:17 +00:00
|
|
|
<TimeRangeSelect v-model="btStore.timerange" class="mt-2"></TimeRangeSelect>
|
2020-09-25 04:22:34 +00:00
|
|
|
</b-form-group>
|
2020-12-05 15:32:44 +00:00
|
|
|
</b-card>
|
|
|
|
|
2021-01-06 12:13:02 +00:00
|
|
|
<h3 class="mt-3">Backtesting summary</h3>
|
2021-05-24 09:34:48 +00:00
|
|
|
<div
|
|
|
|
class="d-flex flex-wrap flex-md-nowrap justify-content-between justify-content-md-center"
|
|
|
|
>
|
2021-01-06 12:13:02 +00:00
|
|
|
<b-button
|
2022-04-12 18:52:48 +00:00
|
|
|
id="start-backtest"
|
2021-01-06 12:13:02 +00:00
|
|
|
variant="primary"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="botStore.activeBot.backtestRunning || !botStore.activeBot.canRunBacktest"
|
2021-01-06 12:13:02 +00:00
|
|
|
class="mx-1"
|
|
|
|
@click="clickBacktest"
|
|
|
|
>
|
2020-12-05 15:32:44 +00:00
|
|
|
Start backtest
|
|
|
|
</b-button>
|
2021-01-06 12:13:02 +00:00
|
|
|
<b-button
|
|
|
|
variant="primary"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="botStore.activeBot.backtestRunning || !botStore.activeBot.canRunBacktest"
|
2021-01-06 12:13:02 +00:00
|
|
|
class="mx-1"
|
2022-04-19 05:05:34 +00:00
|
|
|
@click="botStore.activeBot.pollBacktest"
|
2021-01-06 12:13:02 +00:00
|
|
|
>
|
2020-12-05 15:32:44 +00:00
|
|
|
Load backtest result
|
|
|
|
</b-button>
|
2021-04-05 17:59:14 +00:00
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
class="mx-1"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="!botStore.activeBot.backtestRunning"
|
|
|
|
@click="botStore.activeBot.stopBacktest"
|
2021-04-24 14:51:28 +00:00
|
|
|
>Stop Backtest</b-button
|
2021-04-05 17:59:14 +00:00
|
|
|
>
|
2021-04-02 05:10:11 +00:00
|
|
|
<b-button
|
|
|
|
variant="primary"
|
|
|
|
class="mx-1"
|
2022-04-19 05:05:34 +00:00
|
|
|
:disabled="botStore.activeBot.backtestRunning || !botStore.activeBot.canRunBacktest"
|
|
|
|
@click="botStore.activeBot.removeBacktest"
|
2021-04-02 05:10:11 +00:00
|
|
|
>Reset Backtest</b-button
|
|
|
|
>
|
2020-12-05 15:32:44 +00:00
|
|
|
</div>
|
2020-09-25 04:22:34 +00:00
|
|
|
</div>
|
2021-03-11 18:17:09 +00:00
|
|
|
<BacktestResultView
|
|
|
|
v-if="hasBacktestResult && btFormMode == 'results'"
|
2022-04-19 05:05:34 +00:00
|
|
|
:backtest-result="botStore.activeBot.selectedBacktestResult"
|
2021-03-11 18:17:09 +00:00
|
|
|
class="flex-fill"
|
2020-11-01 12:58:16 +00:00
|
|
|
/>
|
2021-03-11 18:17:09 +00:00
|
|
|
|
2022-09-15 18:16:06 +00:00
|
|
|
<BacktestGraphsView
|
2021-03-11 18:17:09 +00:00
|
|
|
v-if="hasBacktestResult && btFormMode == 'visualize-summary'"
|
2022-09-15 18:16:06 +00:00
|
|
|
:trades="botStore.activeBot.selectedBacktestResult.trades"
|
|
|
|
/>
|
2020-11-01 12:58:16 +00:00
|
|
|
</div>
|
2021-03-11 18:17:09 +00:00
|
|
|
|
2020-12-05 16:42:22 +00:00
|
|
|
<div
|
|
|
|
v-if="hasBacktestResult && btFormMode == 'visualize'"
|
2021-06-25 18:00:40 +00:00
|
|
|
class="container-fluid text-center w-100 mt-2"
|
2020-12-05 16:42:22 +00:00
|
|
|
>
|
2022-10-30 11:55:14 +00:00
|
|
|
<BacktestResultChart
|
|
|
|
:timeframe="timeframe"
|
2023-07-22 09:11:07 +00:00
|
|
|
:strategy="btStore.strategy"
|
2023-07-22 09:15:17 +00:00
|
|
|
:timerange="btStore.timerange"
|
2022-10-30 11:55:14 +00:00
|
|
|
:pairlist="botStore.activeBot.selectedBacktestResult.pairlist"
|
|
|
|
:trades="botStore.activeBot.selectedBacktestResult.trades"
|
2023-07-22 09:16:13 +00:00
|
|
|
:freqai-model="btStore.freqAI.enabled ? btStore.freqAI.model : undefined"
|
2022-10-30 11:55:14 +00:00
|
|
|
/>
|
2020-07-26 17:35:56 +00:00
|
|
|
</div>
|
2020-07-26 11:44:34 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
<script setup lang="ts">
|
2020-07-26 11:44:34 +00:00
|
|
|
import TimeRangeSelect from '@/components/ftbot/TimeRangeSelect.vue';
|
2020-07-26 17:35:56 +00:00
|
|
|
import BacktestResultView from '@/components/ftbot/BacktestResultView.vue';
|
2021-01-20 06:55:56 +00:00
|
|
|
import BacktestResultSelect from '@/components/ftbot/BacktestResultSelect.vue';
|
2021-05-24 09:13:11 +00:00
|
|
|
import StrategySelect from '@/components/ftbot/StrategySelect.vue';
|
2022-12-20 06:13:08 +00:00
|
|
|
import FreqaiModelSelect from '@/components/ftbot/FreqaiModelSelect.vue';
|
2021-05-23 14:54:38 +00:00
|
|
|
import TimeframeSelect from '@/components/ftbot/TimeframeSelect.vue';
|
2022-04-12 05:18:35 +00:00
|
|
|
import BacktestHistoryLoad from '@/components/ftbot/BacktestHistoryLoad.vue';
|
2022-09-15 18:16:06 +00:00
|
|
|
import BacktestGraphsView from '@/components/ftbot/BacktestGraphsView.vue';
|
2022-10-30 11:02:48 +00:00
|
|
|
import BacktestResultChart from '@/components/ftbot/BacktestResultChart.vue';
|
2022-12-20 06:18:49 +00:00
|
|
|
import InfoBox from '@/components/general/InfoBox.vue';
|
2020-07-26 17:35:56 +00:00
|
|
|
|
2022-10-30 11:02:48 +00:00
|
|
|
import { BacktestPayload } from '@/types';
|
2020-07-27 05:19:45 +00:00
|
|
|
|
2021-01-14 07:04:28 +00:00
|
|
|
import { formatPercent } from '@/shared/formatters';
|
2022-12-20 06:02:47 +00:00
|
|
|
import { computed, ref, onMounted, watch } from 'vue';
|
2022-04-19 05:05:34 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2023-07-22 09:11:07 +00:00
|
|
|
import { useBtStore } from '@/stores/btStore';
|
2020-07-26 11:44:34 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const botStore = useBotStore();
|
2023-07-22 09:11:07 +00:00
|
|
|
const btStore = useBtStore();
|
2022-04-16 12:30:33 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const hasBacktestResult = computed(() =>
|
|
|
|
botStore.activeBot.backtestHistory
|
|
|
|
? Object.keys(botStore.activeBot.backtestHistory).length !== 0
|
|
|
|
: false,
|
|
|
|
);
|
|
|
|
const timeframe = computed((): string => {
|
|
|
|
try {
|
|
|
|
return botStore.activeBot.selectedBacktestResult.timeframe;
|
|
|
|
} catch (err) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
});
|
2022-04-16 12:30:33 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const showLeftBar = ref(false);
|
|
|
|
const enableProtections = ref(false);
|
|
|
|
const stakeAmountUnlimited = ref(false);
|
2022-12-20 18:21:23 +00:00
|
|
|
const allowCache = ref(true);
|
2022-12-20 06:02:47 +00:00
|
|
|
const maxOpenTrades = ref('');
|
|
|
|
const stakeAmount = ref('');
|
|
|
|
const startingCapital = ref('');
|
|
|
|
const btFormMode = ref('run');
|
|
|
|
const pollInterval = ref<number | null>(null);
|
2022-04-16 12:30:33 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const selectBacktestResult = () => {
|
|
|
|
// Set parameters for this result
|
2023-07-22 09:11:07 +00:00
|
|
|
btStore.strategy = botStore.activeBot.selectedBacktestResult.strategy_name;
|
|
|
|
botStore.activeBot.getStrategy(btStore.strategy);
|
2023-07-22 09:13:35 +00:00
|
|
|
btStore.selectedTimeframe = botStore.activeBot.selectedBacktestResult.timeframe;
|
|
|
|
btStore.selectedDetailTimeframe =
|
|
|
|
botStore.activeBot.selectedBacktestResult.timeframe_detail || '';
|
2023-04-10 16:20:09 +00:00
|
|
|
// TODO: maybe this should not use timerange, but the actual backtest start/end results instead?
|
2023-07-22 09:15:17 +00:00
|
|
|
btStore.timerange = botStore.activeBot.selectedBacktestResult.timerange;
|
2022-12-20 06:02:47 +00:00
|
|
|
};
|
2022-09-14 18:44:29 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
watch(
|
|
|
|
() => botStore.activeBot.selectedBacktestResultKey,
|
|
|
|
() => {
|
|
|
|
selectBacktestResult();
|
|
|
|
},
|
|
|
|
);
|
2021-02-17 19:37:30 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const clickBacktest = () => {
|
|
|
|
const btPayload: BacktestPayload = {
|
2023-07-22 09:11:07 +00:00
|
|
|
strategy: btStore.strategy,
|
2023-07-22 09:15:17 +00:00
|
|
|
timerange: btStore.timerange,
|
2022-12-20 06:02:47 +00:00
|
|
|
enable_protections: enableProtections.value,
|
|
|
|
};
|
|
|
|
const openTradesInt = parseInt(maxOpenTrades.value, 10);
|
|
|
|
if (openTradesInt) {
|
|
|
|
btPayload.max_open_trades = openTradesInt;
|
|
|
|
}
|
|
|
|
if (stakeAmountUnlimited.value) {
|
|
|
|
btPayload.stake_amount = 'unlimited';
|
|
|
|
} else {
|
|
|
|
const stakeAmountLoc = Number(stakeAmount.value);
|
|
|
|
if (stakeAmountLoc) {
|
|
|
|
btPayload.stake_amount = stakeAmountLoc.toString();
|
|
|
|
}
|
|
|
|
}
|
2020-12-08 18:35:06 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
const startingCapitalLoc = Number(startingCapital.value);
|
|
|
|
if (startingCapitalLoc) {
|
|
|
|
btPayload.dry_run_wallet = startingCapitalLoc;
|
|
|
|
}
|
2020-07-26 11:44:34 +00:00
|
|
|
|
2023-07-22 09:13:35 +00:00
|
|
|
if (btStore.selectedTimeframe) {
|
|
|
|
btPayload.timeframe = btStore.selectedTimeframe;
|
2022-12-20 06:02:47 +00:00
|
|
|
}
|
2023-07-22 09:13:35 +00:00
|
|
|
if (btStore.selectedDetailTimeframe) {
|
|
|
|
btPayload.timeframe_detail = btStore.selectedDetailTimeframe;
|
2022-12-20 06:02:47 +00:00
|
|
|
}
|
2022-12-20 18:21:23 +00:00
|
|
|
if (!allowCache.value) {
|
|
|
|
btPayload.backtest_cache = 'none';
|
|
|
|
}
|
2023-07-22 09:16:13 +00:00
|
|
|
if (btStore.freqAI.enabled) {
|
|
|
|
btPayload.freqaimodel = btStore.freqAI.model;
|
|
|
|
if (btStore.freqAI.identifier !== '') {
|
|
|
|
btPayload.freqai = { identifier: btStore.freqAI.identifier };
|
2022-12-20 18:44:14 +00:00
|
|
|
}
|
2022-12-20 06:13:08 +00:00
|
|
|
}
|
2022-08-01 00:58:50 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
botStore.activeBot.startBacktest(btPayload);
|
|
|
|
};
|
2022-04-19 05:05:34 +00:00
|
|
|
|
2022-12-20 06:02:47 +00:00
|
|
|
onMounted(() => botStore.activeBot.getState());
|
|
|
|
watch(
|
|
|
|
() => botStore.activeBot.backtestRunning,
|
|
|
|
() => {
|
|
|
|
if (botStore.activeBot.backtestRunning === true) {
|
|
|
|
pollInterval.value = window.setInterval(botStore.activeBot.pollBacktest, 1000);
|
|
|
|
} else if (pollInterval.value) {
|
|
|
|
clearInterval(pollInterval.value);
|
|
|
|
pollInterval.value = null;
|
|
|
|
}
|
2022-04-16 12:30:33 +00:00
|
|
|
},
|
2022-12-20 06:02:47 +00:00
|
|
|
);
|
2020-07-26 11:44:34 +00:00
|
|
|
</script>
|
|
|
|
|
2021-05-24 09:34:48 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-01-21 06:47:51 +00:00
|
|
|
.bt-running-label {
|
|
|
|
position: absolute;
|
|
|
|
right: 2em;
|
|
|
|
margin-top: 1em;
|
|
|
|
}
|
2021-03-11 18:17:09 +00:00
|
|
|
|
|
|
|
.sticky-offset {
|
|
|
|
top: 2em;
|
|
|
|
}
|
2021-05-24 09:34:48 +00:00
|
|
|
.flex-samesize-items {
|
|
|
|
flex: 1 1 0;
|
|
|
|
@media md {
|
|
|
|
flex: unset;
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 18:46:24 +00:00
|
|
|
|
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: all 0.2s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fade-enter,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2021-07-06 04:56:41 +00:00
|
|
|
|
|
|
|
.bt-config {
|
|
|
|
@media (min-width: 992px) {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
max-width: 75vw;
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 18:28:48 +00:00
|
|
|
</style>
|