2020-05-14 05:15:18 +00:00
|
|
|
<template>
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
|
|
|
<div class="mb-2">
|
|
|
|
<label class="mr-auto h3">Balance</label>
|
2022-04-18 17:54:17 +00:00
|
|
|
<b-button class="float-right" size="sm" @click="botStore.activeBot.getBalance"
|
|
|
|
>↻</b-button
|
|
|
|
>
|
2021-05-08 07:47:31 +00:00
|
|
|
<b-form-checkbox
|
|
|
|
v-model="hideSmallBalances"
|
|
|
|
class="float-right"
|
|
|
|
size="sm"
|
|
|
|
title="Hide small balances"
|
|
|
|
button
|
|
|
|
>
|
|
|
|
<HideIcon v-if="hideSmallBalances" :size="16" />
|
|
|
|
<ShowIcon v-else :size="16" />
|
|
|
|
</b-form-checkbox>
|
2020-05-17 18:52:14 +00:00
|
|
|
</div>
|
2022-01-24 18:47:33 +00:00
|
|
|
<BalanceChart v-if="balanceCurrencies" :currencies="balanceCurrencies" />
|
2020-05-22 18:04:27 +00:00
|
|
|
<div>
|
2022-04-18 17:54:17 +00:00
|
|
|
<p v-if="botStore.activeBot.balance.note">
|
|
|
|
<strong>{{ botStore.activeBot.balance.note }}</strong>
|
2020-05-14 05:22:27 +00:00
|
|
|
</p>
|
2021-05-08 07:47:31 +00:00
|
|
|
<b-table class="table-sm" :items="balanceCurrencies" :fields="tableFields">
|
2020-05-14 05:15:18 +00:00
|
|
|
<template slot="bottom-row">
|
2020-05-14 05:16:07 +00:00
|
|
|
<td><strong>Total</strong></td>
|
2022-02-07 19:06:14 +00:00
|
|
|
<td>
|
2022-07-21 05:13:18 +00:00
|
|
|
<span
|
|
|
|
class="font-italic"
|
|
|
|
:title="`Increase over initial capital of ${formatCurrency(
|
|
|
|
botStore.activeBot.balance.starting_capital,
|
|
|
|
)} ${botStore.activeBot.balance.stake}`"
|
|
|
|
>{{ formatPercent(botStore.activeBot.balance.starting_capital_ratio) }}</span
|
|
|
|
>
|
2022-02-07 19:06:14 +00:00
|
|
|
</td>
|
2020-05-14 05:15:18 +00:00
|
|
|
<!-- this is a computed prop that adds up all the expenses in the visible rows -->
|
2020-05-14 05:16:07 +00:00
|
|
|
<td>
|
2022-04-18 17:54:17 +00:00
|
|
|
<strong>{{ formatCurrency(botStore.activeBot.balance.total) }}</strong>
|
2020-05-14 05:16:07 +00:00
|
|
|
</td>
|
2020-05-14 05:15:18 +00:00
|
|
|
</template>
|
|
|
|
</b-table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-08-09 13:07:09 +00:00
|
|
|
<script lang="ts">
|
2021-05-08 07:47:31 +00:00
|
|
|
import HideIcon from 'vue-material-design-icons/EyeOff.vue';
|
|
|
|
import ShowIcon from 'vue-material-design-icons/Eye.vue';
|
2021-12-19 19:06:25 +00:00
|
|
|
import BalanceChart from '@/components/charts/BalanceChart.vue';
|
2022-02-07 19:06:14 +00:00
|
|
|
import { formatPercent } from '@/shared/formatters';
|
2022-07-07 18:44:19 +00:00
|
|
|
import { defineComponent, computed, ref } from 'vue';
|
2022-04-18 17:54:17 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'Balance',
|
2021-12-19 19:06:25 +00:00
|
|
|
components: { HideIcon, ShowIcon, BalanceChart },
|
2022-04-15 18:02:27 +00:00
|
|
|
setup() {
|
2022-04-18 17:54:17 +00:00
|
|
|
const botStore = useBotStore();
|
2022-04-15 18:02:27 +00:00
|
|
|
const hideSmallBalances = ref(true);
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
const smallBalance = computed((): number => {
|
2022-04-18 17:54:17 +00:00
|
|
|
return Number((0.1 ** botStore.activeBot.stakeCurrencyDecimals).toFixed(8));
|
2022-04-15 18:02:27 +00:00
|
|
|
});
|
2020-08-09 13:07:09 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
const balanceCurrencies = computed(() => {
|
|
|
|
if (!hideSmallBalances.value) {
|
2022-04-18 17:54:17 +00:00
|
|
|
return botStore.activeBot.balance.currencies;
|
2022-04-15 18:02:27 +00:00
|
|
|
}
|
2022-01-24 18:36:32 +00:00
|
|
|
|
2022-04-18 17:54:17 +00:00
|
|
|
return botStore.activeBot.balance.currencies?.filter(
|
|
|
|
(v) => v.est_stake >= smallBalance.value,
|
|
|
|
);
|
2022-04-15 18:02:27 +00:00
|
|
|
});
|
2021-05-08 07:47:31 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
const tableFields = computed(() => {
|
|
|
|
return [
|
|
|
|
{ key: 'currency', label: 'Currency' },
|
|
|
|
{ key: 'free', label: 'Available', formatter: 'formatCurrency' },
|
2022-04-18 17:54:17 +00:00
|
|
|
{
|
|
|
|
key: 'est_stake',
|
|
|
|
label: `in ${botStore.activeBot.balance.stake}`,
|
|
|
|
formatter: 'formatCurrency',
|
|
|
|
},
|
2022-04-15 18:02:27 +00:00
|
|
|
];
|
|
|
|
});
|
2021-05-08 07:47:31 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
const formatCurrency = (value) => {
|
|
|
|
return value ? value.toFixed(5) : '';
|
|
|
|
};
|
2021-05-08 07:47:31 +00:00
|
|
|
|
2022-04-15 18:02:27 +00:00
|
|
|
return {
|
2022-04-18 17:54:17 +00:00
|
|
|
botStore,
|
2022-04-15 18:02:27 +00:00
|
|
|
hideSmallBalances,
|
|
|
|
formatPercent,
|
|
|
|
smallBalance,
|
|
|
|
balanceCurrencies,
|
|
|
|
tableFields,
|
|
|
|
formatCurrency,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2020-05-14 05:15:18 +00:00
|
|
|
</script>
|