Skip to content

Commit

Permalink
feat: add support for "list" as pairlist config type
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Sep 26, 2024
1 parent 24c208f commit 0583b50
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare module 'vue' {
BalanceChart: typeof import('./components/charts/BalanceChart.vue')['default']
BAlert: typeof import('bootstrap-vue-next')['BAlert']
BaseAlert: typeof import('./components/general/BaseAlert.vue')['default']
BaseStringList: typeof import('./components/general/BaseStringList.vue')['default']
BAvatar: typeof import('bootstrap-vue-next')['BAvatar']
BButton: typeof import('bootstrap-vue-next')['BButton']
BCard: typeof import('bootstrap-vue-next')['BCard']
Expand Down Expand Up @@ -83,6 +84,7 @@ declare module 'vue' {
ForceExitForm: typeof import('./components/ftbot/ForceExitForm.vue')['default']
FreqaiModelSelect: typeof import('./components/ftbot/FreqaiModelSelect.vue')['default']
HourlyChart: typeof import('./components/charts/HourlyChart.vue')['default']
IMdiAdd: typeof import('~icons/mdi/add')['default']
IMdiAlert: typeof import('~icons/mdi/alert')['default']
IMdiArrowDownThick: typeof import('~icons/mdi/arrow-down-thick')['default']
IMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default']
Expand Down
4 changes: 4 additions & 0 deletions src/components/ftbot/PairlistConfigParameter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const paramValue = defineModel<any>();
v-model="paramValue"
:options="param.options"
></BFormSelect>
<BaseStringList
v-if="param.type === PairlistParamType.list"
v-model="paramValue"
></BaseStringList>

<template #label>
<label> {{ param.description }}</label>
Expand Down
29 changes: 29 additions & 0 deletions src/components/general/BaseStringList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup lang="ts">
const values = defineModel<string[]>({ required: true });
</script>

<template>
<div class="d-flex flex-row gap-2">
<div class="d-flex gap-1 flex-column w-100">
<div v-for="(val, idx) in values" :key="val" class="d-flex flex-row gap-1">
<BFormInput v-model="values[idx]" size="sm"></BFormInput>
<BButton
size="sm"
variant="outline-secondary"
title="Delete this value."
@click="values.splice(idx, 1)"
>
<i-mdi-delete />
</BButton>
</div>
</div>
<BButton
size="sm"
:title="`Add new value`"
variant="secondary"
class="ms-auto mt-auto"
@click="values.push('')"
><i-mdi-plus-box-outline />
</BButton>
</div>
</template>
2 changes: 2 additions & 0 deletions src/stores/pairlistConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export const usePairlistConfigStore = defineStore(
return Number(value);
} else if (type === PairlistParamType.boolean) {
return Boolean(value);
} else if (type === PairlistParamType.list) {
return value as string[];
} else {
return String(value);
}
Expand Down
12 changes: 10 additions & 2 deletions src/types/pairlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export enum PairlistParamType {
number = 'number',
boolean = 'boolean',
option = 'option',
list = 'list',
}

export type PairlistParamValue = string | number | boolean;
export type PairlistParamValue = string | number | boolean | string[];

interface PairlistParameterBase {
description: string;
Expand Down Expand Up @@ -65,11 +66,18 @@ export interface OptionPairlistParameter extends PairlistParameterBase {
default: string;
}

export interface ListPairlistParameter extends PairlistParameterBase {
type: PairlistParamType.list;
value?: string[];
default: string;
}

export type PairlistParameter =
| StringPairlistParameter
| NumberPairlistParameter
| BooleanPairlistParameter
| OptionPairlistParameter;
| OptionPairlistParameter
| ListPairlistParameter;

export interface PairlistPayloadItem {
method: string;
Expand Down

0 comments on commit 0583b50

Please sign in to comment.