frequi_origin/src/components/ftbot/BotControls.vue

151 lines
4.4 KiB
Vue
Raw Normal View History

2022-04-21 17:36:12 +00:00
forceexit
2020-05-06 04:38:57 +00:00
<template>
2021-08-30 17:57:42 +00:00
<div>
<button
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading || isRunning"
2021-08-30 17:57:42 +00:00
title="Start Trading"
2022-04-26 20:00:21 +00:00
@click="botStore.activeBot.startBot()"
2021-08-30 17:57:42 +00:00
>
<PlayIcon />
</button>
<button
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading || !isRunning"
2021-08-30 17:57:42 +00:00
title="Stop Trading - Also stops handling open trades."
@click="handleStopBot()"
>
<StopIcon />
</button>
<button
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading || !isRunning"
2021-08-30 17:57:42 +00:00
title="StopBuy - Stops buying, but still handles open trades"
@click="handleStopBuy()"
>
<PauseIcon />
</button>
<button
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading"
2021-08-30 17:57:42 +00:00
title="Reload Config - reloads configuration including strategy, resetting all settings changed on the fly."
@click="handleReloadConfig()"
>
<ReloadIcon />
</button>
<button
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading"
2022-04-21 17:36:12 +00:00
title="Force exit all"
@click="handleForceExit()"
>
2022-04-21 17:36:12 +00:00
<ForceExitIcon />
</button>
2021-08-30 17:57:42 +00:00
<button
2022-04-19 04:53:35 +00:00
v-if="
botStore.activeBot.botState &&
(botStore.activeBot.botState.force_entry_enable ||
botStore.activeBot.botState.forcebuy_enabled)
"
class="btn btn-secondary btn-sm ms-1"
2022-04-19 04:53:35 +00:00
:disabled="!botStore.activeBot.isTrading || !isRunning"
2022-04-21 17:36:12 +00:00
title="Force enter - Immediately enter a trade at an optional price. Exits are then handled according to strategy rules."
2022-11-19 09:53:04 +00:00
@click="forceEnter = true"
2021-08-30 17:57:42 +00:00
>
2022-04-21 17:36:12 +00:00
<ForceEntryIcon />
2021-08-30 17:57:42 +00:00
</button>
<button
2022-04-19 04:53:35 +00:00
v-if="botStore.activeBot.isWebserverMode && false"
2022-04-28 17:21:30 +00:00
:disabled="botStore.activeBot.isTrading"
class="btn btn-secondary btn-sm ms-1"
2021-08-30 17:57:42 +00:00
title="Start Trading mode"
2022-04-26 20:00:21 +00:00
@click="botStore.activeBot.startTrade()"
2021-08-30 17:57:42 +00:00
>
<PlayIcon />
</button>
2022-11-19 09:53:04 +00:00
<ForceEntryForm v-model="forceEnter" :pair="botStore.activeBot.selectedPair" />
2020-05-06 04:38:57 +00:00
</div>
</template>
2020-08-09 13:23:04 +00:00
<script lang="ts">
2022-04-16 05:43:26 +00:00
import { ForceSellPayload } from '@/types';
2020-11-13 19:19:16 +00:00
import PlayIcon from 'vue-material-design-icons/Play.vue';
import StopIcon from 'vue-material-design-icons/Stop.vue';
import PauseIcon from 'vue-material-design-icons/Pause.vue';
import ReloadIcon from 'vue-material-design-icons/Reload.vue';
2022-04-21 17:36:12 +00:00
import ForceExitIcon from 'vue-material-design-icons/CloseBoxMultiple.vue';
import ForceEntryIcon from 'vue-material-design-icons/PlusBoxMultipleOutline.vue';
2022-05-25 17:20:18 +00:00
import ForceEntryForm from './ForceEntryForm.vue';
2022-07-07 18:44:19 +00:00
import { defineComponent, computed, ref, getCurrentInstance } from 'vue';
2022-04-19 04:53:35 +00:00
import { useBotStore } from '@/stores/ftbotwrapper';
2020-05-06 04:38:57 +00:00
2022-04-16 05:43:26 +00:00
export default defineComponent({
name: 'BotControls',
components: {
2022-05-25 17:20:18 +00:00
ForceEntryForm,
PlayIcon,
StopIcon,
PauseIcon,
ReloadIcon,
2022-04-21 17:36:12 +00:00
ForceExitIcon,
ForceEntryIcon,
},
2022-07-07 18:44:19 +00:00
setup() {
const root = getCurrentInstance();
2022-04-19 04:53:35 +00:00
const botStore = useBotStore();
2022-11-19 09:53:04 +00:00
const forceEnter = ref<boolean>(false);
2022-04-16 05:43:26 +00:00
const isRunning = computed((): boolean => {
2022-04-19 04:53:35 +00:00
return botStore.activeBot.botState?.state === 'running';
});
2022-04-16 05:43:26 +00:00
const handleStopBot = () => {
2022-07-09 18:04:22 +00:00
root?.proxy.$bvModal.msgBoxConfirm('Stop Bot?').then((value: boolean) => {
if (value) {
2022-04-19 04:53:35 +00:00
botStore.activeBot.stopBot();
}
});
2022-04-16 05:43:26 +00:00
};
const handleStopBuy = () => {
2022-07-09 18:04:22 +00:00
root?.proxy.$bvModal
2022-04-16 05:43:26 +00:00
.msgBoxConfirm('Stop buying? Freqtrade will continue to handle open trades.')
.then((value: boolean) => {
if (value) {
2022-04-19 04:53:35 +00:00
botStore.activeBot.stopBuy();
2022-04-16 05:43:26 +00:00
}
});
};
const handleReloadConfig = () => {
2022-07-09 18:04:22 +00:00
root?.proxy.$bvModal.msgBoxConfirm('Reload configuration?').then((value: boolean) => {
2022-04-16 05:43:26 +00:00
if (value) {
2022-04-19 04:53:35 +00:00
botStore.activeBot.reloadConfig();
2022-04-16 05:43:26 +00:00
}
});
};
2022-04-21 17:36:12 +00:00
const handleForceExit = () => {
2022-08-03 04:57:17 +00:00
root?.proxy.$bvModal.msgBoxConfirm(`Really forceexit ALL trades?`).then((value: boolean) => {
2022-04-16 05:43:26 +00:00
if (value) {
const payload: ForceSellPayload = {
tradeid: 'all',
// TODO: support ordertype (?)
};
2022-04-21 17:36:12 +00:00
botStore.activeBot.forceexit(payload);
2022-04-16 05:43:26 +00:00
}
});
};
return {
handleStopBot,
handleStopBuy,
handleReloadConfig,
2022-04-21 17:36:12 +00:00
handleForceExit,
2022-11-19 09:53:04 +00:00
forceEnter,
2022-04-19 04:53:35 +00:00
botStore,
2022-04-16 05:43:26 +00:00
isRunning,
};
},
});
2020-05-06 04:38:57 +00:00
</script>