Add closed trades for all bots to dashboard

closes #763
This commit is contained in:
Matthias 2022-06-19 17:42:24 +02:00
parent 5736654062
commit 7b97e8a565
4 changed files with 43 additions and 7 deletions

View File

@ -97,6 +97,20 @@ export const useBotStore = defineStore('wrapper', {
});
return result;
},
allClosedTradesSelectedBots: (state): Trade[] => {
const result: Trade[] = [];
Object.entries(state.botStores).forEach(([, botStore]) => {
if (botStore.isSelected) {
result.push(...botStore.trades);
}
});
return result.sort((a, b) =>
// Sort by close timestamp, then by tradeid
b.close_timestamp && a.close_timestamp
? b.close_timestamp - a.close_timestamp
: b.trade_id - a.trade_id,
);
},
allTradesSelectedBots: (state): ClosedTrade[] => {
const result: ClosedTrade[] = [];
Object.entries(state.botStores).forEach(([, botStore]) => {

View File

@ -14,6 +14,7 @@ export enum DashboardLayout {
botComparison = 'g-botComparison',
allOpenTrades = 'g-allOpenTrades',
cumChartChart = 'g-cumChartChart',
allClosedTrades = 'g-allClosedTrades',
tradesLogChart = 'g-TradesLogChart',
}
@ -40,7 +41,8 @@ const DEFAULT_DASHBOARD_LAYOUT: GridItemData[] = [
{ i: DashboardLayout.dailyChart, x: 8, y: 0, w: 4, h: 6 },
{ i: DashboardLayout.allOpenTrades, x: 0, y: 6, w: 8, h: 6 },
{ i: DashboardLayout.cumChartChart, x: 8, y: 6, w: 4, h: 6 },
{ i: DashboardLayout.tradesLogChart, x: 0, y: 12, w: 12, h: 4 },
{ i: DashboardLayout.allClosedTrades, x: 0, y: 12, w: 8, h: 6 },
{ i: DashboardLayout.tradesLogChart, x: 0, y: 18, w: 12, h: 4 },
];
const DEFAULT_DASHBOARD_LAYOUT_SM: GridItemData[] = [
@ -49,6 +51,7 @@ const DEFAULT_DASHBOARD_LAYOUT_SM: GridItemData[] = [
{ i: DashboardLayout.dailyChart, x: 0, y: 14, w: 12, h: 6 },
{ i: DashboardLayout.cumChartChart, x: 0, y: 20, w: 12, h: 6 },
{ i: DashboardLayout.tradesLogChart, x: 0, y: 26, w: 12, h: 4 },
{ i: DashboardLayout.allClosedTrades, x: 0, y: 30, w: 12, h: 8 },
];
const STORE_LAYOUTS = 'ftLayoutSettings';

View File

@ -57,11 +57,7 @@
drag-allow-from=".drag-header"
>
<DraggableContainer header="Open Trades">
<trade-list
:active-trades="true"
:trades="botStore.allOpenTradesSelectedBots"
multi-bot-view
/>
<trade-list active-trades :trades="botStore.allOpenTradesSelectedBots" multi-bot-view />
</DraggableContainer>
</GridItem>
<GridItem
@ -78,6 +74,25 @@
<CumProfitChart :trades="botStore.allTradesSelectedBots" :show-title="false" />
</DraggableContainer>
</GridItem>
<GridItem
: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>
</GridItem>
<GridItem
:i="gridLayoutTradesLogChart.i"
:x="gridLayoutTradesLogChart.x"
@ -166,6 +181,9 @@ export default defineComponent({
const gridLayoutAllOpenTrades = computed((): GridItemData => {
return findGridLayout(gridLayout.value, DashboardLayout.allOpenTrades);
});
const gridLayoutAllClosedTrades = computed((): GridItemData => {
return findGridLayout(gridLayout.value, DashboardLayout.allClosedTrades);
});
const gridLayoutCumChart = computed((): GridItemData => {
return findGridLayout(gridLayout.value, DashboardLayout.cumChartChart);
@ -198,6 +216,7 @@ export default defineComponent({
gridLayoutDaily,
gridLayoutBotComparison,
gridLayoutAllOpenTrades,
gridLayoutAllClosedTrades,
gridLayoutCumChart,
gridLayoutTradesLogChart,
responsiveGridLayouts,

View File

@ -85,7 +85,7 @@
drag-allow-from=".card-header"
>
<DraggableContainer header="Closed Trades">
<TradeList
<trade-list
class="trade-history"
:trades="botStore.activeBot.closedTrades"
title="Trade history"