From d935a8910008dc0dae2ac9c91d481104fe392091 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:07:03 +0200 Subject: [PATCH 01/13] Add BtStore --- src/stores/btStore.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/stores/btStore.ts diff --git a/src/stores/btStore.ts b/src/stores/btStore.ts new file mode 100644 index 00000000..748d6f14 --- /dev/null +++ b/src/stores/btStore.ts @@ -0,0 +1,17 @@ +import { defineStore } from 'pinia'; + +export const useBtStore = defineStore('btStore', { + state: () => { + return { + strategy: '', + selectedTimeframe: '', + freqAI: { + enabled: false, + model: '', + identifier: '', + }, + }; + }, + getters: {}, + actions: {}, +}); From 359934f4bc2c9966dbf2cd68d0cb6e2271970742 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:11:07 +0200 Subject: [PATCH 02/13] Move strategy to btStore --- src/views/BacktestingView.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/views/BacktestingView.vue b/src/views/BacktestingView.vue index 344f8a97..a55142d8 100644 --- a/src/views/BacktestingView.vue +++ b/src/views/BacktestingView.vue @@ -99,7 +99,7 @@
Strategy - +
@@ -312,7 +312,7 @@ > botStore.activeBot.backtestHistory @@ -355,7 +357,6 @@ const timeframe = computed((): string => { } }); -const strategy = ref(''); const selectedTimeframe = ref(''); const selectedDetailTimeframe = ref(''); const timerange = ref(''); @@ -376,8 +377,8 @@ const pollInterval = ref(null); const selectBacktestResult = () => { // Set parameters for this result - strategy.value = botStore.activeBot.selectedBacktestResult.strategy_name; - botStore.activeBot.getStrategy(strategy.value); + btStore.strategy = botStore.activeBot.selectedBacktestResult.strategy_name; + botStore.activeBot.getStrategy(btStore.strategy); selectedTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe; selectedDetailTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe_detail || ''; // TODO: maybe this should not use timerange, but the actual backtest start/end results instead? @@ -393,7 +394,7 @@ watch( const clickBacktest = () => { const btPayload: BacktestPayload = { - strategy: strategy.value, + strategy: btStore.strategy, timerange: timerange.value, enable_protections: enableProtections.value, }; From 888ba6faf86a3d3f4b768cb4bd9946b5f8c644b7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:13:35 +0200 Subject: [PATCH 03/13] Move Timeframe refs to btStore --- src/stores/btStore.ts | 1 + src/views/BacktestingView.vue | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/stores/btStore.ts b/src/stores/btStore.ts index 748d6f14..d18beaa0 100644 --- a/src/stores/btStore.ts +++ b/src/stores/btStore.ts @@ -5,6 +5,7 @@ export const useBtStore = defineStore('btStore', { return { strategy: '', selectedTimeframe: '', + selectedDetailTimeframe: '', freqAI: { enabled: false, model: '', diff --git a/src/views/BacktestingView.vue b/src/views/BacktestingView.vue index a55142d8..79a17cc7 100644 --- a/src/views/BacktestingView.vue +++ b/src/views/BacktestingView.vue @@ -116,7 +116,7 @@ label-align-sm="right" label-for="timeframe-select" > - + @@ -357,8 +357,6 @@ const timeframe = computed((): string => { } }); -const selectedTimeframe = ref(''); -const selectedDetailTimeframe = ref(''); const timerange = ref(''); const showLeftBar = ref(false); const freqAI = ref({ @@ -379,8 +377,9 @@ const selectBacktestResult = () => { // Set parameters for this result btStore.strategy = botStore.activeBot.selectedBacktestResult.strategy_name; botStore.activeBot.getStrategy(btStore.strategy); - selectedTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe; - selectedDetailTimeframe.value = botStore.activeBot.selectedBacktestResult.timeframe_detail || ''; + btStore.selectedTimeframe = botStore.activeBot.selectedBacktestResult.timeframe; + btStore.selectedDetailTimeframe = + botStore.activeBot.selectedBacktestResult.timeframe_detail || ''; // TODO: maybe this should not use timerange, but the actual backtest start/end results instead? timerange.value = botStore.activeBot.selectedBacktestResult.timerange; }; @@ -416,11 +415,11 @@ const clickBacktest = () => { btPayload.dry_run_wallet = startingCapitalLoc; } - if (selectedTimeframe.value) { - btPayload.timeframe = selectedTimeframe.value; + if (btStore.selectedTimeframe) { + btPayload.timeframe = btStore.selectedTimeframe; } - if (selectedDetailTimeframe.value) { - btPayload.timeframe_detail = selectedDetailTimeframe.value; + if (btStore.selectedDetailTimeframe) { + btPayload.timeframe_detail = btStore.selectedDetailTimeframe; } if (!allowCache.value) { btPayload.backtest_cache = 'none'; From 06f64c9ab9bd6736a60b83c6177683fc413acd08 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:15:17 +0200 Subject: [PATCH 04/13] Move Timerange to btStore --- src/stores/btStore.ts | 1 + src/views/BacktestingView.vue | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stores/btStore.ts b/src/stores/btStore.ts index d18beaa0..8977861a 100644 --- a/src/stores/btStore.ts +++ b/src/stores/btStore.ts @@ -6,6 +6,7 @@ export const useBtStore = defineStore('btStore', { strategy: '', selectedTimeframe: '', selectedDetailTimeframe: '', + timerange: '', freqAI: { enabled: false, model: '', diff --git a/src/views/BacktestingView.vue b/src/views/BacktestingView.vue index 79a17cc7..8ff9414e 100644 --- a/src/views/BacktestingView.vue +++ b/src/views/BacktestingView.vue @@ -253,7 +253,7 @@ > -->
- +
@@ -313,7 +313,7 @@ { } }); -const timerange = ref(''); const showLeftBar = ref(false); const freqAI = ref({ enabled: false, @@ -381,7 +380,7 @@ const selectBacktestResult = () => { btStore.selectedDetailTimeframe = botStore.activeBot.selectedBacktestResult.timeframe_detail || ''; // TODO: maybe this should not use timerange, but the actual backtest start/end results instead? - timerange.value = botStore.activeBot.selectedBacktestResult.timerange; + btStore.timerange = botStore.activeBot.selectedBacktestResult.timerange; }; watch( @@ -394,7 +393,7 @@ watch( const clickBacktest = () => { const btPayload: BacktestPayload = { strategy: btStore.strategy, - timerange: timerange.value, + timerange: btStore.timerange, enable_protections: enableProtections.value, }; const openTradesInt = parseInt(maxOpenTrades.value, 10); From 07798d2d216cf71c08b73ddd75d13a5bdb9ca81f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:16:13 +0200 Subject: [PATCH 05/13] freqAi to btStore --- src/views/BacktestingView.vue | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/views/BacktestingView.vue b/src/views/BacktestingView.vue index 8ff9414e..af5bb089 100644 --- a/src/views/BacktestingView.vue +++ b/src/views/BacktestingView.vue @@ -218,10 +218,13 @@ />
- + - + @@ -316,7 +322,7 @@ :timerange="btStore.timerange" :pairlist="botStore.activeBot.selectedBacktestResult.pairlist" :trades="botStore.activeBot.selectedBacktestResult.trades" - :freqai-model="freqAI.enabled ? freqAI.model : undefined" + :freqai-model="btStore.freqAI.enabled ? btStore.freqAI.model : undefined" /> @@ -358,11 +364,6 @@ const timeframe = computed((): string => { }); const showLeftBar = ref(false); -const freqAI = ref({ - enabled: false, - model: '', - identifier: '', -}); const enableProtections = ref(false); const stakeAmountUnlimited = ref(false); const allowCache = ref(true); @@ -423,10 +424,10 @@ const clickBacktest = () => { if (!allowCache.value) { btPayload.backtest_cache = 'none'; } - if (freqAI.value.enabled) { - btPayload.freqaimodel = freqAI.value.model; - if (freqAI.value.identifier !== '') { - btPayload.freqai = { identifier: freqAI.value.identifier }; + if (btStore.freqAI.enabled) { + btPayload.freqaimodel = btStore.freqAI.model; + if (btStore.freqAI.identifier !== '') { + btPayload.freqai = { identifier: btStore.freqAI.identifier }; } } From 2d3f1c73918206eef846cc3fa78693d63b4e58cb Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 22 Jul 2023 11:18:04 +0200 Subject: [PATCH 06/13] More refs to btStore --- src/stores/btStore.ts | 4 ++++ src/views/BacktestingView.vue | 21 +++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/stores/btStore.ts b/src/stores/btStore.ts index 8977861a..47344650 100644 --- a/src/stores/btStore.ts +++ b/src/stores/btStore.ts @@ -7,6 +7,10 @@ export const useBtStore = defineStore('btStore', { selectedTimeframe: '', selectedDetailTimeframe: '', timerange: '', + maxOpenTrades: '', + stakeAmount: '', + startingCapital: '', + allowCache: true, freqAI: { enabled: false, model: '', diff --git a/src/views/BacktestingView.vue b/src/views/BacktestingView.vue index af5bb089..67c90a00 100644 --- a/src/views/BacktestingView.vue +++ b/src/views/BacktestingView.vue @@ -140,7 +140,7 @@ > @@ -153,7 +153,7 @@ > @@ -174,7 +174,7 @@ - +