VIsual changes, new methods stopbuy and reload_conf

This commit is contained in:
Matthias 2020-05-06 19:38:52 +02:00
parent d01365a532
commit b146f23ba1
9 changed files with 85 additions and 37 deletions

View File

@ -61,3 +61,10 @@ nav a {
color: #ccc; color: #ccc;
} }
</style> </style>
<style>
/* Global styles - populating to child elementes */
.card-header {
font-size: 1.3em;
}
</style>

View File

@ -3,6 +3,8 @@
<div class="row"> <div class="row">
<button class="btn-primary" @click="startBot()">Start</button> <button class="btn-primary" @click="startBot()">Start</button>
<button class="btn-primary" @click="stopBot()">Stop</button> <button class="btn-primary" @click="stopBot()">Stop</button>
<button class="btn-primary" @click="stopBuy()">StopBuy</button>
<button class="btn-primary" @click="reloadConfig()">Reload Config</button>
</div> </div>
</div> </div>
</template> </template>
@ -13,7 +15,7 @@ import { mapActions } from 'vuex';
export default { export default {
name: 'BotControls', name: 'BotControls',
methods: { methods: {
...mapActions('ftbot', ['stopBot', 'startBot']), ...mapActions('ftbot', ['startBot', 'stopBot', 'stopBuy', 'reloadConfig']),
}, },
}; };
</script> </script>

View File

@ -6,17 +6,18 @@
</p> </p>
<p> <p>
Running with Running with
<b> <strong>
{{ botState.max_open_trades }}x{{ botState.stake_amount }} {{ botState.max_open_trades }}x{{ botState.stake_amount }} {{ botState.stake_currency }}
{{ botState.stake_currency }} </strong>
</b>
on on
<b>{{ botState.exchange }}</b <strong>{{ botState.exchange }}</strong>
>, with Strategy <b>{{ botState.strategy }}</b , with Strategy<strong>{{ botState.strategy }}</strong>
>.
</p> </p>
<p> <p>
Currently <b>{{ botState.state }}</b> Currently <strong>{{ botState.state }}</strong>
</p>
<p>
<strong>{{ botState.dry_run ? 'Dry-Run' : 'Live' }}</strong>
</p> </p>
</div> </div>
</template> </template>

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div class="card">
<h2>Performance</h2> <div class="card-header">Performance</div>
<table v-if="performanceStats" class="table table-sm table-hover "> <table v-if="performanceStats" class="table table-sm table-hover ">
<thead> <thead>
<tr> <tr>

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div class="card">
<h2>{{ title }}</h2> <div class="card-header">{{ title }}</div>
<table v-if="trades" class="table table-sm table-hover"> <table v-if="trades" class="table table-sm table-hover">
<thead> <thead>
<tr> <tr>
@ -9,8 +9,8 @@
<th>Amount</th> <th>Amount</th>
<th>Stake amount</th> <th>Stake amount</th>
<th>Open rate</th> <th>Open rate</th>
<th>Close rate</th> <th>{{ activeTrades ? 'Current rate' : 'Close rate' }}</th>
<th>Profit</th> <th>{{ activeTrades ? 'Current Profit' : 'Profit' }}</th>
<th>Open date</th> <th>Open date</th>
<th>Close date</th> <th>Close date</th>
</tr> </tr>
@ -22,8 +22,8 @@
<td>{{ trade.amount }}</td> <td>{{ trade.amount }}</td>
<td>{{ trade.stake_amount }}</td> <td>{{ trade.stake_amount }}</td>
<td>{{ trade.open_rate }}</td> <td>{{ trade.open_rate }}</td>
<td>{{ trade.close_rate }}</td> <td>{{ activeTrades ? trade.current_rate : trade.close_rate }}</td>
<td>{{ trade.close_profit }}</td> <td>{{ activeTrades ? trade.current_profit : trade.close_profit.toFixed(3) }}%</td>
<td>{{ trade.open_date }}</td> <td>{{ trade.open_date }}</td>
<td>{{ trade.close_date }}</td> <td>{{ trade.close_date }}</td>
</tr> </tr>
@ -45,6 +45,11 @@ export default {
required: false, required: false,
default: 'Trades', default: 'Trades',
}, },
activeTrades: {
type: Boolean,
required: true,
default: false,
},
}, },
}; };
</script> </script>

View File

