frequi_origin/src/components/ftbot/BotControls.vue

161 lines
4.3 KiB
Vue
Raw Normal View History

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 ml-1"
:disabled="!isTrading || isRunning"
title="Start Trading"
@click="startBot()"
>
<PlayIcon />
</button>
<button
class="btn btn-secondary btn-sm ml-1"
:disabled="!isTrading || !isRunning"
title="Stop Trading - Also stops handling open trades."
@click="handleStopBot()"
>
<StopIcon />
</button>
<button
class="btn btn-secondary btn-sm ml-1"
:disabled="!isTrading || !isRunning"
title="StopBuy - Stops buying, but still handles open trades"
@click="handleStopBuy()"
>
<PauseIcon />
</button>
<button
class="btn btn-secondary btn-sm ml-1"
:disabled="!isTrading"
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 ml-1"
:disabled="!isTrading"
title="Forcesell all"
@click="handleForceSell()"
>
<ForceSellIcon />
</button>
2021-08-30 17:57:42 +00:00
<button
2022-04-08 05:44:28 +00:00
v-if="botState && (botState.force_entry_enable || botState.forcebuy_enabled)"
2021-08-30 17:57:42 +00:00
class="btn btn-secondary btn-sm ml-1"
:disabled="!isTrading || !isRunning"
title="Force enter - Immediately buy an asset at an optional price. Sells are then handled according to strategy rules."
@click="initiateForceenter"
2021-08-30 17:57:42 +00:00
>
<ForceBuyIcon />
</button>
<button
v-if="isWebserverMode && false"
:disabled="isTrading"
class="btn btn-secondary btn-sm ml-1"
title="Start Trading mode"
@click="startTrade()"
>
<PlayIcon />
</button>
<ForceBuyForm :modal-show="forcebuyShow" @close="$bvModal.hide('forcebuy-modal')" />
2020-05-06 04:38:57 +00:00
</div>
</template>
2020-08-09 13:23:04 +00:00
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import { BotState, ForceSellPayload } from '@/types';
import { BotStoreActions, BotStoreGetters } from '@/store/modules/ftbot';
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';
import ForceSellIcon from 'vue-material-design-icons/CloseBoxMultiple.vue';
2020-11-20 05:54:42 +00:00
import ForceBuyIcon from 'vue-material-design-icons/PlusBoxMultipleOutline.vue';
import StoreModules from '@/store/storeSubModules';
2020-05-14 16:10:57 +00:00
import ForceBuyForm from './ForceBuyForm.vue';
2020-05-06 04:38:57 +00:00
const ftbot = namespace(StoreModules.ftbot);
2020-08-09 13:23:04 +00:00
2020-11-13 19:19:16 +00:00
@Component({
components: {
ForceBuyForm,
PlayIcon,
StopIcon,
PauseIcon,
ReloadIcon,
ForceSellIcon,
ForceBuyIcon,
},
2020-11-13 19:19:16 +00:00
})
2020-08-09 13:23:04 +00:00
export default class BotControls extends Vue {
forcebuyShow = false;
@ftbot.Getter [BotStoreGetters.botState]?: BotState;
2020-08-09 13:23:04 +00:00
@ftbot.Action startBot;
@ftbot.Action stopBot;
@ftbot.Action stopBuy;
@ftbot.Action reloadConfig;
2020-11-08 10:08:27 +00:00
@ftbot.Action startTrade;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ftbot.Action [BotStoreActions.forcesell]!: (payload: ForceSellPayload) => void;
2020-11-08 10:40:26 +00:00
@ftbot.Getter [BotStoreGetters.isTrading]!: boolean;
@ftbot.Getter [BotStoreGetters.isWebserverMode]!: boolean;
get isRunning(): boolean {
2021-01-16 15:07:06 +00:00
return this.botState?.state === 'running';
}
initiateForceenter() {
2020-08-09 13:23:04 +00:00
this.$bvModal.show('forcebuy-modal');
}
handleStopBot() {
this.$bvModal.msgBoxConfirm('Stop Bot?').then((value: boolean) => {
if (value) {
this.stopBot();
}
});
}
handleStopBuy() {
this.$bvModal
.msgBoxConfirm('Stop buying? Freqtrade will continue to handle open trades.')
.then((value: boolean) => {
if (value) {
this.stopBuy();
}
});
}
handleReloadConfig() {
this.$bvModal.msgBoxConfirm('Reload configuration?').then((value: boolean) => {
if (value) {
this.reloadConfig();
}
});
}
handleForceSell() {
2022-01-22 12:22:52 +00:00
this.$bvModal.msgBoxConfirm(`Really forcesell ALL trades?`).then((value: boolean) => {
if (value) {
const payload: ForceSellPayload = {
tradeid: 'all',
// TODO: support ordertype (?)
};
this.forcesell(payload);
}
});
}
2020-08-09 13:23:04 +00:00
}
2020-05-06 04:38:57 +00:00
</script>