From 7dde1648fceaed6b07360785473bf8548e16a482 Mon Sep 17 00:00:00 2001 From: Tako Date: Fri, 9 Jun 2023 11:02:21 +0000 Subject: [PATCH] per config blacklist with copy option --- .../ftbot/PairlistConfigBlacklist.vue | 17 +++++-- src/stores/pairlistConfig.ts | 46 +++++++++++-------- src/types/pairlists.ts | 1 + 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/components/ftbot/PairlistConfigBlacklist.vue b/src/components/ftbot/PairlistConfigBlacklist.vue index d170e70c..82c0c68f 100644 --- a/src/components/ftbot/PairlistConfigBlacklist.vue +++ b/src/components/ftbot/PairlistConfigBlacklist.vue @@ -25,8 +25,19 @@ - - +
+ 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[]; }