mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-13 03:33:50 +00:00
wip config storage
This commit is contained in:
parent
cebf07bdee
commit
0c4c4b7fc6
|
@ -34,13 +34,21 @@
|
||||||
<b-col>
|
<b-col>
|
||||||
<b-row>
|
<b-row>
|
||||||
<b-col>
|
<b-col>
|
||||||
<b-form-input
|
<b-row>
|
||||||
v-model="pairlistStore.config.name"
|
<b-col>
|
||||||
class="mb-2"
|
<b-form-select v-model="pairlistStore.config" :options="configsSelectOptions" />
|
||||||
placeholder="Configuration name..."
|
</b-col>
|
||||||
></b-form-input>
|
<b-col
|
||||||
|
><b-form-input
|
||||||
|
v-model="pairlistStore.config.name"
|
||||||
|
class="mb-2"
|
||||||
|
placeholder="Configuration name..."
|
||||||
|
></b-form-input
|
||||||
|
></b-col>
|
||||||
|
</b-row>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="auto">
|
<b-col cols="auto">
|
||||||
|
<b-button>New</b-button>
|
||||||
<b-button @click="pairlistStore.saveConfig()">Save</b-button>
|
<b-button @click="pairlistStore.saveConfig()">Save</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
|
|
|
@ -5,79 +5,88 @@ import { Pairlist, PairlistConfig, PairlistsPayload } from '@/types';
|
||||||
import { computed, ref, toRaw } from 'vue';
|
import { computed, ref, toRaw } from 'vue';
|
||||||
import { showAlert } from './alerts';
|
import { showAlert } from './alerts';
|
||||||
|
|
||||||
export const usePairlistConfigStore = defineStore('pairlistConfig', () => {
|
export const usePairlistConfigStore = defineStore(
|
||||||
const botStore = useBotStore();
|
'pairlistConfig',
|
||||||
|
() => {
|
||||||
|
const botStore = useBotStore();
|
||||||
|
|
||||||
const evaluating = ref<boolean>(false);
|
const evaluating = ref<boolean>(false);
|
||||||
const intervalId = ref<number>();
|
const intervalId = ref<number>();
|
||||||
const whitelist = ref<string[]>([]);
|
const whitelist = ref<string[]>([]);
|
||||||
const config = ref<PairlistConfig>({ name: '', pairlists: [] });
|
const config = ref<PairlistConfig>({ name: '', pairlists: [] });
|
||||||
const savedConfigs = ref<PairlistConfig[]>([]);
|
const savedConfigs = ref<PairlistConfig[]>([]);
|
||||||
|
|
||||||
const firstPairlistIsGenerator = computed<boolean>(() => {
|
const firstPairlistIsGenerator = computed<boolean>(() => {
|
||||||
// First pairlist must be a generator
|
// First pairlist must be a generator
|
||||||
if (config.value.pairlists[0]?.is_pairlist_generator) {
|
if (config.value.pairlists[0]?.is_pairlist_generator) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
const pairlistValid = computed<boolean>(() => {
|
|
||||||
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);
|
return false;
|
||||||
}
|
});
|
||||||
|
|
||||||
function addToConfig(pairlist: Pairlist, index: number) {
|
const pairlistValid = computed<boolean>(() => {
|
||||||
pairlist = structuredClone(toRaw(pairlist));
|
return firstPairlistIsGenerator.value && config.value.pairlists.length > 0;
|
||||||
for (const param in pairlist.params) {
|
});
|
||||||
pairlist.params[param].value = pairlist.params[param].default
|
|
||||||
? pairlist.params[param].default.toString()
|
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);
|
||||||
}
|
}
|
||||||
config.value.pairlists.splice(index, 0, pairlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFromConfig(index: number) {
|
function addToConfig(pairlist: Pairlist, index: number) {
|
||||||
config.value.pairlists.splice(index, 1);
|
pairlist = structuredClone(toRaw(pairlist));
|
||||||
}
|
for (const param in pairlist.params) {
|
||||||
|
pairlist.params[param].value = pairlist.params[param].default
|
||||||
const saveConfig = () => {
|
? pairlist.params[param].default.toString()
|
||||||
const i = savedConfigs.value.findIndex((c) => c.name === config.value.name);
|
: '';
|
||||||
|
}
|
||||||
if (i > -1) {
|
config.value.pairlists.splice(index, 0, pairlist);
|
||||||
savedConfigs.value[i] = config.value;
|
|
||||||
} else {
|
|
||||||
savedConfigs.value.push(config.value);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
function removeFromConfig(index: number) {
|
||||||
evaluating,
|
config.value.pairlists.splice(index, 1);
|
||||||
whitelist,
|
}
|
||||||
config,
|
|
||||||
savedConfigs,
|
const saveConfig = () => {
|
||||||
startPairlistEvaluation,
|
const i = savedConfigs.value.findIndex((c) => c.name === config.value.name);
|
||||||
addToConfig,
|
|
||||||
removeFromConfig,
|
if (i > -1) {
|
||||||
saveConfig,
|
savedConfigs.value[i] = structuredClone(toRaw(config.value));
|
||||||
firstPairlistIsGenerator,
|
} else {
|
||||||
pairlistValid,
|
savedConfigs.value.push(structuredClone(toRaw(config.value)));
|
||||||
};
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
evaluating,
|
||||||
|
whitelist,
|
||||||
|
config,
|
||||||
|
savedConfigs,
|
||||||
|
startPairlistEvaluation,
|
||||||
|
addToConfig,
|
||||||
|
removeFromConfig,
|
||||||
|
saveConfig,
|
||||||
|
firstPairlistIsGenerator,
|
||||||
|
pairlistValid,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
{
|
||||||
|
persist: {
|
||||||
|
key: 'pairlist-configs',
|
||||||
|
paths: ['savedConfigs'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user