frequi_origin/src/views/Dashboard.vue

223 lines
7.2 KiB
Vue
Raw Normal View History

2020-08-17 19:16:27 +00:00
<template>
<grid-layout
2020-08-29 09:38:43 +00:00
class="h-100 w-100"
:row-height="50"
:layout="gridLayoutData"
2020-08-25 17:45:35 +00:00
:vertical-compact="false"
:margin="[5, 5]"
: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 }"
:col-num="12"
@layout-updated="layoutUpdatedEvent"
@breakpoint-changed="breakpointChanged"
2020-08-29 09:38:43 +00:00
>
<template #default="{ gridItemProps }">
<grid-item
v-bind="gridItemProps"
:i="gridLayoutDaily.i"
:x="gridLayoutDaily.x"
:y="gridLayoutDaily.y"
:w="gridLayoutDaily.w"
:h="gridLayoutDaily.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer :header="`Daily Profit ${botStore.botCount > 1 ? 'combined' : ''}`">
<DailyChart
v-if="botStore.allDailyStatsSelectedBots"
:daily-stats="botStore.allDailyStatsSelectedBots"
:show-title="false"
/>
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
:i="gridLayoutBotComparison.i"
:x="gridLayoutBotComparison.x"
:y="gridLayoutBotComparison.y"
:w="gridLayoutBotComparison.w"
:h="gridLayoutBotComparison.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Bot comparison">
<bot-comparison-list />
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
: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">
<trade-list active-trades :trades="botStore.allOpenTradesSelectedBots" multi-bot-view />
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
:i="gridLayoutCumChart.i"
:x="gridLayoutCumChart.x"
:y="gridLayoutCumChart.y"
:w="gridLayoutCumChart.w"
:h="gridLayoutCumChart.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Cumulative Profit">
<CumProfitChart :trades="botStore.allTradesSelectedBots" :show-title="false" />
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
:i="gridLayoutAllClosedTrades.i"
:x="gridLayoutAllClosedTrades.x"
:y="gridLayoutAllClosedTrades.y"
:w="gridLayoutAllClosedTrades.w"
:h="gridLayoutAllClosedTrades.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Closed Trades">
<trade-list
:active-trades="false"
show-filter
:trades="botStore.allClosedTradesSelectedBots"
multi-bot-view
/>
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
:i="gridLayoutProfitDistribution.i"
:x="gridLayoutProfitDistribution.x"
:y="gridLayoutProfitDistribution.y"
:w="gridLayoutProfitDistribution.w"
:h="gridLayoutProfitDistribution.h"
:min-w="3"
:min-h="4"
drag-allow-from=".drag-header"
>
<DraggableContainer header="Profit Distribution">
<ProfitDistributionChart :trades="botStore.allTradesSelectedBots" :show-title="false" />
</DraggableContainer>
</grid-item>
<grid-item
v-bind="gridItemProps"
: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="botStore.allTradesSelectedBots" :show-title="false" />
</DraggableContainer>
</grid-item>
</template>
</grid-layout>
2020-08-17 19:16:27 +00:00
</template>
2023-02-27 19:10:23 +00:00
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
2020-08-24 20:27:03 +00:00
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';
2022-06-21 17:51:47 +00:00
import ProfitDistributionChart from '@/components/charts/ProfitDistributionChart.vue';
import BotComparisonList from '@/components/ftbot/BotComparisonList.vue';
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
import { DashboardLayout, findGridLayout, useLayoutStore } from '@/stores/layout';
2022-04-19 17:37:04 +00:00
import { useBotStore } from '@/stores/ftbotwrapper';
import { GridItemData } from '@/types';
2020-08-17 19:16:27 +00:00
2023-02-27 19:10:23 +00:00
const botStore = useBotStore();
2023-02-27 19:10:23 +00:00
const layoutStore = useLayoutStore();
const currentBreakpoint = ref('');
2023-02-27 19:10:23 +00:00
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;
});
2023-02-27 19:10:23 +00:00
const gridLayoutData = computed((): GridItemData[] => {
if (isResizableLayout) {
return layoutStore.dashboardLayout;
}
return [...layoutStore.getDashboardLayoutSm];
});
2023-02-27 19:10:23 +00:00
const layoutUpdatedEvent = (newLayout) => {
if (isResizableLayout) {
console.log('newlayout', newLayout);
console.log('saving dashboard');
layoutStore.dashboardLayout = newLayout;
}
};
2023-02-27 19:10:23 +00:00
const gridLayoutDaily = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.dailyChart);
});
2020-08-18 05:05:40 +00:00
2023-02-27 19:10:23 +00:00
const gridLayoutBotComparison = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.botComparison);
});
2023-02-27 19:10:23 +00:00
const gridLayoutAllOpenTrades = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.allOpenTrades);
});
const gridLayoutAllClosedTrades = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.allClosedTrades);
});
2023-02-27 19:10:23 +00:00
const gridLayoutCumChart = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.cumChartChart);
});
const gridLayoutProfitDistribution = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.profitDistributionChart);
});
const gridLayoutTradesLogChart = computed((): GridItemData => {
return findGridLayout(gridLayoutData.value, DashboardLayout.tradesLogChart);
});
2023-02-27 19:10:23 +00:00
const responsiveGridLayouts = computed(() => {
return {
sm: layoutStore.getDashboardLayoutSm,
};
});
2021-01-05 18:29:47 +00:00
2023-02-27 19:10:23 +00:00
onMounted(async () => {
await botStore.allGetDaily({ timescale: 30 });
// botStore.activeBot.getTrades();
botStore.activeBot.getOpenTrades();
botStore.activeBot.getProfit();
});
2020-08-17 19:16:27 +00:00
</script>
<style scoped></style>