Add botname to tradeslog

This commit is contained in:
Matthias 2021-09-18 19:56:06 +02:00
parent 8eada44433
commit 3470cb2c16
4 changed files with 14 additions and 7 deletions

View File

@ -62,7 +62,7 @@ export default class TradesLogChart extends Vue {
.sort((a, b) => (a.close_timestamp > b.close_timestamp ? 1 : -1)); .sort((a, b) => (a.close_timestamp > b.close_timestamp ? 1 : -1));
for (let i = 0, len = sortedTrades.length; i < len; i += 1) { for (let i = 0, len = sortedTrades.length; i < len; i += 1) {
const trade = sortedTrades[i]; 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); res.push(entry);
} }
@ -86,7 +86,7 @@ export default class TradesLogChart extends Vue {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
formatter: (params) => { formatter: (params) => {
return `Profit %<br>${params[0].data[1]} % ${params[0].data[2]}`; return `Profit %<br>${params[0].data[1]} % ${params[0].data[2]} | ${params[0].data[3]}`;
}, },
axisPointer: { axisPointer: {
type: 'line', type: 'line',

View File

@ -196,7 +196,7 @@ export default function createBotStore(store) {
return; return;
} }
console.log('add bot', bot); 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`); dispatch(`${bot.botId}/botAdded`);
commit('addBot', bot); commit('addBot', bot);
}, },

View File

@ -139,10 +139,9 @@ export enum BotStoreActions {
logout = 'logout', logout = 'logout',
} }
export function createBotSubStore(botId: string) { export function createBotSubStore(botId: string, botName: string) {
const userService = useUserService(botId); const userService = useUserService(botId);
const { api } = useApi(userService, botId); const { api } = useApi(userService, botId);
return { return {
namespaced: true, namespaced: true,
state, state,
@ -524,6 +523,7 @@ export function createBotSubStore(botId: string) {
trades = trades.map((t) => ({ trades = trades.map((t) => ({
...t, ...t,
botId, botId,
botName,
botTradeId: `${botId}__${t.trade_id}`, botTradeId: `${botId}__${t.trade_id}`,
})); }));
commit('updateTrades', { trades, tradesCount }); commit('updateTrades', { trades, tradesCount });
@ -579,6 +579,7 @@ export function createBotSubStore(botId: string) {
const openTrades = result.data.map((t) => ({ const openTrades = result.data.map((t) => ({
...t, ...t,
botId, botId,
botName,
botTradeId: `${botId}__${t.trade_id}`, botTradeId: `${botId}__${t.trade_id}`,
})); }));

View File

@ -1,10 +1,16 @@
export interface Trade { 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; botId: string;
/**
* Corresponds to the UI botID + tradeid. Does not relate to backend!
*/
botTradeId: string; botTradeId: string;
/**
* Given bot Name (in the UI). Does not relate to backend!
*/
botName: string;
trade_id: number; trade_id: number;
pair: string; pair: string;
is_open: boolean; is_open: boolean;