2023-06-04 08:01:28 +00:00
|
|
|
<template>
|
|
|
|
<div class="w-100 d-flex">
|
2023-06-11 11:07:15 +00:00
|
|
|
<b-form-select
|
|
|
|
id="exchange-select"
|
|
|
|
v-model="exchangeModel.exchange"
|
|
|
|
size="sm"
|
|
|
|
:options="exchangeList"
|
|
|
|
>
|
2023-06-04 08:01:28 +00:00
|
|
|
</b-form-select>
|
|
|
|
<b-form-select
|
|
|
|
id="tradeMode-select"
|
|
|
|
v-model="exchangeModel.trade_mode"
|
2023-06-11 11:07:15 +00:00
|
|
|
size="sm"
|
2023-06-04 08:01:28 +00:00
|
|
|
:options="tradeModes"
|
|
|
|
:disabled="tradeModes.length < 2"
|
|
|
|
>
|
|
|
|
</b-form-select>
|
|
|
|
<div class="ms-2">
|
2023-06-11 11:07:15 +00:00
|
|
|
<b-button size="sm" @click="botStore.activeBot.getExchangeList">
|
2023-06-04 08:01:28 +00:00
|
|
|
<i-mdi-refresh />
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2023-06-04 13:45:49 +00:00
|
|
|
import { computed, onMounted, watch } from 'vue';
|
2023-06-04 08:01:28 +00:00
|
|
|
import { ExchangeSelection } from '@/types';
|
|
|
|
|
|
|
|
const exchangeModel = defineModel({
|
|
|
|
type: Object as () => ExchangeSelection,
|
|
|
|
required: true,
|
|
|
|
});
|
|
|
|
const botStore = useBotStore();
|
|
|
|
|
|
|
|
const exchangeList = computed(() => {
|
2023-06-07 18:33:22 +00:00
|
|
|
const supported = botStore.activeBot.exchangeList
|
|
|
|
.filter((ex) => ex.valid && ex.supported)
|
|
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
|
|
|
|
|
|
const unsupported = botStore.activeBot.exchangeList
|
|
|
|
.filter((ex) => ex.valid && !ex.supported)
|
|
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
|
|
|
|
|
|
return [
|
|
|
|
{ label: 'Supported', options: supported.map((e) => e.name) },
|
|
|
|
{ label: 'Unsupported', options: unsupported.map((e) => e.name) },
|
|
|
|
];
|
2023-06-04 08:01:28 +00:00
|
|
|
});
|
|
|
|
|
2023-06-04 13:45:49 +00:00
|
|
|
const tradeModesTyped = computed(() => {
|
2023-07-11 20:02:02 +00:00
|
|
|
const val = botStore.activeBot.exchangeList.find((ex) => ex.name === exchangeModel.value.exchange)
|
|
|
|
?.trade_modes;
|
2023-06-04 13:45:49 +00:00
|
|
|
return val ?? [];
|
|
|
|
});
|
|
|
|
|
2023-06-04 08:01:28 +00:00
|
|
|
const tradeModes = computed<Record<string, unknown>[]>(() => {
|
2023-06-04 13:45:49 +00:00
|
|
|
return tradeModesTyped.value.map((tm) => {
|
|
|
|
return (
|
|
|
|
{
|
|
|
|
text: `${tm.margin_mode} ${tm.trading_mode}`,
|
|
|
|
value: tm,
|
|
|
|
} ?? []
|
|
|
|
);
|
|
|
|
}) as Record<string, unknown>[];
|
2023-06-04 08:01:28 +00:00
|
|
|
});
|
|
|
|
|
2023-06-04 13:45:49 +00:00
|
|
|
watch(
|
|
|
|
() => exchangeModel.value.exchange,
|
|
|
|
() => {
|
|
|
|
if (tradeModesTyped.value.length < 2) {
|
|
|
|
exchangeModel.value.trade_mode = tradeModesTyped.value[0];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-06-04 08:01:28 +00:00
|
|
|
onMounted(() => {
|
|
|
|
if (botStore.activeBot.exchangeList.length === 0) {
|
|
|
|
botStore.activeBot.getExchangeList();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|