Skip to content

Commit 22aa482

Browse files
walletPnL command corrections
1 parent 3483ea7 commit 22aa482

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

services/bot.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ Available chains: _eth, bsc, ftm, avax, cro, arbi, poly, base, sol, sonic_`, { p
243243
const tokenAddress = match[1];
244244
console.log(`[LOG] Fetching price data for token address: ${tokenAddress}`);
245245

246-
bot.sendMessage(chatId, `🔍 Generating 7-day price chart for token: ${tokenAddress}. Please wait...`);
246+
bot.sendMessage(chatId, `🔍 Generating 2W price chart for token: ${tokenAddress}. Please wait...`);
247247

248248
try {
249249
const response = await axios.get(`https://api.vybenetwork.xyz/price/${tokenAddress}/token-ohlcv`, {
@@ -436,33 +436,40 @@ Available chains: _eth, bsc, ftm, avax, cro, arbi, poly, base, sol, sonic_`, { p
436436

437437
message += `*Summary:*\n`;
438438
message += `- *Win Rate:* ${summary.winRate ? (summary.winRate * 100).toFixed(2) + '%' : 'N/A'}\n`;
439-
message += `- *Realized PnL (USD):* $${summary.realizedPnlUsd.toFixed(2)}\n`;
440-
message += `- *Unrealized PnL (USD):* $${summary.unrealizedPnlUsd.toFixed(2)}\n`;
439+
message += `- *Realized PnL (USD):* $${formatValue(summary.realizedPnlUsd)}\n`;
440+
message += `- *Unrealized PnL (USD):* $${formatValue(summary.unrealizedPnlUsd)}\n`;
441441
message += `- *Unique Tokens Traded:* ${summary.uniqueTokensTraded}\n`;
442-
message += `- *Average Trade (USD):* $${summary.averageTradeUsd.toFixed(2)}\n`;
442+
message += `- *Average Trade (USD):* $${formatValue(summary.averageTradeUsd)}\n`;
443443
message += `- *Total Trades:* ${summary.tradesCount}\n`;
444444
message += `- *Winning Trades:* ${summary.winningTradesCount}\n`;
445445
message += `- *Losing Trades:* ${summary.losingTradesCount}\n`;
446-
message += `- *Trades Volume (USD):* $${summary.tradesVolumeUsd.toFixed(2)}\n`;
447-
message += `- *Best Performing Token:* ${summary.bestPerformingToken || 'N/A'}\n`;
448-
message += `- *Worst Performing Token:* ${summary.worstPerformingToken || 'N/A'}\n\n`;
446+
message += `- *Trades Volume (USD):* $${formatValue(summary.tradesVolumeUsd)}\n`;
447+
message += `- *Best Performing Token:* ${summary.bestPerformingToken.tokenSymbol || 'N/A'}\n`;
448+
message += `- *Worst Performing Token:* ${summary.worstPerformingToken.tokenSymbol || 'N/A'}\n\n`;
449449

450450
if (summary.pnlTrendSevenDays.length > 0) {
451451
message += `*PnL Trend (Last 7 Days):*\n`;
452-
summary.pnlTrendSevenDays.forEach((trend: any, index: number) => {
453-
message += ` Day ${index + 1}: $${trend.toFixed(2)}\n`;
452+
summary.pnlTrendSevenDays.forEach((trend: number[], dayIndex: number) => {
453+
const dailyTrend = trend.map(value => `$${formatValue(value)}`).join(', ');
454+
message += ` Day ${dayIndex + 1}: [${dailyTrend}]\n`;
454455
});
455456
message += `\n`;
456457
}
457458

458459
if (tokenMetrics.length > 0) {
459460
message += `*Token Metrics:*\n`;
460461
tokenMetrics.forEach((token: any) => {
461-
message += `🔹 *${token.name} (${token.symbol})*\n`;
462-
message += ` - *Realized PnL (USD):* $${token.realizedPnlUsd.toFixed(2)}\n`;
463-
message += ` - *Unrealized PnL (USD):* $${token.unrealizedPnlUsd.toFixed(2)}\n`;
464-
message += ` - *Trades Count:* ${token.tradesCount}\n`;
465-
message += ` - *Volume (USD):* $${token.volumeUsd.toFixed(2)}\n\n`;
462+
message += `🔹 *${token.tokenSymbol}*\n`;
463+
message += ` - *Realized PnL (USD):* $${formatValue(token.realizedPnlUsd)}\n`;
464+
message += ` - *Unrealized PnL (USD):* $${formatValue(token.unrealizedPnlUsd)}\n`;
465+
message += ` - *Buys:*\n`;
466+
message += ` - *Volume (USD):* $${formatValue(token.buys.volumeUsd)}\n`;
467+
message += ` - *Token Amount:* ${token.buys.tokenAmount}\n`;
468+
message += ` - *Transaction Count:* ${token.buys.transactionCount}\n`;
469+
message += ` - *Sells:*\n`;
470+
message += ` - *Volume (USD):* $${formatValue(token.sells.volumeUsd)}\n`;
471+
message += ` - *Token Amount:* ${token.sells.tokenAmount}\n`;
472+
message += ` - *Transaction Count:* ${token.sells.transactionCount}\n\n`;
466473
});
467474
}
468475

@@ -479,7 +486,7 @@ Available chains: _eth, bsc, ftm, avax, cro, arbi, poly, base, sol, sonic_`, { p
479486
const chatId = msg.chat.id;
480487

481488
// Check if the message starts with '/' and no command matched
482-
if (msg.text?.startsWith('/') && !msg.text.match(/^\/(start|help|echo|time|walletpnl|tokenbalances|analytics|get2wpricechart)/)) {
489+
if (msg.text?.startsWith('/') && !msg.text.match(/^\/(start|help|echo|time|walletpnl|tokenbalances|tokendetail|analytics|get2wpricechart)/)) {
483490
bot.sendMessage(chatId, `⚠️ Unknown command: "${msg.text}". Type /help to see available commands.`);
484491
} else if (!msg.text?.startsWith('/')) {
485492
bot.sendMessage(chatId, `🤖 I received your message: "${msg.text}".\nSince I work only on configured commands, type /help to see available commands.`);

0 commit comments

Comments
 (0)