From ac78a184149c1e9cb6328f0da7d14dbe59270154 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 23 May 2023 18:27:33 +0000 Subject: [PATCH 001/122] added pairlist configurator --- src/components/ftbot/PairlistConfigItem.vue | 68 ++++++++++ src/components/ftbot/PairlistConfigurator.vue | 117 ++++++++++++++++++ .../general/PairlistConfigParameter.vue | 51 ++++++++ src/components/layout/NavBar.vue | 3 + src/router/index.ts | 5 + src/stores/ftbot.ts | 40 +++++- src/types/types.ts | 49 ++++++++ src/views/PairlistConfigView.vue | 108 ++++++++++++++++ 8 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 src/components/ftbot/PairlistConfigItem.vue create mode 100644 src/components/ftbot/PairlistConfigurator.vue create mode 100644 src/components/general/PairlistConfigParameter.vue create mode 100644 src/views/PairlistConfigView.vue diff --git a/src/components/ftbot/PairlistConfigItem.vue b/src/components/ftbot/PairlistConfigItem.vue new file mode 100644 index 00000000..a87a2288 --- /dev/null +++ b/src/components/ftbot/PairlistConfigItem.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue new file mode 100644 index 00000000..b27fc135 --- /dev/null +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -0,0 +1,117 @@ + + + diff --git a/src/components/general/PairlistConfigParameter.vue b/src/components/general/PairlistConfigParameter.vue new file mode 100644 index 00000000..15728293 --- /dev/null +++ b/src/components/general/PairlistConfigParameter.vue @@ -0,0 +1,51 @@ + + + diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue index 20da8173..8298f313 100644 --- a/src/components/layout/NavBar.vue +++ b/src/components/layout/NavBar.vue @@ -23,6 +23,9 @@ Backtest + Pairlist Config diff --git a/src/router/index.ts b/src/router/index.ts index 04eb7e9d..d543fe84 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -67,6 +67,11 @@ const routes: Array = [ allowAnonymous: true, }, }, + { + path: '/pairlist_config', + name: 'Pairlist Configuration', + component: () => import('@/views/PairlistConfigView.vue'), + }, { path: '/(.*)*', name: '404', diff --git a/src/stores/ftbot.ts b/src/stores/ftbot.ts index ed12ef2b..87f0f779 100644 --- a/src/stores/ftbot.ts +++ b/src/stores/ftbot.ts @@ -42,7 +42,12 @@ import { showAlert } from './alerts'; import { useWebSocket } from '@vueuse/core'; import { FTWsMessage, FtWsMessageTypes } from '@/types/wsMessageTypes'; import { showNotification } from '@/shared/notifications'; -import { FreqAIModelListResult } from '../types/types'; +import { + FreqAIModelListResult, + PairlistEvalResponse, + PairlistsPayload, + PairlistsResponse, +} from '../types/types'; export function createBotSubStore(botId: string, botName: string) { const userService = useUserService(botId); @@ -535,6 +540,24 @@ export function createBotSubStore(botId: string, botName: string) { return Promise.reject(error); } }, + async getPairlists() { + try { + const { data } = await api.get('/pairlists/available'); + return Promise.resolve(data); + } catch (error) { + console.error(error); + return Promise.reject(error); + } + }, + async getPairlistEvalStatus() { + try { + const { data } = await api.get('/pairlists/evaluate'); + return Promise.resolve(data); + } catch (error) { + console.error(error); + return Promise.reject(error); + } + }, // // Post methods // // TODO: Migrate calls to API to a seperate module unrelated to pinia? async startBot() { @@ -938,6 +961,21 @@ export function createBotSubStore(botId: string, botName: string) { }, ); }, + async evaluatePairlist(payload: PairlistsPayload) { + try { + const { data } = await api.post>( + '/pairlists/evaluate', + payload, + ); + return Promise.resolve(data); + } catch (error) { + if (axios.isAxiosError(error)) { + console.error(error.response); + } + showAlert('Error testing pairlist', 'danger'); + return Promise.reject(error); + } + }, }, }); diff --git a/src/types/types.ts b/src/types/types.ts index e51a3186..5661ff83 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -271,3 +271,52 @@ export enum LoadingStatus { success, error, } + +export interface PairlistsResponse { + pairlists: Pairlist[]; +} + +export interface PairlistEvalResponse { + detail?: string; + method?: string[]; + whitelist?: string[]; +} + +export interface Pairlist { + id?: string; + is_pairlist_generator: boolean; + name: string; + params: Record; +} + +export interface PairlistConfig { + name: string; + pairlists: Pairlist[]; +} + +export enum PairlistParamType { + string = 'string', + number = 'number', + boolean = 'boolean', + option = 'option', +} + +export interface PairlistParameter { + description: string; + help: string; + type: PairlistParamType; + value?: string; + default: string; + options?: string[]; +} + +export interface PairlistPayloadItem { + method: string; + [key: string]: string | number | boolean; +} + +export interface PairlistsPayload { + pairlists: PairlistPayloadItem[]; + blacklist: string[]; + stake_currency: string; +} diff --git a/src/views/PairlistConfigView.vue b/src/views/PairlistConfigView.vue new file mode 100644 index 00000000..1fb0b496 --- /dev/null +++ b/src/views/PairlistConfigView.vue @@ -0,0 +1,108 @@ + + + From 257a57fcf2091c374f5cba7a96dca983b8e89419 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 23 May 2023 18:43:16 +0000 Subject: [PATCH 002/122] replace sorting icon --- src/components/ftbot/PairlistConfigItem.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ftbot/PairlistConfigItem.vue b/src/components/ftbot/PairlistConfigItem.vue index a87a2288..f7477b85 100644 --- a/src/components/ftbot/PairlistConfigItem.vue +++ b/src/components/ftbot/PairlistConfigItem.vue @@ -4,7 +4,7 @@ - +
{{ pairlist.name }}
@@ -34,7 +34,6 @@ import { Pairlist } from '@/types'; import { computed, ref } from 'vue'; import PairlistConfigParameter from '../general/PairlistConfigParameter.vue'; -import ReorderIcon from 'vue-material-design-icons/ReorderHorizontal.vue'; const props = defineProps<{ modelValue: Pairlist; From e8c50a167a042763de10ece5c68632837d577496 Mon Sep 17 00:00:00 2001 From: Tako Date: Wed, 24 May 2023 18:19:46 +0000 Subject: [PATCH 003/122] drag and drop configurator prototype --- src/components/ftbot/PairlistConfigurator.vue | 160 +++++++++++------- src/views/PairlistConfigView.vue | 58 +++---- 2 files changed, 126 insertions(+), 92 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index b27fc135..84b785f8 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -1,36 +1,59 @@ + + diff --git a/src/views/PairlistConfigView.vue b/src/views/PairlistConfigView.vue index 1fb0b496..dd3c694b 100644 --- a/src/views/PairlistConfigView.vue +++ b/src/views/PairlistConfigView.vue @@ -2,17 +2,12 @@
- Configure Test - - +
+ {{ whitelist }} +
+
-

{{ progressMessage }}

-
{{ whitelist }}
@@ -23,7 +18,6 @@ import PairlistConfigurator from '@/components/ftbot/PairlistConfigurator.vue'; import { PairlistConfig, PairlistParamType, PairlistPayloadItem } from '@/types'; const botStore = useBotStore(); -const showConfigurator = ref(false); const configs = ref([]); const selectedConfig = ref({ name: '', pairlists: [] }); const whitelist = ref([]); @@ -57,26 +51,7 @@ const configsSelectOptions = computed(() => { const test = async () => { if (!selectedConfig.value) return; - const pairlists: PairlistPayloadItem[] = []; - - selectedConfig.value.pairlists.forEach((config) => { - const pairlist = { - method: config.name, - }; - for (const key in config.params) { - const param = config.params[key]; - if (param.value) { - pairlist[key] = convertToParamType(param.type, param.value); - } - } - pairlists.push(pairlist); - }); - - const payload = { - pairlists: pairlists, - stake_currency: botStore.activeBot.stakeCurrency, - blacklist: [], - }; + const payload = configToPayload(); evaluating.value = true; whitelist.value = []; @@ -105,4 +80,27 @@ const convertToParamType = (type: PairlistParamType, value: string) => { return String(value); } }; + +const configToPayload = () => { + const pairlists: PairlistPayloadItem[] = []; + + selectedConfig.value.pairlists.forEach((config) => { + const pairlist = { + method: config.name, + }; + for (const key in config.params) { + const param = config.params[key]; + if (param.value) { + pairlist[key] = convertToParamType(param.type, param.value); + } + } + pairlists.push(pairlist); + }); + + return { + pairlists: pairlists, + stake_currency: botStore.activeBot.stakeCurrency, + blacklist: [], + }; +}; From 2f07024f11894a81a063d5266ac02ab4f8805525 Mon Sep 17 00:00:00 2001 From: Tako Date: Wed, 24 May 2023 20:15:28 +0000 Subject: [PATCH 004/122] stop the timer and show error messages --- src/components/ftbot/PairlistConfigurator.vue | 2 +- src/types/types.ts | 9 ++++++--- src/views/PairlistConfigView.vue | 13 ++++++++----- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 84b785f8..6aa0c495 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -136,7 +136,7 @@ watch( From 078878df3fbae911b2f8f6503745c54d1d59d87b Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 29 May 2023 15:07:54 +0200 Subject: [PATCH 061/122] Improve copy button behavior --- src/components/general/CopyableTextfield.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/general/CopyableTextfield.vue b/src/components/general/CopyableTextfield.vue index b37dc9c9..83819171 100644 --- a/src/components/general/CopyableTextfield.vue +++ b/src/components/general/CopyableTextfield.vue @@ -1,9 +1,9 @@ diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 2c301d18..504cf4fa 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -64,6 +64,7 @@
+ - +
@@ -97,7 +100,7 @@ import { useBotStore } from '@/stores/ftbotwrapper'; import { usePairlistConfigStore } from '@/stores/pairlistConfig'; import PairlistConfigItem from './PairlistConfigItem.vue'; import PairlistConfigBlacklist from './PairlistConfigBlacklist.vue'; -import { Pairlist, PairlistParamType, PairlistPayloadItem } from '@/types'; +import { Pairlist } from '@/types'; import { useSortable, moveArrayElement } from '@vueuse/integrations/useSortable'; import CopyableTextfield from '@/components/general/CopyableTextfield.vue'; @@ -119,10 +122,6 @@ const pairlistsComp = computed(() => }), ); -const configJSON = computed(() => { - return JSON.stringify(configToPayloadItems(), null, 2); -}); - useSortable(availablePairlistsEl, availablePairlists.value, { group: { name: 'configurator', @@ -161,45 +160,7 @@ onMounted(async () => { }); async function evaluateClick() { - const payload = configToPayload(); - pairlistStore.startPairlistEvaluation(payload); -} - -function convertToParamType(type: PairlistParamType, value: string) { - if (type === PairlistParamType.number) { - return Number(value); - } else if (type === PairlistParamType.boolean) { - return Boolean(value); - } else { - return String(value); - } -} - -function configToPayload() { - const pairlists: PairlistPayloadItem[] = configToPayloadItems(); - return { - pairlists: pairlists, - stake_currency: botStore.activeBot.stakeCurrency, - blacklist: pairlistStore.blacklist, - }; -} - -function configToPayloadItems() { - const pairlists: PairlistPayloadItem[] = []; - pairlistStore.config.pairlists.forEach((config) => { - const pairlist = { - method: config.name, - }; - for (const key in config.params) { - const param = config.params[key]; - if (param.value) { - pairlist[key] = convertToParamType(param.type, param.value); - } - } - pairlists.push(pairlist); - }); - - return pairlists; + pairlistStore.startPairlistEvaluation(); } diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index db468050..923709b8 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -1,7 +1,13 @@ import { defineStore } from 'pinia'; import { useBotStore } from './ftbotwrapper'; -import { Pairlist, PairlistConfig, PairlistsPayload } from '@/types'; +import { + Pairlist, + PairlistConfig, + PairlistParamType, + PairlistPayloadItem, + PairlistsPayload, +} from '@/types'; import { computed, ref, toRaw } from 'vue'; import { showAlert } from './alerts'; @@ -29,23 +35,9 @@ export const usePairlistConfigStore = defineStore( return firstPairlistIsGenerator.value && config.value.pairlists.length > 0; }); - async function startPairlistEvaluation(payload: PairlistsPayload) { - evaluating.value = true; - await botStore.activeBot.evaluatePairlist(payload); - - intervalId.value = setInterval(async () => { - const res = await botStore.activeBot.getPairlistEvalStatus(); - if (res.status === 'success' && res.result) { - clearInterval(intervalId.value); - evaluating.value = false; - whitelist.value = res.result.whitelist; - } else if (res.error) { - showAlert(res.error, 'danger'); - clearInterval(intervalId.value); - evaluating.value = false; - } - }, 1000); - } + const configJSON = computed(() => { + return JSON.stringify(configToPayloadItems(), null, 2); + }); function addToConfig(pairlist: Pairlist, index: number) { pairlist = structuredClone(toRaw(pairlist)); @@ -87,10 +79,68 @@ export const usePairlistConfigStore = defineStore( blacklist.value.splice(index, 1); } + async function startPairlistEvaluation() { + const payload: PairlistsPayload = configToPayload(); + + evaluating.value = true; + await botStore.activeBot.evaluatePairlist(payload); + + intervalId.value = setInterval(async () => { + const res = await botStore.activeBot.getPairlistEvalStatus(); + if (res.status === 'success' && res.result) { + clearInterval(intervalId.value); + evaluating.value = false; + whitelist.value = res.result.whitelist; + } else if (res.error) { + showAlert(res.error, 'danger'); + clearInterval(intervalId.value); + evaluating.value = false; + } + }, 1000); + } + + function convertToParamType(type: PairlistParamType, value: string) { + if (type === PairlistParamType.number) { + return Number(value); + } else if (type === PairlistParamType.boolean) { + return Boolean(value); + } else { + return String(value); + } + } + + function configToPayload() { + const pairlists: PairlistPayloadItem[] = configToPayloadItems(); + return { + pairlists: pairlists, + stake_currency: botStore.activeBot.stakeCurrency, + blacklist: blacklist.value, + }; + } + + function configToPayloadItems() { + const pairlists: PairlistPayloadItem[] = []; + config.value.pairlists.forEach((config) => { + const pairlist = { + method: config.name, + }; + for (const key in config.params) { + const param = config.params[key]; + if (param.value) { + pairlist[key] = convertToParamType(param.type, param.value); + } + } + pairlists.push(pairlist); + }); + + return pairlists; + } + return { evaluating, whitelist, config, + configJSON, savedConfigs, blacklist, startPairlistEvaluation, From 53a8e988f86c319e3d59b0d571d251743eccc7bc Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 30 May 2023 12:01:19 +0000 Subject: [PATCH 069/122] prepend config action buttons --- src/components/ftbot/PairlistConfigurator.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index cc22d696..4e1d9c36 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -42,15 +42,15 @@ >{{ config.name }} + + From ee3cf53e6bfa4a04c470d794f2ada710b701b507 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 30 May 2023 15:44:38 +0000 Subject: [PATCH 071/122] deleting configs --- src/stores/pairlistConfig.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index 923709b8..53a9cfb3 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -63,6 +63,15 @@ export const usePairlistConfigStore = defineStore( } } + function deleteConfig() { + const i = savedConfigs.value.findIndex((c) => c.name === config.value.name); + console.log(i); + if (i > -1) { + savedConfigs.value.splice(i, 1); + config.value = { name: '', pairlists: [] }; + } + } + function newConfig() { config.value = { name: '', pairlists: [] }; } @@ -147,6 +156,7 @@ export const usePairlistConfigStore = defineStore( addToConfig, removeFromConfig, saveConfig, + deleteConfig, selectConfig, newConfig, addToBlacklist, From 954100eb636f9cd780ad9e9805ffe634adb6d882 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 30 May 2023 15:45:03 +0000 Subject: [PATCH 072/122] added PairlistConfigActions component --- .../ftbot/PairlistConfigActions.vue | 48 +++++++++++++++++++ src/components/ftbot/PairlistConfigurator.vue | 42 +--------------- 2 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 src/components/ftbot/PairlistConfigActions.vue diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue new file mode 100644 index 00000000..0827d805 --- /dev/null +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -0,0 +1,48 @@ + + diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 264ee53a..8225c1df 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -32,42 +32,7 @@
- - - - - - - + From 37c06453dfb05a0848e720b11aefa75cbe41e466 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 30 May 2023 15:51:19 +0000 Subject: [PATCH 073/122] hide config delete button if not saved --- src/components/ftbot/PairlistConfigActions.vue | 2 +- src/stores/pairlistConfig.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue index 0827d805..6076e6e9 100644 --- a/src/components/ftbot/PairlistConfigActions.vue +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -2,7 +2,7 @@ - diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 076d7db8..8228bc65 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -25,6 +25,7 @@
+ ({ + exchange: '', +}); const availablePairlists = ref([]); const pairlistConfigsEl = ref(null); diff --git a/src/types/exchange.ts b/src/types/exchange.ts index adcec421..c7fe4384 100644 --- a/src/types/exchange.ts +++ b/src/types/exchange.ts @@ -16,3 +16,8 @@ export interface Exchange { export interface ExchangeListResult { exchanges: Exchange[]; } + +export interface ExchangeSelection { + exchange: string; + trade_mode?: TradeMode; +} From 35a81a8d9bf1981776d1177c3dbe574a5d5e6708 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Jun 2023 13:41:14 +0200 Subject: [PATCH 099/122] Allow exchange selection for pairlist config --- src/components/ftbot/PairlistConfigurator.vue | 14 +++-- src/stores/pairlistConfig.ts | 57 ++++++++++++++----- src/types/exchange.ts | 2 +- src/types/pairlists.ts | 3 +- 4 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 8228bc65..49ffa550 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -25,8 +25,15 @@
- + Custom Exchange + import { useBotStore } from '@/stores/ftbotwrapper'; -import { computed, onMounted } from 'vue'; +import { computed, onMounted, watch } from 'vue'; import { ExchangeSelection } from '@/types'; const exchangeModel = defineModel({ @@ -44,20 +44,33 @@ const exchangeList = computed(() => { .map((e) => e.name); }); -const tradeModes = computed[]>(() => { - const val = botStore.activeBot.exchangeList - .find((ex) => ex.name === exchangeModel.value.exchange) - ?.trade_modes.map((tm) => { - return ( - { - text: `${tm.margin_mode} ${tm.trading_mode}`, - value: tm, - } ?? [] - ); - }); - return (val ?? []) as Record[]; +const tradeModesTyped = computed(() => { + const val = botStore.activeBot.exchangeList.find( + (ex) => ex.name === exchangeModel.value.exchange, + )?.trade_modes; + return val ?? []; }); +const tradeModes = computed[]>(() => { + return tradeModesTyped.value.map((tm) => { + return ( + { + text: `${tm.margin_mode} ${tm.trading_mode}`, + value: tm, + } ?? [] + ); + }) as Record[]; +}); + +watch( + () => exchangeModel.value.exchange, + () => { + if (tradeModesTyped.value.length < 2) { + exchangeModel.value.trade_mode = tradeModesTyped.value[0]; + } + }, +); + onMounted(() => { if (botStore.activeBot.exchangeList.length === 0) { botStore.activeBot.getExchangeList(); diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index c93a7a5b..d9935bc2 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -26,10 +26,13 @@ export const usePairlistConfigStore = defineStore( const blacklist = ref([]); const customExchange = ref(false); const selectedExchange = ref({ - exchange: '', + exchange: botStore.activeBot?.botState.exchange ?? '', trade_mode: { - trading_mode: TradingMode.SPOT, - margin_mode: MarginMode.NONE, + trading_mode: botStore.activeBot?.botState.trading_mode ?? TradingMode.SPOT, + margin_mode: + botStore.activeBot?.botState.trading_mode === TradingMode.FUTURES + ? MarginMode.ISOLATED + : MarginMode.NONE, }, }); diff --git a/src/types/types.ts b/src/types/types.ts index 64c13465..887f62b1 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -81,7 +81,7 @@ export enum TradingMode { } export enum MarginMode { - NONE = 'none', + NONE = '', ISOLATED = 'isolated', // CROSS = 'cross', } From ef70eaded889d84a19eb818ef38ead0b289af4d3 Mon Sep 17 00:00:00 2001 From: Tako Date: Mon, 5 Jun 2023 10:25:23 +0000 Subject: [PATCH 101/122] data-theme to data-bs-theme --- src/components/ftbot/PairlistConfigurator.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 49ffa550..470a1e9c 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -157,14 +157,14 @@ onMounted(async () => { } } -[data-theme='light'] .add-pairlist { +[data-bs-theme='light'] .add-pairlist { color: black; } .empty { border: 3px dashed rgba(255, 255, 255, 0.65); - [data-theme='light'] & { + [data-bs-theme='light'] & { border: 3px dashed rgba(0, 0, 0, 0.5); } From 8cee684a58e4aaa6448f878bf1b5f272b95f2aff Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 6 Jun 2023 14:39:32 +0000 Subject: [PATCH 102/122] use edit-value for config actions --- .../ftbot/PairlistConfigActions.vue | 77 ++++++------------- src/stores/pairlistConfig.ts | 31 ++++---- 2 files changed, 40 insertions(+), 68 deletions(-) diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue index 3b908177..d641afe3 100644 --- a/src/components/ftbot/PairlistConfigActions.vue +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -1,51 +1,33 @@ diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index d9935bc2..d7ff9624 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -73,9 +73,9 @@ export const usePairlistConfigStore = defineStore( config.value.pairlists.splice(index, 1); } - function saveConfig(name: string) { + function renameOrSaveConfig(oldName: string, newName: string) { const i = savedConfigs.value.findIndex((c) => c.name === config.value.name); - config.value.name = name; + config.value.name = newName; if (i > -1) { savedConfigs.value[i] = config.value; @@ -84,11 +84,19 @@ export const usePairlistConfigStore = defineStore( } } - function cloneConfig() { - config.value = { - name: '', + function newConfig(name: string) { + const c = { name: name, pairlists: [] }; + savedConfigs.value.push(c); + config.value = c; + } + + function duplicateConfig(oldName: string, newName: string) { + const c = { + name: newName, pairlists: structuredClone(toRaw(config.value.pairlists)), }; + savedConfigs.value.push(c); + config.value = c; } function deleteConfig() { @@ -99,14 +107,6 @@ export const usePairlistConfigStore = defineStore( } } - function newConfig() { - config.value = { name: '', pairlists: [] }; - } - - function selectConfig(selected: PairlistConfig) { - config.value = structuredClone(toRaw(selected)); - } - function addToBlacklist() { blacklist.value.push(''); } @@ -198,10 +198,9 @@ export const usePairlistConfigStore = defineStore( startPairlistEvaluation, addToConfig, removeFromConfig, - saveConfig, - cloneConfig, + renameOrSaveConfig, + duplicateConfig, deleteConfig, - selectConfig, newConfig, addToBlacklist, removeFromBlacklist, From 74caaef7f088ba63a0a68a8532b2d462f664d2f6 Mon Sep 17 00:00:00 2001 From: Tako Date: Wed, 7 Jun 2023 17:26:33 +0000 Subject: [PATCH 103/122] improved config actions --- .../ftbot/PairlistConfigActions.vue | 20 +++++--- src/components/ftbot/PairlistConfigurator.vue | 3 ++ src/stores/pairlistConfig.ts | 50 ++++++++++++++----- 3 files changed, 52 insertions(+), 21 deletions(-) diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue index d641afe3..d7dad257 100644 --- a/src/components/ftbot/PairlistConfigActions.vue +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -1,5 +1,12 @@ - - +
+ Copy from: + +
+ + diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index e2efc956..6b471b06 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -23,7 +23,6 @@ export const usePairlistConfigStore = defineStore( const intervalId = ref(); const stakeCurrency = ref(botStore.activeBot?.stakeCurrency ?? 'USDT'); const whitelist = ref([]); - const blacklist = ref([]); const customExchange = ref(false); const selectedExchange = ref({ exchange: botStore.activeBot?.botState.exchange ?? '', @@ -36,7 +35,7 @@ export const usePairlistConfigStore = defineStore( }, }); - const config = ref({ name: '', pairlists: [] }); + const config = ref(makeConfig()); const savedConfigs = ref([]); const configName = ref(''); @@ -86,16 +85,17 @@ export const usePairlistConfigStore = defineStore( } function newConfig(name: string) { - const c = { name: name, pairlists: [] }; + const c = makeConfig({ name }); savedConfigs.value.push(c); config.value = structuredClone(c); } function duplicateConfig(name = '') { - const c = { - name: name, - pairlists: toRaw(config.value.pairlists), - }; + const c = makeConfig({ + name, + pairlists: toRaw(config.value.pairlists) as [], + blacklist: toRaw(config.value.blacklist) as [], + }); savedConfigs.value.push(c); config.value = structuredClone(c); } @@ -119,12 +119,23 @@ export const usePairlistConfigStore = defineStore( } } + function makeConfig({ name = '', pairlists = [], blacklist = [] } = {}): PairlistConfig { + return { name, pairlists, blacklist }; + } + function addToBlacklist() { - blacklist.value.push(''); + config.value.blacklist.push(''); } function removeFromBlacklist(index: number) { - blacklist.value.splice(index, 1); + config.value.blacklist.splice(index, 1); + } + + function duplicateBlacklist(configName: string) { + const conf = savedConfigs.value.find((c) => c.name === configName); + if (conf) { + config.value.blacklist = structuredClone(toRaw(conf.blacklist)); + } } async function startPairlistEvaluation() { @@ -167,19 +178,18 @@ export const usePairlistConfigStore = defineStore( function configToPayload(): PairlistsPayload { const pairlists: PairlistPayloadItem[] = configToPayloadItems(); - const config: PairlistsPayload = { + const c: PairlistsPayload = { pairlists: pairlists, stake_currency: stakeCurrency.value, - blacklist: blacklist.value, + blacklist: config.value.blacklist, }; - console.log('asdf'); if (customExchange.value) { console.log('setting custom exchange props'); - config.exchange = selectedExchange.value.exchange; - config.trading_mode = selectedExchange.value.trade_mode.trading_mode; - config.margin_mode = selectedExchange.value.trade_mode.margin_mode; + c.exchange = selectedExchange.value.exchange; + c.trading_mode = selectedExchange.value.trade_mode.trading_mode; + c.margin_mode = selectedExchange.value.trade_mode.margin_mode; } - return config; + return c; } function configToPayloadItems() { @@ -216,7 +226,6 @@ export const usePairlistConfigStore = defineStore( config, configJSON, savedConfigs, - blacklist, configName, startPairlistEvaluation, addToConfig, @@ -228,6 +237,7 @@ export const usePairlistConfigStore = defineStore( selectOrCreateConfig, addToBlacklist, removeFromBlacklist, + duplicateBlacklist, isSavedConfig, firstPairlistIsGenerator, pairlistValid, @@ -239,7 +249,7 @@ export const usePairlistConfigStore = defineStore( { persist: { key: 'ftPairlistConfig', - paths: ['savedConfigs', 'blacklist'], + paths: ['savedConfigs'], }, }, ); diff --git a/src/types/pairlists.ts b/src/types/pairlists.ts index 307c3808..f5b0998d 100644 --- a/src/types/pairlists.ts +++ b/src/types/pairlists.ts @@ -20,6 +20,7 @@ export interface Pairlist { export interface PairlistConfig { name: string; + blacklist: string[]; pairlists: Pairlist[]; } From c3378f0f2696d0c44e276ca98fccbaba4e9f5900 Mon Sep 17 00:00:00 2001 From: Tako Date: Fri, 9 Jun 2023 12:05:27 +0000 Subject: [PATCH 107/122] remove separate results view for now --- src/components/ftbot/PairlistConfigurator.vue | 18 ++++++++- src/views/PairlistConfigView.vue | 37 +------------------ 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 82ba7a3e..47ec3db0 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -59,16 +59,24 @@
+ + Config + + Results + +
From 1dabe912265a87c0cf2b3d251b2c4c54004a0c5f Mon Sep 17 00:00:00 2001 From: Tako Date: Fri, 9 Jun 2023 15:24:07 +0000 Subject: [PATCH 109/122] add stake currency field --- .../ftbot/PairlistConfigBlacklist.vue | 9 ++++++-- src/components/ftbot/PairlistConfigurator.vue | 23 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/ftbot/PairlistConfigBlacklist.vue b/src/components/ftbot/PairlistConfigBlacklist.vue index 4e2135ac..fc81f854 100644 --- a/src/components/ftbot/PairlistConfigBlacklist.vue +++ b/src/components/ftbot/PairlistConfigBlacklist.vue @@ -32,7 +32,12 @@ > - + - Add + Add diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 47ec3db0..398f365f 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -26,14 +26,21 @@
- Custom Exchange - + +
+ Stake currency: + +
+ +
+ Custom Exchange + +
From 3cb7d7560115317dacbfa6841554a698a17e9752 Mon Sep 17 00:00:00 2001 From: Tako Date: Fri, 9 Jun 2023 19:32:47 +0000 Subject: [PATCH 111/122] remember last used config on reload --- src/components/ftbot/PairlistConfigurator.vue | 2 +- src/stores/pairlistConfig.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index 398f365f..9a35cd46 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -154,7 +154,7 @@ onMounted(async () => { : 1, ); pairlistStore.selectOrCreateConfig( - pairlistStore.savedConfigs.length > 0 ? pairlistStore.savedConfigs[0].name : 'default', + pairlistStore.isSavedConfig(pairlistStore.configName) ? pairlistStore.configName : 'default', ); }); diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index 6b471b06..f11b05ce 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -55,9 +55,8 @@ export const usePairlistConfigStore = defineStore( return JSON.stringify(configToPayloadItems(), null, 2); }); - const isSavedConfig = computed( - () => savedConfigs.value.findIndex((c) => c.name === config.value.name) > -1, - ); + const isSavedConfig = (name: string) => + savedConfigs.value.findIndex((c) => c.name === name) > -1; function addToConfig(pairlist: Pairlist, index: number) { pairlist = structuredClone(toRaw(pairlist)); @@ -249,7 +248,7 @@ export const usePairlistConfigStore = defineStore( { persist: { key: 'ftPairlistConfig', - paths: ['savedConfigs'], + paths: ['savedConfigs', 'configName'], }, }, ); From c3a4f1def6fe169df309bceaab16553ed3af170c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 10 Jun 2023 08:46:36 +0200 Subject: [PATCH 112/122] Make parameter types more explicit --- src/components/ftbot/PairlistConfigItem.vue | 7 ++--- src/stores/pairlistConfig.ts | 3 +- src/types/pairlists.ts | 34 +++++++++++++++++++-- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/components/ftbot/PairlistConfigItem.vue b/src/components/ftbot/PairlistConfigItem.vue index c58b20e9..da798418 100644 --- a/src/components/ftbot/PairlistConfigItem.vue +++ b/src/components/ftbot/PairlistConfigItem.vue @@ -55,11 +55,10 @@ From e136127e4c857bf520f7d3ca4a4b8ba56e926676 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 13 Jun 2023 13:00:45 +0000 Subject: [PATCH 118/122] remember pairlist collapsed state --- src/components/ftbot/PairlistConfigItem.vue | 16 +++++++--------- src/components/ftbot/PairlistConfigurator.vue | 13 +------------ src/stores/pairlistConfig.ts | 4 ++++ src/types/pairlists.ts | 1 + 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/components/ftbot/PairlistConfigItem.vue b/src/components/ftbot/PairlistConfigItem.vue index db8c8532..b6d29d97 100644 --- a/src/components/ftbot/PairlistConfigItem.vue +++ b/src/components/ftbot/PairlistConfigItem.vue @@ -26,22 +26,22 @@ @click="pairlistStore.removeFromConfig(index)" />
- + (); -const showParameters = ref(false); - const pairlist = defineModel({ required: true }); const hasParameters = computed(() => Object.keys(pairlist.value.params).length > 0); function toggleVisible() { if (hasParameters.value) { - showParameters.value = !showParameters.value; + pairlist.value.showParameters = !pairlist.value.showParameters; } } diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index d5be8a7d..f368c805 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -58,7 +58,7 @@ :class="{ empty: configEmpty }" > (null); const availablePairlistsEl = ref(null); const selectedView = ref<'Config' | 'Results'>('Config'); -// v-for updates with sorting, deleting and adding items seem to get wonky without unique keys for every item -const pairlistsComp = computed(() => - pairlistStore.config.pairlists.map((p) => { - if (p.id) { - return p; - } else { - return { id: Date.now().toString(36) + Math.random().toString(36).substring(2), ...p }; - } - }), -); - const configEmpty = computed(() => { return pairlistStore.config.pairlists.length == 0; }); diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index a77946e7..23898730 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -62,6 +62,10 @@ export const usePairlistConfigStore = defineStore( function addToConfig(pairlist: Pairlist, index: number) { pairlist = structuredClone(toRaw(pairlist)); + pairlist.showParameters = false; + if (!pairlist.id) { + pairlist.id = Date.now().toString(36) + Math.random().toString(36).substring(2); + } for (const param in pairlist.params) { pairlist.params[param].value = isNotUndefined(pairlist.params[param].default) ? pairlist.params[param].default diff --git a/src/types/pairlists.ts b/src/types/pairlists.ts index a4308557..786653ac 100644 --- a/src/types/pairlists.ts +++ b/src/types/pairlists.ts @@ -15,6 +15,7 @@ export interface Pairlist { is_pairlist_generator: boolean; name: string; description: string; + showParameters: boolean; params: Record; } From 93be009b74b0d1afe4197e9ad159ebfa9d684da7 Mon Sep 17 00:00:00 2001 From: Tako Date: Tue, 13 Jun 2023 17:09:24 +0000 Subject: [PATCH 119/122] better config/results scroll --- src/components/ftbot/PairlistConfigurator.vue | 23 ++++++++++++------- src/components/general/CopyableTextfield.vue | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/ftbot/PairlistConfigurator.vue b/src/components/ftbot/PairlistConfigurator.vue index f368c805..d1e3f54e 100644 --- a/src/components/ftbot/PairlistConfigurator.vue +++ b/src/components/ftbot/PairlistConfigurator.vue @@ -1,5 +1,5 @@ diff --git a/src/components/general/CopyableTextfield.vue b/src/components/general/CopyableTextfield.vue index 83819171..2b535a0c 100644 --- a/src/components/general/CopyableTextfield.vue +++ b/src/components/general/CopyableTextfield.vue @@ -6,7 +6,7 @@ class="copy-button position-absolute end-0 mt-1 me-2" @click="copy(content)" /> -
{{ content }}
+
{{ content }}
From 01e4ed704c9b47c0387ec95fb82d86b69ea56d45 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 15 Jun 2023 06:44:43 +0200 Subject: [PATCH 120/122] Improve responsive behavior for Pairlist config actions --- src/components/ftbot/PairlistConfigActions.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ftbot/PairlistConfigActions.vue b/src/components/ftbot/PairlistConfigActions.vue index c8fbac7f..538bcf06 100644 --- a/src/components/ftbot/PairlistConfigActions.vue +++ b/src/components/ftbot/PairlistConfigActions.vue @@ -1,5 +1,5 @@