From 3470cb2c166277b5a519b0b99125cbb847a6b496 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 18 Sep 2021 19:56:06 +0200 Subject: [PATCH] Add botname to tradeslog --- src/components/charts/TradesLog.vue | 4 ++-- src/store/modules/botStoreWrapper.ts | 2 +- src/store/modules/ftbot/index.ts | 5 +++-- src/types/trades.ts | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/charts/TradesLog.vue b/src/components/charts/TradesLog.vue index 3bd9fcb5..d9d52f4a 100644 --- a/src/components/charts/TradesLog.vue +++ b/src/components/charts/TradesLog.vue @@ -62,7 +62,7 @@ export default class TradesLogChart extends Vue { .sort((a, b) => (a.close_timestamp > b.close_timestamp ? 1 : -1)); for (let i = 0, len = sortedTrades.length; i < len; i += 1) { const trade = sortedTrades[i]; - const entry = [i, (trade.profit_ratio * 100).toFixed(2), trade.pair]; + const entry = [i, (trade.profit_ratio * 100).toFixed(2), trade.pair, trade.botName]; res.push(entry); } @@ -86,7 +86,7 @@ export default class TradesLogChart extends Vue { tooltip: { trigger: 'axis', formatter: (params) => { - return `Profit %
${params[0].data[1]} % ${params[0].data[2]}`; + return `Profit %
${params[0].data[1]} % ${params[0].data[2]} | ${params[0].data[3]}`; }, axisPointer: { type: 'line', diff --git a/src/store/modules/botStoreWrapper.ts b/src/store/modules/botStoreWrapper.ts index 67bc0db2..c4ae7efb 100644 --- a/src/store/modules/botStoreWrapper.ts +++ b/src/store/modules/botStoreWrapper.ts @@ -196,7 +196,7 @@ export default function createBotStore(store) { return; } console.log('add bot', bot); - store.registerModule(['ftbot', bot.botId], createBotSubStore(bot.botId)); + store.registerModule(['ftbot', bot.botId], createBotSubStore(bot.botId, bot.botName)); dispatch(`${bot.botId}/botAdded`); commit('addBot', bot); }, diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts index 3df0b38a..7c1a88f8 100644 --- a/src/store/modules/ftbot/index.ts +++ b/src/store/modules/ftbot/index.ts @@ -139,10 +139,9 @@ export enum BotStoreActions { logout = 'logout', } -export function createBotSubStore(botId: string) { +export function createBotSubStore(botId: string, botName: string) { const userService = useUserService(botId); const { api } = useApi(userService, botId); - return { namespaced: true, state, @@ -524,6 +523,7 @@ export function createBotSubStore(botId: string) { trades = trades.map((t) => ({ ...t, botId, + botName, botTradeId: `${botId}__${t.trade_id}`, })); commit('updateTrades', { trades, tradesCount }); @@ -579,6 +579,7 @@ export function createBotSubStore(botId: string) { const openTrades = result.data.map((t) => ({ ...t, botId, + botName, botTradeId: `${botId}__${t.trade_id}`, })); diff --git a/src/types/trades.ts b/src/types/trades.ts index cc978cc3..99e1a046 100644 --- a/src/types/trades.ts +++ b/src/types/trades.ts @@ -1,10 +1,16 @@ export interface Trade { /** - * BotId - only available on "all" methods. - * corresponds to the UI (ftbot.1) - does NOT relate to the backend + * corresponds to the UI (ftbot.1) - does NOT relate to the backend! */ botId: string; + /** + * Corresponds to the UI botID + tradeid. Does not relate to backend! + */ botTradeId: string; + /** + * Given bot Name (in the UI). Does not relate to backend! + */ + botName: string; trade_id: number; pair: string; is_open: boolean;