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"
|
2022-04-15 15:53:31 +00:00
|
|
|
:layout="gridLayout"
|
2020-08-25 17:45:35 +00:00
|
|
|
:vertical-compact="false"
|
2020-12-21 18:39:55 +00:00
|
|
|
:margin="[5, 5]"
|
2021-08-20 18:16:16 +00:00
|
|
|
:responsive-layouts="responsiveGridLayouts"
|
|
|
|
:is-resizable="!isLayoutLocked"
|
|
|
|
:is-draggable="!isLayoutLocked"
|
|
|
|
:responsive="true"
|
|
|
|
:prevent-collision="true"
|
2022-01-01 16:22:32 +00:00
|
|
|
:cols="{ lg: 12, md: 12, sm: 12, xs: 4, xxs: 2 }"
|
2022-04-15 15:53:31 +00:00
|
|
|
@layout-updated="layoutUpdatedEvent"
|
2021-08-20 18:16:16 +00:00
|
|
|
@breakpoint-changed="breakpointChanged"
|
2020-08-29 09:38:43 +00:00
|
|
|
>
|
2020-08-18 05:05:40 +00:00
|
|
|
<GridItem
|
2020-08-31 15:48:08 +00:00
|
|
|
: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
|
|
|
>
|
2021-09-18 17:45:26 +00:00
|
|
|
<DraggableContainer :header="`Daily Profit ${botCount > 1 ? 'combined' : ''}`">
|
|
|
|
<DailyChart
|
|
|
|
v-if="allDailyStatsAllBots"
|
|
|
|
:daily-stats="allDailyStatsAllBots"
|
|
|
|
:show-title="false"
|
|
|
|
/>
|
2020-08-31 15:47:26 +00:00
|
|
|
</DraggableContainer>
|
2020-08-18 05:05:40 +00:00
|
|
|
</GridItem>
|
|
|
|
<GridItem
|
2021-09-04 15:10:35 +00:00
|
|
|
:i="gridLayoutBotComparison.i"
|
|
|
|
:x="gridLayoutBotComparison.x"
|
|
|
|
:y="gridLayoutBotComparison.y"
|
|
|
|
:w="gridLayoutBotComparison.w"
|
|
|
|
:h="gridLayoutBotComparison.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
|
|
|
>
|
2021-09-04 15:10:35 +00:00
|
|
|
<DraggableContainer header="Bot comparison">
|
|
|
|
<bot-comparison-list />
|
|
|
|
</DraggableContainer>
|
|
|
|
</GridItem>
|
|
|
|
<GridItem
|
|
|
|
:i="gridLayoutAllOpenTrades.i"
|
|
|
|
:x="gridLayoutAllOpenTrades.x"
|
|
|
|
:y="gridLayoutAllOpenTrades.y"
|
|
|
|
:w="gridLayoutAllOpenTrades.w"
|
|
|
|
:h="gridLayoutAllOpenTrades.h"
|
|
|
|
:min-w="3"
|
|
|
|
:min-h="4"
|
|
|
|
drag-allow-from=".drag-header"
|
|
|
|
>
|
|
|
|
<DraggableContainer header="Open Trades">
|
2021-09-18 18:00:48 +00:00
|
|
|
<trade-list :active-trades="true" :trades="allOpenTradesAllBots" multi-bot-view />
|
2020-08-31 15:47:26 +00:00
|
|
|
</DraggableContainer>
|
2020-08-18 05:05:40 +00:00
|
|
|
</GridItem>
|
|
|
|
<GridItem
|
2020-08-31 15:48:08 +00:00
|
|
|
: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">
|
2021-09-04 14:41:44 +00:00
|
|
|
<CumProfitChart :trades="allTradesAllBots" :show-title="false" />
|
2020-08-31 15:47:26 +00:00
|
|
|
</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">
|
2021-09-18 17:49:36 +00:00
|
|
|
<TradesLogChart :trades="allTradesAllBots" :show-title="false" />
|
2021-01-05 18:29:47 +00:00
|
|
|
</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-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';
|
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';
|
2021-10-28 17:33:08 +00:00
|
|
|
import BotComparisonList from '@/components/ftbot/BotComparisonList.vue';
|
2021-09-04 15:10:35 +00:00
|
|
|
import TradeList from '@/components/ftbot/TradeList.vue';
|
2020-08-31 15:47:26 +00:00
|
|
|
import DraggableContainer from '@/components/layout/DraggableContainer.vue';
|
2020-08-17 19:16:27 +00:00
|
|
|
|
2021-08-26 18:35:33 +00:00
|
|
|
import { BotStoreGetters } from '@/store/modules/ftbot';
|
2021-09-02 18:04:48 +00:00
|
|
|
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
2021-12-20 19:12:57 +00:00
|
|
|
import StoreModules from '@/store/storeSubModules';
|
2020-08-17 19:16:27 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
import { defineComponent, ref, computed, onMounted } from '@vue/composition-api';
|
|
|
|
import { useNamespacedGetters, useNamespacedActions } from 'vuex-composition-helpers';
|
|
|
|
import { DashboardLayout, findGridLayout, useLayoutStore } from '@/stores/layout';
|
2020-08-17 19:16:27 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'Dashboard',
|
2020-08-17 19:16:27 +00:00
|
|
|
components: {
|
2020-08-29 09:38:43 +00:00
|
|
|
GridLayout,
|
|
|
|
GridItem,
|
2020-08-17 19:16:27 +00:00
|
|
|
DailyChart,
|
2020-08-24 17:28:46 +00:00
|
|
|
CumProfitChart,
|
2021-01-05 18:29:47 +00:00
|
|
|
TradesLogChart,
|
2021-09-04 15:10:35 +00:00
|
|
|
BotComparisonList,
|
|
|
|
TradeList,
|
2020-08-31 15:47:26 +00:00
|
|
|
DraggableContainer,
|
2020-08-17 19:16:27 +00:00
|
|
|
},
|
2022-04-15 15:53:31 +00:00
|
|
|
setup() {
|
|
|
|
const {
|
|
|
|
botCount,
|
|
|
|
allOpenTradesAllBots,
|
|
|
|
allTradesAllBots,
|
|
|
|
allDailyStatsAllBots,
|
|
|
|
performanceStats,
|
|
|
|
} = useNamespacedGetters(StoreModules.ftbot, [
|
|
|
|
MultiBotStoreGetters.botCount,
|
|
|
|
MultiBotStoreGetters.allOpenTradesAllBots,
|
|
|
|
MultiBotStoreGetters.allTradesAllBots,
|
|
|
|
MultiBotStoreGetters.allDailyStatsAllBots,
|
|
|
|
BotStoreGetters.performanceStats,
|
|
|
|
]);
|
|
|
|
|
|
|
|
const { getPerformance, allGetDaily, getTrades, getOpenTrades, getProfit } =
|
|
|
|
useNamespacedActions(StoreModules.ftbot, [
|
|
|
|
'getPerformance',
|
|
|
|
'allGetDaily',
|
|
|
|
'getTrades',
|
|
|
|
'getOpenTrades',
|
|
|
|
'getProfit',
|
|
|
|
]);
|
|
|
|
|
|
|
|
const layoutStore = useLayoutStore();
|
|
|
|
const currentBreakpoint = ref('');
|
|
|
|
|
|
|
|
const breakpointChanged = (newBreakpoint) => {
|
|
|
|
// // console.log('breakpoint:', newBreakpoint);
|
|
|
|
currentBreakpoint.value = newBreakpoint;
|
|
|
|
};
|
|
|
|
const isResizableLayout = computed(() =>
|
|
|
|
['', 'sm', 'md', 'lg', 'xl'].includes(currentBreakpoint.value),
|
|
|
|
);
|
|
|
|
const isLayoutLocked = computed(() => {
|
|
|
|
return layoutStore.layoutLocked || !isResizableLayout;
|
|
|
|
});
|
|
|
|
|
|
|
|
const gridLayout = computed((): GridItemData[] => {
|
|
|
|
if (isResizableLayout) {
|
|
|
|
return layoutStore.dashboardLayout;
|
|
|
|
}
|
|
|
|
return [...layoutStore.getDashboardLayoutSm];
|
|
|
|
});
|
|
|
|
|
|
|
|
const layoutUpdatedEvent = (newLayout) => {
|
|
|
|
if (isResizableLayout) {
|
|
|
|
console.log('newlayout', newLayout);
|
|
|
|
console.log('saving dashboard');
|
2022-04-15 17:25:23 +00:00
|
|
|
layoutStore.dashboardLayout = newLayout;
|
2022-04-15 15:53:31 +00:00
|
|
|
}
|
|
|
|
};
|
2021-08-20 18:16:16 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const gridLayoutDaily = computed((): GridItemData => {
|
|
|
|
return findGridLayout(gridLayout.value, DashboardLayout.dailyChart);
|
|
|
|
});
|
2021-08-20 18:16:16 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const gridLayoutBotComparison = computed((): GridItemData => {
|
|
|
|
return findGridLayout(gridLayout.value, DashboardLayout.botComparison);
|
|
|
|
});
|
2020-08-18 05:05:40 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const gridLayoutAllOpenTrades = computed((): GridItemData => {
|
|
|
|
return findGridLayout(gridLayout.value, DashboardLayout.allOpenTrades);
|
|
|
|
});
|
2020-08-31 15:48:08 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const gridLayoutCumChart = computed((): GridItemData => {
|
|
|
|
return findGridLayout(gridLayout.value, DashboardLayout.cumChartChart);
|
|
|
|
});
|
2021-09-04 15:10:35 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const gridLayoutTradesLogChart = computed((): GridItemData => {
|
|
|
|
return findGridLayout(gridLayout.value, DashboardLayout.tradesLogChart);
|
|
|
|
});
|
2020-08-31 15:48:08 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
const responsiveGridLayouts = computed(() => {
|
|
|
|
return {
|
|
|
|
sm: layoutStore.getDashboardLayoutSm,
|
|
|
|
};
|
|
|
|
});
|
2020-08-31 15:48:08 +00:00
|
|
|
|
2022-04-15 15:53:31 +00:00
|
|
|
onMounted(() => {
|
|
|
|
allGetDaily({ timescale: 30 });
|
|
|
|
getTrades();
|
|
|
|
getOpenTrades();
|
|
|
|
getPerformance();
|
|
|
|
getProfit();
|
|
|
|
});
|
2021-01-05 18:29:47 +00:00
|
|
|
|
2021-08-20 18:16:16 +00:00
|
|
|
return {
|
2022-04-15 15:53:31 +00:00
|
|
|
formatPrice,
|
|
|
|
isLayoutLocked,
|
|
|
|
layoutUpdatedEvent,
|
|
|
|
breakpointChanged,
|
|
|
|
gridLayout,
|
|
|
|
gridLayoutDaily,
|
|
|
|
gridLayoutBotComparison,
|
|
|
|
gridLayoutAllOpenTrades,
|
|
|
|
gridLayoutCumChart,
|
|
|
|
gridLayoutTradesLogChart,
|
|
|
|
responsiveGridLayouts,
|
|
|
|
getPerformance,
|
|
|
|
allGetDaily,
|
|
|
|
getTrades,
|
|
|
|
getOpenTrades,
|
|
|
|
getProfit,
|
|
|
|
botCount,
|
|
|
|
allOpenTradesAllBots,
|
|
|
|
allTradesAllBots,
|
|
|
|
allDailyStatsAllBots,
|
|
|
|
performanceStats,
|
2021-08-20 18:16:16 +00:00
|
|
|
};
|
2022-04-15 15:53:31 +00:00
|
|
|
},
|
|
|
|
});
|
2020-08-17 19:16:27 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|