mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 18:23:50 +00:00
Improve exchange Select behavior
This commit is contained in:
parent
35a81a8d9b
commit
f6c0e3d0b6
|
@ -19,7 +19,7 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { computed, onMounted, watch } from 'vue';
|
||||
import { ExchangeSelection } from '@/types';
|
||||
|
||||
const exchangeModel = defineModel({
|
||||
|
@ -44,20 +44,33 @@ const exchangeList = computed(() => {
|
|||
.map((e) => e.name);
|
||||
});
|
||||
|
||||
const tradeModes = computed<Record<string, unknown>[]>(() => {
|
||||
const val = botStore.activeBot.exchangeList
|
||||
.find((ex) => ex.name === exchangeModel.value.exchange)
|
||||
?.trade_modes.map((tm) => {
|
||||
return (
|
||||
{
|
||||
text: `${tm.margin_mode} ${tm.trading_mode}`,
|
||||
value: tm,
|
||||
} ?? []
|
||||
);
|
||||
});
|
||||
return (val ?? []) as Record<string, unknown>[];
|
||||
const tradeModesTyped = computed(() => {
|
||||
const val = botStore.activeBot.exchangeList.find(
|
||||
(ex) => ex.name === exchangeModel.value.exchange,
|
||||
)?.trade_modes;
|
||||
return val ?? [];
|
||||
});
|
||||
|
||||
const tradeModes = computed<Record<string, unknown>[]>(() => {
|
||||
return tradeModesTyped.value.map((tm) => {
|
||||
return (
|
||||
{
|
||||
text: `${tm.margin_mode} ${tm.trading_mode}`,
|
||||
value: tm,
|
||||
} ?? []
|
||||
);
|
||||
}) as Record<string, unknown>[];
|
||||
});
|
||||
|
||||
watch(
|
||||
() => exchangeModel.value.exchange,
|
||||
() => {
|
||||
if (tradeModesTyped.value.length < 2) {
|
||||
exchangeModel.value.trade_mode = tradeModesTyped.value[0];
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
if (botStore.activeBot.exchangeList.length === 0) {
|
||||
botStore.activeBot.getExchangeList();
|
||||
|
|
|
@ -26,10 +26,13 @@ export const usePairlistConfigStore = defineStore(
|
|||
const blacklist = ref<string[]>([]);
|
||||
const customExchange = ref<boolean>(false);
|
||||
const selectedExchange = ref<ExchangeSelection>({
|
||||
exchange: '',
|
||||
exchange: botStore.activeBot?.botState.exchange ?? '',
|
||||
trade_mode: {
|
||||
trading_mode: TradingMode.SPOT,
|
||||
margin_mode: MarginMode.NONE,
|
||||
trading_mode: botStore.activeBot?.botState.trading_mode ?? TradingMode.SPOT,
|
||||
margin_mode:
|
||||
botStore.activeBot?.botState.trading_mode === TradingMode.FUTURES
|
||||
? MarginMode.ISOLATED
|
||||
: MarginMode.NONE,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ export enum TradingMode {
|
|||
}
|
||||
|
||||
export enum MarginMode {
|
||||
NONE = 'none',
|
||||
NONE = '',
|
||||
ISOLATED = 'isolated',
|
||||
// CROSS = 'cross',
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user