@ -4,12 +4,12 @@
<div class="col-md-8"> <div class="col-md-8">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<TradeList :trades="openTrades" title="Open trades" /> <TradeList :trades="openTrades" title="Open trades" activeTrades="True" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<TradeList :trades="trades" /> <TradeList :trades="closedtrades" title="Trade history" />
</div> </div>
</div> </div>
</div> </div>
@ -58,27 +58,27 @@ export default {
data() { data() {
return { return {
refresh_interval: null, refresh_interval: null,
} };
}, },
computed: { computed: {
...mapState('ftbot', ['trades', 'open_trades']), ...mapState('ftbot', ['open_trades']),
...mapGetters('ftbot', ['openTrades']), ...mapGetters('ftbot', ['openTrades', 'closedtrades']),
}, },
methods: { methods: {
...mapActions(['refresh_all']), ...mapActions(['refresh_all']),
...mapActions('ftbot', ['getTrades', 'getProfit', 'getState']), ...mapActions('ftbot', ['getTrades', 'getProfit', 'getState']),
}, },
mounted() { mounted() {
console.log(`Starting automatic refresh.`) console.log(`Starting automatic refresh.`);
this.refresh_interval = setInterval(() => { this.refresh_interval = setInterval(() => {
this.refresh_all(); this.refresh_all();
}, 5000); }, 5000);
}, },
beforeDestroy() { beforeDestroy() {
console.log(`Stopping automatic refresh.`) console.log(`Stopping automatic refresh.`);
clearInterval(this.refresh_interval); clearInterval(this.refresh_interval);
} },
}; };
</script> </script>
<style> <style></style>

View File

@ -30,7 +30,8 @@ export default new Vuex.Store({
}, },
refresh_all({dispatch}) { refresh_all({dispatch}) {
// Refresh all data // Refresh all data
dispatch('ftbot/getState') dispatch('ftbot/getState');
dispatch('ftbot/getOpentrades');
dispatch('ftbot/getTrades'); dispatch('ftbot/getTrades');
dispatch('ftbot/getPerformance'); dispatch('ftbot/getPerformance');
dispatch('ftbot/getProfit'); dispatch('ftbot/getProfit');

View File

@ -6,6 +6,7 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
trades: [], trades: [],
openTrades: [],
trade_count: 0, trade_count: 0,
performanceStats: [], performanceStats: [],
profit: {}, profit: {},
@ -13,14 +14,21 @@ export default {
}, },
getters: { getters: {
openTrades(state) { openTrades(state) {
return state.trades.filter((item) => item.is_open); return state.openTrades;
// return state.trades.filter((item) => item.is_open);
}, },
closedtrades(state) {
return state.trades.filter((item) => !item.is_open);
}
}, },
mutations: { mutations: {
updateTrades(state, trades) { updateTrades(state, trades) {
state.trades = trades.trades; state.trades = trades.trades;
state.trade_count = trades.trade_count; state.trade_count = trades.trade_count;
}, },
updateOpenTrades(state, trades) {
state.openTrades = trades;
},
updatePerformance(state, performance) { updatePerformance(state, performance) {
state.performanceStats = performance; state.performanceStats = performance;
}, },
@ -40,6 +48,13 @@ export default {
.then((result) => commit('updateTrades', result.data)) .then((result) => commit('updateTrades', result.data))
.catch(console.error); .catch(console.error);
}, },
getOpentrades({ commit }) {
axios.get(`${apiBase}/status`, {
...apiAuth
})
.then((result) => commit('updateOpenTrades', result.data))
.catch(console.error);
},
getPerformance({commit}) { getPerformance({commit}) {
axios.get(`${apiBase}/performance`, { axios.get(`${apiBase}/performance`, {
...apiAuth ...apiAuth
@ -62,13 +77,6 @@ export default {
.catch(console.error); .catch(console.error);
}, },
// Post methods // Post methods
stopBot() {
axios.post(`${apiBase}/stop`, {}, {
...apiAuth
})
// .then((result) => )
.catch(console.error);
},
startBot() { startBot() {
axios.post(`${apiBase}/start`, {}, { axios.post(`${apiBase}/start`, {}, {
...apiAuth ...apiAuth
@ -76,6 +84,26 @@ export default {
// .then((result) => ) // .then((result) => )
.catch(console.error); .catch(console.error);
}, },
stopBot() {
axios.post(`${apiBase}/stop`, {}, {
...apiAuth
})
// .then((result) => )
.catch(console.error);
},
stopBuy() {
axios.post(`${apiBase}/stopbuy`, {}, {
...apiAuth
})
// .then((result) => )
.catch(console.error);
},
reloadConfig() {
axios.post(`${apiBase}/reload_conf`, {}, {
...apiAuth
})
// .then((result) => )
.catch(console.error);
},
}, },
}; };

View File

@ -18,4 +18,8 @@ export default {
}; };
</script> </script>
<style scoped></style> <style scoped>
.home {
margin-top: 1.5em;
}
</style>