mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 04:55:15 +00:00
more things to pairlistStore
This commit is contained in:
parent
5e927d406e
commit
13324c8d37
|
@ -85,7 +85,10 @@
|
|||
</div>
|
||||
</b-col>
|
||||
<b-col cols="12" md="3">
|
||||
<CopyableTextfield :content="configJSON" :is-valid="pairlistStore.pairlistValid" />
|
||||
<CopyableTextfield
|
||||
:content="pairlistStore.configJSON"
|
||||
:is-valid="pairlistStore.pairlistValid"
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
|
@ -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();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user