mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 11:35:14 +00:00
Update DailyStats in dashboard
This commit is contained in:
parent
dd44c54c6a
commit
7685703b8c
|
@ -15,9 +15,10 @@
|
|||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import { mapActions, mapState } from 'vuex';
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import DailyChart from '@/components/charts/DailyChart.vue';
|
||||
import { formatPrice } from '@/shared/formatters';
|
||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'DailyStats',
|
||||
|
@ -25,7 +26,7 @@ export default Vue.extend({
|
|||
DailyChart,
|
||||
},
|
||||
computed: {
|
||||
...mapState('ftbot', ['dailyStats']),
|
||||
...mapGetters('ftbot', [BotStoreGetters.dailyStats]),
|
||||
dailyFields() {
|
||||
return [
|
||||
{ key: 'date', label: 'Day' },
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
import { BotDescriptor, BotDescriptors, Trade } from '@/types';
|
||||
import {
|
||||
BotDescriptor,
|
||||
BotDescriptors,
|
||||
DailyPayload,
|
||||
DailyRecord,
|
||||
DailyReturnValue,
|
||||
Trade,
|
||||
} from '@/types';
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { BotStoreActions, BotStoreGetters, createBotSubStore } from './ftbot';
|
||||
|
||||
|
@ -22,6 +29,7 @@ export enum MultiBotStoreGetters {
|
|||
allAvailableBotsList = 'allAvailableBotsList',
|
||||
allTradesAllBots = 'allTradesAllBots',
|
||||
allOpenTradesAllBots = 'allOpenTradesAllBots',
|
||||
allDailyStatsAllBots = 'allDailyStatsAllBots',
|
||||
// Automatically created entries
|
||||
allIsBotOnline = 'allIsBotOnline',
|
||||
allAutoRefresh = 'allAutoRefresh',
|
||||
|
@ -102,6 +110,32 @@ export default function createBotStore(store) {
|
|||
});
|
||||
return resp;
|
||||
},
|
||||
[MultiBotStoreGetters.allDailyStatsAllBots](state: FTMultiBotState, getters): DailyReturnValue {
|
||||
const resp: Record<string, DailyRecord> = {};
|
||||
getters.allAvailableBotsList.forEach((botId) => {
|
||||
const x = getters[`${botId}/${BotStoreGetters.dailyStats}`]?.data?.forEach((d) => {
|
||||
if (!resp[d.date]) {
|
||||
resp[d.date] = { ...d };
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
resp[d.date].abs_profit += d.abs_profit;
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
resp[d.date].fiat_value += d.fiat_value;
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
resp[d.date].trade_count += d.trade_count;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const dailyReturn: DailyReturnValue = {
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
stake_currency: 'USDT',
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
fiat_display_currency: 'USD',
|
||||
data: Object.values(resp),
|
||||
};
|
||||
return dailyReturn;
|
||||
},
|
||||
};
|
||||
// Autocreate getters from botStores
|
||||
Object.keys(BotStoreGetters).forEach((e) => {
|
||||
|
@ -113,7 +147,7 @@ export default function createBotStore(store) {
|
|||
// Create selected getters
|
||||
createAllGetters.forEach((e: string) => {
|
||||
const getterName = `all${e.charAt(0).toUpperCase() + e.slice(1)}`;
|
||||
console.log('creatin ', e, getterName);
|
||||
console.log('creating getter', e, getterName);
|
||||
getters[getterName] = (state, getters) => {
|
||||
const result = {};
|
||||
|
||||
|
@ -267,6 +301,11 @@ export default function createBotStore(store) {
|
|||
dispatch(`${e}/getState`);
|
||||
});
|
||||
},
|
||||
allGetDaily({ getters, dispatch }, payload: DailyPayload) {
|
||||
getters.allAvailableBotsList.forEach((e) => {
|
||||
dispatch(`${e}/getDaily`, payload);
|
||||
});
|
||||
},
|
||||
};
|
||||
// Autocreate Actions from botstores
|
||||
Object.keys(BotStoreActions).forEach((e) => {
|
||||
|
|
|
@ -23,8 +23,12 @@
|
|||
:min-h="4"
|
||||
drag-allow-from=".drag-header"
|
||||
>
|
||||
<DraggableContainer header="Daily Profit">
|
||||
<DailyChart v-if="dailyStats.data" :daily-stats="dailyStats" :show-title="false" />
|
||||
<DraggableContainer :header="`Daily Profit ${botCount > 1 ? 'combined' : ''}`">
|
||||
<DailyChart
|
||||
v-if="allDailyStatsAllBots"
|
||||
:daily-stats="allDailyStatsAllBots"
|
||||
:show-title="false"
|
||||
/>
|
||||
</DraggableContainer>
|
||||
</GridItem>
|
||||
<GridItem
|
||||
|
@ -109,7 +113,6 @@ import {
|
|||
import {
|
||||
Trade,
|
||||
DailyReturnValue,
|
||||
BalanceInterface,
|
||||
ProfitInterface,
|
||||
DailyPayload,
|
||||
BotState,
|
||||
|
@ -136,16 +139,16 @@ const layoutNs = namespace('layout');
|
|||
export default class Dashboard extends Vue {
|
||||
@ftbot.Getter closedTrades!: Trade[];
|
||||
|
||||
@ftbot.Getter [MultiBotStoreGetters.botCount]!: number;
|
||||
|
||||
@ftbot.Getter [MultiBotStoreGetters.allOpenTradesAllBots]!: Trade[];
|
||||
|
||||
@ftbot.Getter [MultiBotStoreGetters.allTradesAllBots]!: ClosedTrade[];
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.dailyStats]!: DailyReturnValue;
|
||||
@ftbot.Getter [MultiBotStoreGetters.allDailyStatsAllBots]!: Record<string, DailyReturnValue>;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.openTrades]!: Array<Trade>;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.balance]!: BalanceInterface;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.botState]?: BotState;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.profit]!: ProfitInterface;
|
||||
|
@ -155,7 +158,7 @@ export default class Dashboard extends Vue {
|
|||
@ftbot.Action getPerformance;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action getDaily!: (payload?: DailyPayload) => void;
|
||||
@ftbot.Action allGetDaily!: (payload?: DailyPayload) => void;
|
||||
|
||||
@ftbot.Action getTrades;
|
||||
|
||||
|
@ -232,10 +235,9 @@ export default class Dashboard extends Vue {
|
|||
}
|
||||
|
||||
mounted() {
|
||||
this.getDaily({ timescale: 30 });
|
||||
this.allGetDaily({ timescale: 30 });
|
||||
this.getTrades();
|
||||
this.getOpenTrades();
|
||||
this.getBalance();
|
||||
this.getPerformance();
|
||||
this.getProfit();
|
||||
this.localGridLayout = [...this.getDashboardLayoutSm];
|
||||
|
|
Loading…
Reference in New Issue
Block a user