frequi_origin/src/views/Dashboard.vue

226 lines
6.3 KiB
Vue
Raw Normal View History

2020-08-17 19:16:27 +00:00
<template>
2020-08-29 09:38:43 +00:00
<GridLayout
class="h-100 w-100"
:row-height="50"
:layout="gridLayout"
2020-08-25 17:45:35 +00:00
:vertical-compact="false"
:margin="[5, 5]"
2021-05-28 17:07:34 +00:00
:is-resizable="!getLayoutLocked"
:is-draggable="!getLayoutLocked"
2020-08-29 09:38:43 +00:00
@layout-updated="layoutUpdatedEvent"
>
<GridItem
:i="gridLayoutKPI.i"
:x="gridLayoutKPI.x"
:y="gridLayoutKPI.y"
:w="gridLayoutKPI.w"
:h="gridLayoutKPI.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Bot KPI">
<b-card-group deck>
<b-card header="Open / Total trades">
<b-card-text>
<span class="text-primary">{{ openTrades.length }}</span> /
2020-12-29 09:38:11 +00:00
<span class="text">{{ profit.trade_count }}</span>
</b-card-text>
</b-card>
<b-card header="Won / lost trades">
<b-card-text>
<span class="text-success">{{ profit.winning_trades }}</span> /
<span class="text-danger">{{ profit.losing_trades }}</span>
</b-card-text>
</b-card>
<b-card header="Last trade">
<b-card-text>{{ profit.latest_trade_date }}</b-card-text>
</b-card>
</b-card-group>
<b-card-group deck class="mt-2">
<b-card header="Best performing">
<b-card-text>{{ profit.best_pair }}</b-card-text>
</b-card>
<b-card header="Total Balance">
<b-card-text
>{{ formatPrice(balance.total) }} {{ dailyStats.stake_currency }}</b-card-text
>
</b-card>
<b-card v-if="profit.profit_closed_fiat" header="Total profit">
<b-card-text
>{{ formatPrice(profit.profit_closed_fiat) }}
{{ dailyStats.fiat_display_currency }}</b-card-text
>
</b-card>
</b-card-group>
</DraggableContainer>
</GridItem>
2020-08-18 05:05:40 +00:00
<GridItem
:i="gridLayoutDaily.i"
:x="gridLayoutDaily.x"
:y="gridLayoutDaily.y"
:w="gridLayoutDaily.w"
:h="gridLayoutDaily.h"
2020-08-31 15:47:26 +00:00
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
2020-08-18 05:05:40 +00:00
>
2020-08-31 15:47:26 +00:00
<DraggableContainer header="Daily Profit">
<DailyChart v-if="dailyStats.data" :daily-stats="dailyStats" :show-title="false" />
</DraggableContainer>
2020-08-18 05:05:40 +00:00
</GridItem>
<GridItem
:i="gridLayoutHourly.i"
:x="gridLayoutHourly.x"
:y="gridLayoutHourly.y"
:w="gridLayoutHourly.w"
:h="gridLayoutHourly.h"
2020-08-31 15:47:26 +00:00
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
2020-08-18 05:05:40 +00:00
>
2020-08-31 15:47:26 +00:00
<DraggableContainer header="Hourly Profit">
<HourlyChart :trades="closedTrades" :show-title="false" />
</DraggableContainer>
2020-08-18 05:05:40 +00:00
</GridItem>
<GridItem
:i="gridLayoutCumChart.i"
:x="gridLayoutCumChart.x"
:y="gridLayoutCumChart.y"
:w="gridLayoutCumChart.w"
:h="gridLayoutCumChart.h"
2020-08-31 15:47:26 +00:00
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
2020-08-18 05:05:40 +00:00
>
2020-08-31 15:47:26 +00:00
<DraggableContainer header="Cumulative Profit">
<CumProfitChart :trades="closedTrades" :show-title="false" />
</DraggableContainer>
2020-08-18 05:05:40 +00:00
</GridItem>
2021-01-05 18:29:47 +00:00
<GridItem
:i="gridLayoutTradesLogChart.i"
:x="gridLayoutTradesLogChart.x"
:y="gridLayoutTradesLogChart.y"
:w="gridLayoutTradesLogChart.w"
:h="gridLayoutTradesLogChart.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Trades Log">
<TradesLogChart :trades="closedTrades" :show-title="false" />
</DraggableContainer>
</GridItem>
2020-08-18 05:05:40 +00:00
</GridLayout>
2020-08-17 19:16:27 +00:00
</template>
<script lang="ts">
2020-08-24 20:27:03 +00:00
import { formatPrice } from '@/shared/formatters';
2020-08-17 19:16:27 +00:00
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
2020-08-29 09:38:43 +00:00
import { GridLayout, GridItem, GridItemData } from 'vue-grid-layout';
2020-08-17 19:16:27 +00:00
import DailyChart from '@/components/charts/DailyChart.vue';
import HourlyChart from '@/components/charts/HourlyChart.vue';
2020-08-24 17:28:46 +00:00
import CumProfitChart from '@/components/charts/CumProfitChart.vue';
2021-01-05 18:29:47 +00:00
import TradesLogChart from '@/components/charts/TradesLog.vue';
2020-08-31 15:47:26 +00:00
import DraggableContainer from '@/components/layout/DraggableContainer.vue';
2020-08-17 19:16:27 +00:00
2020-10-06 05:59:05 +00:00
import {
DashboardLayout,
findGridLayout,
LayoutActions,
LayoutGetters,
} from '@/store/modules/layout';
2020-09-03 05:10:08 +00:00
import { Trade, DailyReturnValue, BalanceInterface, ProfitInterface, DailyPayload } from '@/types';
2020-08-17 19:16:27 +00:00
const ftbot = namespace('ftbot');
2020-08-18 06:29:40 +00:00
const layoutNs = namespace('layout');
2020-08-17 19:16:27 +00:00
@Component({
components: {
2020-08-29 09:38:43 +00:00
GridLayout,
GridItem,
2020-08-17 19:16:27 +00:00
DailyChart,
HourlyChart,
2020-08-24 17:28:46 +00:00
CumProfitChart,
2021-01-05 18:29:47 +00:00
TradesLogChart,
2020-08-31 15:47:26 +00:00
DraggableContainer,
2020-08-17 19:16:27 +00:00
},
})
2020-08-18 06:29:40 +00:00
export default class Dashboard extends Vue {
@ftbot.Getter closedTrades!: Trade[];
2020-08-17 19:16:27 +00:00
@ftbot.State dailyStats!: DailyReturnValue;
2020-08-24 20:27:03 +00:00
@ftbot.Getter openTrades!: Array<Trade>;
@ftbot.State balance!: BalanceInterface;
2020-09-03 04:43:41 +00:00
@ftbot.State profit!: ProfitInterface;
2020-08-24 20:27:03 +00:00
@ftbot.State performanceStats!: Array<PerformanceEntry>;
@ftbot.Action getPerformance;
2020-09-08 13:45:01 +00:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2020-09-03 05:10:08 +00:00
@ftbot.Action getDaily!: (payload?: DailyPayload) => void;
2020-08-17 19:16:27 +00:00
@ftbot.Action getTrades;
2020-10-06 05:59:05 +00:00
@layoutNs.Getter [LayoutGetters.getDashboardLayout]!: GridItemData[];
2020-08-18 06:29:40 +00:00
2020-10-06 05:59:05 +00:00
@layoutNs.Action [LayoutActions.setDashboardLayout];
2020-08-18 06:29:40 +00:00
2021-05-28 17:07:34 +00:00
@layoutNs.Getter [LayoutGetters.getLayoutLocked]: boolean;
2020-08-24 20:27:03 +00:00
@ftbot.Action getOpenTrades;
@ftbot.Action getBalance;
@ftbot.Action getProfit;
formatPrice = formatPrice;
get gridLayout() {
2020-08-18 06:29:40 +00:00
return this.getDashboardLayout;
}
2020-08-18 05:05:40 +00:00
get gridLayoutKPI(): GridItemData {
return findGridLayout(this.gridLayout, DashboardLayout.KPI);
}
get gridLayoutDaily(): GridItemData {
2020-08-29 14:43:50 +00:00
return findGridLayout(this.gridLayout, DashboardLayout.dailyChart);
}
get gridLayoutHourly(): GridItemData {
2020-08-29 14:43:50 +00:00
return findGridLayout(this.gridLayout, DashboardLayout.hourlyChart);
}
get gridLayoutCumChart(): GridItemData {
2020-08-29 14:43:50 +00:00
return findGridLayout(this.gridLayout, DashboardLayout.cumChartChart);
}
2021-01-05 18:29:47 +00:00
get gridLayoutTradesLogChart(): GridItemData {
return findGridLayout(this.gridLayout, DashboardLayout.tradesLogChart);
}
2020-08-17 19:16:27 +00:00
mounted() {
2020-09-03 05:10:08 +00:00
this.getDaily({ timescale: 30 });
2020-08-17 19:16:27 +00:00
this.getTrades();
2020-08-24 20:27:03 +00:00
this.getOpenTrades();
this.getBalance();
this.getPerformance();
this.getProfit();
2020-08-17 19:16:27 +00:00
}
2020-08-29 09:38:43 +00:00
2020-08-18 06:29:40 +00:00
layoutUpdatedEvent(newLayout) {
this.setDashboardLayout(newLayout);
2020-08-29 09:38:43 +00:00
}
2020-08-17 19:16:27 +00:00
}
</script>
<style scoped></style>