浏览代码

Update formatter calls in management, trading, and info commands to use async/await for improved performance and consistency. This change enhances the responsiveness of price and amount formatting across various commands, ensuring accurate and timely data presentation.

Carles Sentis 3 天之前
父节点
当前提交
c1bc58f760

+ 2 - 2
src/commands/info/balance_adjustments.py

@@ -39,7 +39,7 @@ class BalanceAdjustmentsCommands(InfoCommandsBase):
                 
                 # Format the adjustment
                 amount_emoji = "➕" if amount > 0 else "➖"
-                amount_str = formatter.format_price_with_symbol(abs(amount))
+                amount_str = await formatter.format_price_with_symbol(abs(amount))
                 
                 adjustments_text.append(
                     f"\n{amount_emoji} <b>{amount_str}</b>"
@@ -50,7 +50,7 @@ class BalanceAdjustmentsCommands(InfoCommandsBase):
             # Add summary
             total_adjustments = sum(float(adj.get('amount', 0)) for adj in adjustments)
             total_emoji = "🟢" if total_adjustments >= 0 else "🔴"
-            total_str = formatter.format_price_with_symbol(total_adjustments)
+            total_str = await formatter.format_price_with_symbol(total_adjustments)
             
             adjustments_text.append(f"\n\n💼 <b>Total Adjustments:</b> {total_emoji} {total_str}")
 

+ 3 - 3
src/commands/info/daily.py

@@ -38,7 +38,7 @@ class DailyCommands(InfoCommandsBase):
             for day_stats_item in daily_stats_list:
                 if day_stats_item.get('has_trades'):
                     pnl_emoji = "🟢" if day_stats_item.get('pnl', 0) >= 0 else "🔴"
-                    pnl_str = formatter.format_price_with_symbol(day_stats_item.get('pnl', 0))
+                    pnl_str = await formatter.format_price_with_symbol(day_stats_item.get('pnl', 0))
                     roe = day_stats_item.get('roe', 0.0)  # Get ROE from stats
                     roe_str = f"ROE: {roe:+.1f}%" if roe != 0 else ""
                     day_str = day_stats_item.get('date_formatted', 'Unknown')
@@ -58,8 +58,8 @@ class DailyCommands(InfoCommandsBase):
                 avg_daily_pnl = total_pnl_all_days / trading_days_count
                 avg_daily_roe = total_roe_all_days / trading_days_count
                 avg_pnl_emoji = "🟢" if avg_daily_pnl >= 0 else "🔴"
-                total_pnl_all_days_str = formatter.format_price_with_symbol(total_pnl_all_days)
-                avg_daily_pnl_str = formatter.format_price_with_symbol(avg_daily_pnl)
+                total_pnl_all_days_str = await formatter.format_price_with_symbol(total_pnl_all_days)
+                avg_daily_pnl_str = await formatter.format_price_with_symbol(avg_daily_pnl)
 
                 daily_text_parts.append(f"\n\n📈 <b>Period Summary:</b>")
                 daily_text_parts.append(f"  Total P&L: {avg_pnl_emoji} {total_pnl_all_days_str} | Avg Daily: {avg_daily_pnl_str}")

+ 8 - 8
src/commands/info/market.py

@@ -76,9 +76,9 @@ class MarketCommands(InfoCommandsBase):
             
             # Add price information
             message += "💰 <b>Price Information:</b>\n"
-            message += f"Last Price: {self.formatter.format_price_with_symbol(last_price)}\n"
-            message += f"24h High: {self.formatter.format_price_with_symbol(high_price)}{percent_from_high_str}\n"
-            message += f"24h Low: {self.formatter.format_price_with_symbol(low_price)}{percent_from_low_str}\n"
+            message += f"Last Price: {await self.formatter.format_price_with_symbol(last_price)}\n"
+            message += f"24h High: {await self.formatter.format_price_with_symbol(high_price)}{percent_from_high_str}\n"
+            message += f"24h Low: {await self.formatter.format_price_with_symbol(low_price)}{percent_from_low_str}\n"
             message += f"24h Change: {change_24h:.2f}%\n"
             
             # Add leverage information if available
@@ -89,8 +89,8 @@ class MarketCommands(InfoCommandsBase):
             
             # Add volume information
             message += f"\n📈 <b>Volume Information:</b>\n"
-            message += f"24h Volume: {self.formatter.format_amount(float(ticker_info.get('dayBaseVlm', 0)), token)}\n"
-            message += f"24h Turnover: {self.formatter.format_price_with_symbol(float(ticker_info.get('dayNtlVlm', 0)))}\n"
+            message += f"24h Volume: {await self.formatter.format_amount(float(ticker_info.get('dayBaseVlm', 0)), token)}\n"
+            message += f"24h Turnover: {await self.formatter.format_price_with_symbol(float(ticker_info.get('dayNtlVlm', 0)))}\n"
             
             # Add order book information if available
             if orderbook:
@@ -98,9 +98,9 @@ class MarketCommands(InfoCommandsBase):
                 ask = ticker.get('ask', 0)
                 spread = ask - bid if ask and bid else 0
                 message += f"\n📚 <b>Order Book:</b>\n"
-                message += f"Bid: {self.formatter.format_price_with_symbol(bid)}\n"
-                message += f"Ask: {self.formatter.format_price_with_symbol(ask)}\n"
-                message += f"Spread: {self.formatter.format_price_with_symbol(spread)}\n"
+                message += f"Bid: {await self.formatter.format_price_with_symbol(bid)}\n"
+                message += f"Ask: {await self.formatter.format_price_with_symbol(ask)}\n"
+                message += f"Spread: {await self.formatter.format_price_with_symbol(spread)}\n"
             
             await context.bot.edit_message_text(chat_id=sent_message.chat.id, message_id=sent_message.message_id, text=message.strip(), parse_mode='HTML')
             

+ 3 - 3
src/commands/info/monthly.py

@@ -38,7 +38,7 @@ class MonthlyCommands(InfoCommandsBase):
             for month_stats_item in monthly_stats_list:
                 if month_stats_item['has_trades']:
                     pnl_emoji = "🟢" if month_stats_item['pnl'] >= 0 else "🔴"
-                    pnl_str = formatter.format_price_with_symbol(month_stats_item['pnl'])
+                    pnl_str = await formatter.format_price_with_symbol(month_stats_item['pnl'])
                     roe = month_stats_item.get('roe', 0.0)  # Get ROE from stats
                     roe_str = f"ROE: {roe:+.1f}%" if roe != 0 else ""
                     period_lines.append(f"📅 <b>{month_stats_item['month_formatted']}</b>: {pnl_emoji} {pnl_str} ({month_stats_item['pnl_pct']:+.1f}%) {roe_str} | Trades: {month_stats_item['trades']}")
@@ -56,8 +56,8 @@ class MonthlyCommands(InfoCommandsBase):
                 avg_monthly_pnl = total_pnl_all_months / trading_months_count
                 avg_monthly_roe = total_roe_all_months / trading_months_count
                 avg_pnl_emoji = "🟢" if avg_monthly_pnl >= 0 else "🔴"
-                total_pnl_all_months_str = formatter.format_price_with_symbol(total_pnl_all_months)
-                avg_monthly_pnl_str = formatter.format_price_with_symbol(avg_monthly_pnl)
+                total_pnl_all_months_str = await formatter.format_price_with_symbol(total_pnl_all_months)
+                avg_monthly_pnl_str = await formatter.format_price_with_symbol(avg_monthly_pnl)
 
                 monthly_text_parts.append(f"\n\n📈 <b>Period Summary:</b>")
                 monthly_text_parts.append(f"  Total P&L: {avg_pnl_emoji} {total_pnl_all_months_str} | Avg Monthly: {avg_monthly_pnl_str}")

+ 3 - 3
src/commands/info/orders.py

@@ -43,8 +43,8 @@ class OrdersCommands(InfoCommandsBase):
 
                     # Format order details
                     formatter = self._get_formatter()
-                    price_str = formatter.format_price_with_symbol(price, base_asset)
-                    amount_str = formatter.format_amount(remaining, base_asset)
+                    price_str = await formatter.format_price_with_symbol(price, base_asset)
+                    amount_str = await formatter.format_amount(remaining, base_asset)
 
                     # Order header
                     side_emoji = "🟢" if side == "BUY" else "🔴"
@@ -56,7 +56,7 @@ class OrdersCommands(InfoCommandsBase):
                     if order_type == "STOP_LOSS" or order_type == "TAKE_PROFIT":
                         trigger_price = order.get('info', {}).get('triggerPrice')
                         if trigger_price:
-                            trigger_price_str = formatter.format_price_with_symbol(float(trigger_price), base_asset)
+                            trigger_price_str = await formatter.format_price_with_symbol(float(trigger_price), base_asset)
                             orders_text += f"   🎯 Trigger: {trigger_price_str}\n"
 
                     # Add order ID

+ 10 - 11
src/commands/info/performance.py

@@ -140,7 +140,7 @@ class PerformanceCommands(InfoCommandsBase):
             # Check if there's a message (no completed trades)
             perf_summary = token_stats.get('performance_summary', {})
             if 'message' in token_stats and perf_summary.get('completed_trades', 0) == 0:
-                total_volume_str = formatter.format_price_with_symbol(token_stats.get('total_volume', 0), quote_asset=Config.QUOTE_CURRENCY)
+                total_volume_str = await formatter.format_price_with_symbol(token_stats.get('total_volume', 0), token)
                 await self._reply(update,
                     f"📊 <b>{token} Performance</b>\n\n"
                     f"{token_stats['message']}\n\n"
@@ -159,13 +159,13 @@ class PerformanceCommands(InfoCommandsBase):
             perf_summary = token_stats.get('performance_summary', {})
             pnl_emoji = "🟢" if perf_summary.get('total_pnl', 0) >= 0 else "🔴"
             
-            total_pnl_str = formatter.format_price_with_symbol(perf_summary.get('total_pnl', 0))
-            completed_volume_str = formatter.format_price_with_symbol(perf_summary.get('completed_entry_volume', 0))
-            expectancy_str = formatter.format_price_with_symbol(perf_summary.get('expectancy', 0))
-            largest_win_str = formatter.format_price_with_symbol(perf_summary.get('largest_win', 0))
-            largest_loss_str = formatter.format_price_with_symbol(perf_summary.get('largest_loss', 0))
-            avg_win_str = formatter.format_price_with_symbol(perf_summary.get('avg_win', 0))
-            avg_loss_str = formatter.format_price_with_symbol(perf_summary.get('avg_loss', 0))
+            total_pnl_str = await formatter.format_price_with_symbol(perf_summary.get('total_pnl', 0), token)
+            completed_volume_str = await formatter.format_price_with_symbol(perf_summary.get('completed_entry_volume', 0), token)
+            expectancy_str = await formatter.format_price_with_symbol(perf_summary.get('expectancy', 0), token)
+            largest_win_str = await formatter.format_price_with_symbol(perf_summary.get('largest_win', 0), token)
+            largest_loss_str = await formatter.format_price_with_symbol(perf_summary.get('largest_loss', 0), token)
+            avg_win_str = await formatter.format_price_with_symbol(perf_summary.get('avg_win', 0), token)
+            avg_loss_str = await formatter.format_price_with_symbol(perf_summary.get('avg_loss', 0), token)
             
             # Calculate ROE (Return on Equity)
             entry_vol = perf_summary.get('completed_entry_volume', 0)
@@ -208,14 +208,13 @@ class PerformanceCommands(InfoCommandsBase):
                     
                     # trade_symbol is required for format_price and format_amount
                     trade_symbol = trade.get('symbol', token) # Fallback to token if symbol not in trade dict
-                    trade_base_asset = trade_symbol.split('/')[0] if '/' in trade_symbol else trade_symbol
                     
                     # Formatting trade value. Assuming 'value' is in quote currency.
-                    trade_value_str = formatter.format_price_with_symbol(trade.get('value', 0))
+                    trade_value_str = await formatter.format_price_with_symbol(trade.get('value', 0), trade_symbol.split('/')[0])
                     
                     pnl_display_str = ""
                     if trade.get('pnl', 0) != 0:
-                        trade_pnl_str = formatter.format_price_with_symbol(trade.get('pnl', 0))
+                        trade_pnl_str = await formatter.format_price_with_symbol(trade.get('pnl', 0), trade_symbol.split('/')[0])
                         pnl_display_str = f" | P&L: {trade_pnl_str}"
                     
                     performance_text += f"• {side_emoji} {trade['side'].upper()} {trade_value_str} @ {trade_time}{pnl_display_str}\n"

+ 6 - 6
src/commands/info/positions.py

@@ -157,11 +157,11 @@ class PositionsCommands(InfoCommandsBase):
                     formatter = self._get_formatter()
 
                     # Get price precisions
-                    entry_price_str = formatter.format_price_with_symbol(entry_price, base_asset)
-                    mark_price_str = formatter.format_price_with_symbol(mark_price, base_asset)
+                    entry_price_str = await formatter.format_price_with_symbol(entry_price, base_asset)
+                    mark_price_str = await formatter.format_price_with_symbol(mark_price, base_asset)
 
                     # Get amount precision for position size
-                    size_str = formatter.format_amount(abs_current_amount, base_asset)
+                    size_str = await formatter.format_amount(abs_current_amount, base_asset)
 
                     type_indicator = ""
                     if position_trade.get('trade_lifecycle_id'):
@@ -192,18 +192,18 @@ class PositionsCommands(InfoCommandsBase):
                     
                     # Show exchange-provided risk data if available
                     if position_trade.get('liquidation_price') is not None and position_trade.get('liquidation_price') > 0:
-                        liq_price_str = formatter.format_price_with_symbol(position_trade.get('liquidation_price'), base_asset)
+                        liq_price_str = await formatter.format_price_with_symbol(position_trade.get('liquidation_price'), base_asset)
                         positions_text += f"   ⚠️ Liquidation: {liq_price_str}\n"
                     
                     # Show stop loss if linked in database
                     if position_trade.get('stop_loss_price'):
                         sl_price = position_trade['stop_loss_price']
-                        positions_text += f"   🛑 Stop Loss: {formatter.format_price_with_symbol(sl_price, base_asset)}\n"
+                        positions_text += f"   🛑 Stop Loss: {await formatter.format_price_with_symbol(sl_price, base_asset)}\n"
                     
                     # Show take profit if linked in database
                     if position_trade.get('take_profit_price'):
                         tp_price = position_trade['take_profit_price']
-                        positions_text += f"   🎯 Take Profit: {formatter.format_price_with_symbol(tp_price, base_asset)}\n"
+                        positions_text += f"   🎯 Take Profit: {await formatter.format_price_with_symbol(tp_price, base_asset)}\n"
                     
                     positions_text += f"   🆔 Lifecycle ID: {position_trade['trade_lifecycle_id'][:8]}\n\n"
 

+ 3 - 3
src/commands/info/price.py

@@ -36,7 +36,7 @@ class PriceCommands(InfoCommandsBase):
 
             # Current price
             current_price = float(ticker.get('last', 0))
-            price_text_parts.append(f"\n📊 <b>Current Price:</b> {formatter.format_price_with_symbol(current_price, token)}")
+            price_text_parts.append(f"\n📊 <b>Current Price:</b> {await formatter.format_price_with_symbol(current_price, token)}")
 
             # 24h change
             change_24h = float(ticker.get('percentage', 0))
@@ -46,11 +46,11 @@ class PriceCommands(InfoCommandsBase):
             # 24h high/low
             high_24h = float(ticker.get('high', 0))
             low_24h = float(ticker.get('low', 0))
-            price_text_parts.append(f"📊 <b>24h Range:</b> {formatter.format_price_with_symbol(low_24h, token)} - {formatter.format_price_with_symbol(high_24h, token)}")
+            price_text_parts.append(f"📊 <b>24h Range:</b> {await formatter.format_price_with_symbol(low_24h, token)} - {await formatter.format_price_with_symbol(high_24h, token)}")
 
             # Volume
             volume_24h = float(ticker.get('quoteVolume', 0))
-            price_text_parts.append(f"💎 <b>24h Volume:</b> {formatter.format_price_with_symbol(volume_24h)}")
+            price_text_parts.append(f"💎 <b>24h Volume:</b> {await formatter.format_price_with_symbol(volume_24h)}")
 
             await self._reply(update, "\n".join(price_text_parts))
 

+ 8 - 8
src/commands/info/risk.py

@@ -92,10 +92,10 @@ class RiskCommands(InfoCommandsBase):
                     pnl_emoji = "🟢" if risk['unrealized_pnl'] >= 0 else "🔴"
                     message += (
                         f"\n<b>{risk['symbol']}</b>\n"
-                        f"Size: {self.formatter.format_amount(risk['size'])}\n"
-                        f"Entry: {self.formatter.format_price_with_symbol(risk['entry_price'])}\n"
-                        f"Mark: {self.formatter.format_price_with_symbol(risk['mark_price'])}\n"
-                        f"P&L: {pnl_emoji} {self.formatter.format_price_with_symbol(risk['unrealized_pnl'])}\n"
+                        f"Size: {await self.formatter.format_amount(risk['size'], risk['symbol'].split('/')[0])}\n"
+                        f"Entry: {await self.formatter.format_price_with_symbol(risk['entry_price'], risk['symbol'].split('/')[0])}\n"
+                        f"Mark: {await self.formatter.format_price_with_symbol(risk['mark_price'], risk['symbol'].split('/')[0])}\n"
+                        f"P&L: {pnl_emoji} {await self.formatter.format_price_with_symbol(risk['unrealized_pnl'], risk['symbol'].split('/')[0])}\n"
                         f"Price Risk: {risk['price_risk']:.2f}%\n"
                         f"Liquidation Risk: {risk['liquidation_risk']:.2f}%\n"
                         f"Stop Loss Risk: {risk['stop_loss_risk']:.2f}%\n"
@@ -105,8 +105,8 @@ class RiskCommands(InfoCommandsBase):
             
             # Add portfolio summary
             message += f"\n📈 <b>Portfolio Summary:</b>\n"
-            message += f"Total Value: {self.formatter.format_price_with_symbol(portfolio_value)}\n"
-            message += f"Unrealized P&L: {self.formatter.format_price_with_symbol(total_unrealized_pnl)}\n"
+            message += f"Total Value: {await self.formatter.format_price_with_symbol(portfolio_value)}\n"
+            message += f"Unrealized P&L: {await self.formatter.format_price_with_symbol(total_unrealized_pnl)}\n"
             message += f"Portfolio Risk: {portfolio_risk:.2f}%\n"
             
             # Add trading statistics
@@ -114,8 +114,8 @@ class RiskCommands(InfoCommandsBase):
                 message += f"\n📊 <b>Trading Statistics:</b>\n"
                 message += f"Win Rate: {stats.get('win_rate', 0):.2f}%\n"
                 message += f"Profit Factor: {stats.get('profit_factor', 0):.2f}\n"
-                message += f"Average Win: {self.formatter.format_price_with_symbol(stats.get('avg_win', 0))}\n"
-                message += f"Average Loss: {self.formatter.format_price_with_symbol(stats.get('avg_loss', 0))}\n"
+                message += f"Average Win: {await self.formatter.format_price_with_symbol(stats.get('avg_win', 0))}\n"
+                message += f"Average Loss: {await self.formatter.format_price_with_symbol(stats.get('avg_loss', 0))}\n"
             
             await update.message.reply_text(message, parse_mode='HTML')
             

+ 17 - 17
src/commands/info/stats.py

@@ -31,15 +31,15 @@ class StatsCommands(InfoCommandsBase):
         # --- Account Overview ---
         account_lines = [
             f"💰 <b>{token_name.upper()} Account Overview:</b>",
-            f"• Current Balance: {formatter.format_price_with_symbol(perf_summary.get('current_balance', 0.0))}",
-            f"• Initial Balance: {formatter.format_price_with_symbol(perf_summary.get('initial_balance', 0.0))}",
+            f"• Current Balance: {await formatter.format_price_with_symbol(perf_summary.get('current_balance', 0.0))}",
+            f"• Initial Balance: {await formatter.format_price_with_symbol(perf_summary.get('initial_balance', 0.0))}",
             f"• Open Positions: {len(open_positions)}",
         ]
         total_pnl = perf_summary.get('total_pnl', 0.0)
         entry_vol = perf_summary.get('completed_entry_volume', 0.0)
         total_pnl_pct = (total_pnl / entry_vol * 100) if entry_vol > 0 else 0.0
         pnl_emoji = "🟢" if total_pnl >= 0 else "🔴"
-        account_lines.append(f"• {pnl_emoji} Total P&L: {formatter.format_price_with_symbol(total_pnl)} ({total_pnl_pct:+.2f}%)")
+        account_lines.append(f"• {pnl_emoji} Total P&L: {await formatter.format_price_with_symbol(total_pnl)} ({total_pnl_pct:+.2f}%)")
         account_lines.append(f"• Days Active: {perf_summary.get('days_active', 0)}")
 
         # --- Performance Metrics ---
@@ -47,13 +47,13 @@ class StatsCommands(InfoCommandsBase):
             "🏆 <b>Performance Metrics:</b>",
             f"• Total Completed Trades: {perf_summary.get('completed_trades', 0)}",
             f"• Win Rate: {perf_summary.get('win_rate', 0.0):.1f}% ({perf_summary.get('total_wins', 0)}/{perf_summary.get('completed_trades', 0)})",
-            f"• Trading Volume (Entry Vol.): {formatter.format_price_with_symbol(perf_summary.get('completed_entry_volume', 0.0))}",
+            f"• Trading Volume (Entry Vol.): {await formatter.format_price_with_symbol(perf_summary.get('completed_entry_volume', 0.0))}",
             f"• Profit Factor: {perf_summary.get('profit_factor', 0.0):.2f}",
-            f"• Expectancy: {formatter.format_price_with_symbol(perf_summary.get('expectancy', 0.0))}",
-            f"• Largest Winning Trade: {formatter.format_price_with_symbol(perf_summary.get('largest_win', 0.0))} ({perf_summary.get('largest_win_pct', 0.0):+.2f}%)",
-            f"• Largest Losing Trade: {formatter.format_price_with_symbol(perf_summary.get('largest_loss', 0.0))}",
-            f"• Best ROE Trade: {formatter.format_price_with_symbol(perf_summary.get('best_roe_trade', 0.0))} ({perf_summary.get('best_roe_trade_pct', 0.0):+.2f}%)",
-            f"• Worst ROE Trade: {formatter.format_price_with_symbol(perf_summary.get('worst_roe_trade', 0.0))} ({perf_summary.get('worst_roe_trade_pct', 0.0):+.2f}%)",
+            f"• Expectancy: {await formatter.format_price_with_symbol(perf_summary.get('expectancy', 0.0))}",
+            f"• Largest Winning Trade: {await formatter.format_price_with_symbol(perf_summary.get('largest_win', 0.0))} ({perf_summary.get('largest_win_pct', 0.0):+.2f}%)",
+            f"• Largest Losing Trade: {await formatter.format_price_with_symbol(perf_summary.get('largest_loss', 0.0))}",
+            f"• Best ROE Trade: {await formatter.format_price_with_symbol(perf_summary.get('best_roe_trade', 0.0))} ({perf_summary.get('best_roe_trade_pct', 0.0):+.2f}%)",
+            f"• Worst ROE Trade: {await formatter.format_price_with_symbol(perf_summary.get('worst_roe_trade', 0.0))} ({perf_summary.get('worst_roe_trade_pct', 0.0):+.2f}%)",
             f"• Average Trade Duration: {perf_summary.get('avg_trade_duration', 'N/A')}",
             f"• Max Drawdown: {perf_summary.get('max_drawdown', 0.0):.2f}% <i>(Live)</i>",
         ]
@@ -129,27 +129,27 @@ class StatsCommands(InfoCommandsBase):
 
             # Account Overview
             stats_text_parts.append("💰 <b>Account Overview:</b>")
-            stats_text_parts.append(f"• Current Balance: {formatter.format_price_with_symbol(current_balance)}")
+            stats_text_parts.append(f"• Current Balance: {await formatter.format_price_with_symbol(current_balance)}")
             stats_text_parts.append(f"• Open Positions: {perf.get('open_positions', 0)}")
-            stats_text_parts.append(f"• Total P&L: {formatter.format_price_with_symbol(perf.get('total_pnl', 0))}")
+            stats_text_parts.append(f"• Total P&L: {await formatter.format_price_with_symbol(perf.get('total_pnl', 0))}")
 
             # Performance Metrics
             stats_text_parts.append("\n🏆 <b>Performance Metrics:</b>")
             stats_text_parts.append(f"• Total Trades: {perf.get('total_trades', 0)}")
             stats_text_parts.append(f"• Win Rate: {perf.get('win_rate', 0.0):.1f}% ({perf.get('total_wins', 0)}/{perf.get('total_trades', 0)})")
-            stats_text_parts.append(f"• Trading Volume: {formatter.format_price_with_symbol(perf.get('total_entry_volume', 0.0))}")
+            stats_text_parts.append(f"• Trading Volume: {await formatter.format_price_with_symbol(perf.get('total_entry_volume', 0.0))}")
             stats_text_parts.append(f"• Profit Factor: {perf.get('profit_factor', 0.0):.2f}")
-            stats_text_parts.append(f"• Expectancy: {formatter.format_price_with_symbol(perf.get('expectancy', 0.0))}")
+            stats_text_parts.append(f"• Expectancy: {await formatter.format_price_with_symbol(perf.get('expectancy', 0.0))}")
 
             # Largest Trades
             stats_text_parts.append("\n📈 <b>Largest Trades:</b>")
-            stats_text_parts.append(f"• Largest Win: {formatter.format_price_with_symbol(perf.get('largest_win', 0.0))} ({perf.get('largest_win_pct', 0.0):+.2f}%) ({perf.get('largest_win_token', 'N/A')})")
-            stats_text_parts.append(f"• Largest Loss: {formatter.format_price_with_symbol(perf.get('largest_loss', 0.0))} ({perf.get('largest_loss_pct', 0.0):+.2f}%) ({perf.get('largest_loss_token', 'N/A')})")
+            stats_text_parts.append(f"• Largest Win: {await formatter.format_price_with_symbol(perf.get('largest_win', 0.0))} ({perf.get('largest_win_pct', 0.0):+.2f}%) ({perf.get('largest_win_token', 'N/A')})")
+            stats_text_parts.append(f"• Largest Loss: {await formatter.format_price_with_symbol(perf.get('largest_loss', 0.0))} ({perf.get('largest_loss_pct', 0.0):+.2f}%) ({perf.get('largest_loss_token', 'N/A')})")
 
             # Best/Worst Tokens
             stats_text_parts.append("\n🏆 <b>Token Performance:</b>")
-            stats_text_parts.append(f"• Best Token: {perf.get('best_token', 'N/A')} {formatter.format_price_with_symbol(perf.get('best_token_pnl', 0.0))} ({perf.get('best_token_pct', 0.0):+.2f}%)")
-            stats_text_parts.append(f"• Worst Token: {perf.get('worst_token', 'N/A')} {formatter.format_price_with_symbol(perf.get('worst_token_pnl', 0.0))} ({perf.get('worst_token_pct', 0.0):+.2f}%)")
+            stats_text_parts.append(f"• Best Token: {perf.get('best_token', 'N/A')} {await formatter.format_price_with_symbol(perf.get('best_token_pnl', 0.0))} ({perf.get('best_token_pct', 0.0):+.2f}%)")
+            stats_text_parts.append(f"• Worst Token: {perf.get('worst_token', 'N/A')} {await formatter.format_price_with_symbol(perf.get('worst_token_pnl', 0.0))} ({perf.get('worst_token_pct', 0.0):+.2f}%)")
 
             # Risk Metrics
             stats_text_parts.append("\n⚠️ <b>Risk Metrics:</b>")

+ 2 - 2
src/commands/info/trades.py

@@ -45,8 +45,8 @@ class TradesCommands(InfoCommandsBase):
 
                     # Format trade details
                     formatter = self._get_formatter()
-                    price_str = formatter.format_price_with_symbol(price, base_asset)
-                    amount_str = formatter.format_amount(amount, base_asset)
+                    price_str = await formatter.format_price_with_symbol(price, base_asset)
+                    amount_str = await formatter.format_amount(amount, base_asset)
 
                     # Trade header
                     side_emoji = "🟢" if side == "BUY" else "🔴"

+ 3 - 3
src/commands/info/weekly.py

@@ -38,7 +38,7 @@ class WeeklyCommands(InfoCommandsBase):
             for week_stats_item in weekly_stats_list:
                 if week_stats_item['has_trades']:
                     pnl_emoji = "🟢" if week_stats_item['pnl'] >= 0 else "🔴"
-                    pnl_str = formatter.format_price_with_symbol(week_stats_item['pnl'])
+                    pnl_str = await formatter.format_price_with_symbol(week_stats_item['pnl'])
                     roe = week_stats_item.get('roe', 0.0)  # Get ROE from stats
                     roe_str = f"ROE: {roe:+.1f}%" if roe != 0 else ""
                     period_lines.append(f"📅 <b>{week_stats_item['week_formatted']}</b>: {pnl_emoji} {pnl_str} ({week_stats_item['pnl_pct']:+.1f}%) {roe_str} | Trades: {week_stats_item['trades']}")
@@ -56,8 +56,8 @@ class WeeklyCommands(InfoCommandsBase):
                 avg_weekly_pnl = total_pnl_all_weeks / trading_weeks_count
                 avg_weekly_roe = total_roe_all_weeks / trading_weeks_count
                 avg_pnl_emoji = "🟢" if avg_weekly_pnl >= 0 else "🔴"
-                total_pnl_all_weeks_str = formatter.format_price_with_symbol(total_pnl_all_weeks)
-                avg_weekly_pnl_str = formatter.format_price_with_symbol(avg_weekly_pnl)
+                total_pnl_all_weeks_str = await formatter.format_price_with_symbol(total_pnl_all_weeks)
+                avg_weekly_pnl_str = await formatter.format_price_with_symbol(avg_weekly_pnl)
 
                 weekly_text_parts.append(f"\n\n📈 <b>Period Summary:</b>")
                 weekly_text_parts.append(f"  Total P&L: {avg_pnl_emoji} {total_pnl_all_weeks_str} | Avg Weekly: {avg_weekly_pnl_str}")

+ 4 - 4
src/commands/management_commands.py

@@ -74,7 +74,7 @@ class ManagementCommands:
 
 💰 <b>Balance Tracking:</b>
 • Total Adjustments: {adjustments_summary['adjustment_count']}
-• Net Adjustment: {formatter.format_price_with_symbol(adjustments_summary['net_adjustment'])}
+• Net Adjustment: {await formatter.format_price_with_symbol(adjustments_summary['net_adjustment'])}
 
 🔔 <b>Price Alarms:</b>
 • Active Alarms: {alarm_stats['total_active']}
@@ -185,9 +185,9 @@ class ManagementCommands:
                 price_diff = abs(target_price - current_price)
                 price_diff_percent = (price_diff / current_price) * 100 if current_price != 0 else 0
                 
-                target_price_str = formatter.format_price_with_symbol(target_price, token)
-                current_price_str = formatter.format_price_with_symbol(current_price, token)
-                price_diff_str = formatter.format_price_with_symbol(price_diff, token)
+                target_price_str = await formatter.format_price_with_symbol(target_price, token)
+                current_price_str = await formatter.format_price_with_symbol(current_price, token)
+                price_diff_str = await formatter.format_price_with_symbol(price_diff, token)
 
                 message = f"""
 ✅ <b>Price Alarm Created</b>

+ 50 - 50
src/commands/trading_commands.py

@@ -108,9 +108,9 @@ class TradingCommands:
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Stop loss price should be BELOW entry price for long positions\n\n"
                     f"📊 Your order:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(price, token)}\n"
-                    f"• Stop Loss: {formatter.format_price_with_symbol(stop_loss_price, token)} ❌\n\n"
-                    f"💡 Try a lower stop loss like: sl:{formatter.format_price(price * 0.95, token)}"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(price, token)}\n"
+                    f"• Stop Loss: {await formatter.format_price_with_symbol(stop_loss_price, token)} ❌\n\n"
+                    f"💡 Try a lower stop loss like: sl:{await formatter.format_price(price * 0.95, token)}"
                 ))
                 return
             
@@ -121,16 +121,16 @@ class TradingCommands:
 
 📊 <b>Order Details:</b>
 • Token: {token}
-• USDC Amount: {formatter.format_price_with_symbol(usdc_amount)}
-• Token Amount: {formatter.format_amount(token_amount, token)} {token}
+• USDC Amount: {await formatter.format_price_with_symbol(usdc_amount)}
+• Token Amount: {await formatter.format_amount(token_amount, token)} {token}
 • Order Type: {order_type}
-• Price: {formatter.format_price_with_symbol(price, token)}
-• Current Price: {formatter.format_price_with_symbol(current_price, token)}
-• Est. Value: {formatter.format_price_with_symbol(token_amount * price)}"""
+• Price: {await formatter.format_price_with_symbol(price, token)}
+• Current Price: {await formatter.format_price_with_symbol(current_price, token)}
+• Est. Value: {await formatter.format_price_with_symbol(token_amount * price)}"""
             
             if stop_loss_price:
                 confirmation_text += f"""
-• 🛑 Stop Loss: {formatter.format_price_with_symbol(stop_loss_price, token)}"""
+• 🛑 Stop Loss: {await formatter.format_price_with_symbol(stop_loss_price, token)}"""
             
             confirmation_text += f"""
 
@@ -229,9 +229,9 @@ This will {"place a limit buy order" if limit_price else "execute a market buy o
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Stop loss price should be ABOVE entry price for short positions\n\n"
                     f"📊 Your order:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(price, token)}\n"
-                    f"• Stop Loss: {formatter.format_price_with_symbol(stop_loss_price, token)} ❌\n\n"
-                    f"💡 Try a higher stop loss like: sl:{formatter.format_price(price * 1.05, token)}"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(price, token)}\n"
+                    f"• Stop Loss: {await formatter.format_price_with_symbol(stop_loss_price, token)} ❌\n\n"
+                    f"💡 Try a higher stop loss like: sl:{await formatter.format_price(price * 1.05, token)}"
                 ))
                 return
             
@@ -242,16 +242,16 @@ This will {"place a limit buy order" if limit_price else "execute a market buy o
 
 📊 <b>Order Details:</b>
 • Token: {token}
-• USDC Amount: {formatter.format_price_with_symbol(usdc_amount)}
-• Token Amount: {formatter.format_amount(token_amount, token)} {token}
+• USDC Amount: {await formatter.format_price_with_symbol(usdc_amount)}
+• Token Amount: {await formatter.format_amount(token_amount, token)} {token}
 • Order Type: {order_type}
-• Price: {formatter.format_price_with_symbol(price, token)}
-• Current Price: {formatter.format_price_with_symbol(current_price, token)}
-• Est. Value: {formatter.format_price_with_symbol(token_amount * price)}"""
+• Price: {await formatter.format_price_with_symbol(price, token)}
+• Current Price: {await formatter.format_price_with_symbol(current_price, token)}
+• Est. Value: {await formatter.format_price_with_symbol(token_amount * price)}"""
             
             if stop_loss_price:
                 confirmation_text += f"""
-• 🛑 Stop Loss: {formatter.format_price_with_symbol(stop_loss_price, token)}"""
+• 🛑 Stop Loss: {await formatter.format_price_with_symbol(stop_loss_price, token)}"""
             
             confirmation_text += f"""
 
@@ -332,15 +332,15 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
 📊 <b>Position Details:</b>
 • Token: {token}
 • Position: {position_type}
-• Size: {formatter.format_amount(contracts, token)} contracts
-• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}
-• Current Price: {formatter.format_price_with_symbol(current_price, token)}
-• {pnl_emoji} Unrealized P&L: {formatter.format_price_with_symbol(unrealized_pnl)}
+• Size: {await formatter.format_amount(contracts, token)} contracts
+• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}
+• Current Price: {await formatter.format_price_with_symbol(current_price, token)}
+• {pnl_emoji} Unrealized P&L: {await formatter.format_price_with_symbol(unrealized_pnl)}
 
 🎯 <b>Exit Order:</b>
 • Action: {exit_side.upper()} (Close {position_type})
-• Amount: {formatter.format_amount(contracts, token)} {token}
-• Est. Value: ~{formatter.format_price_with_symbol(exit_value)}
+• Amount: {await formatter.format_amount(contracts, token)} {token}
+• Est. Value: ~{await formatter.format_price_with_symbol(exit_value)}
 • Order Type: Market Order
 
 ⚠️ <b>Are you sure you want to close this {position_type} position?</b>
@@ -395,9 +395,9 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Stop loss price should be BELOW entry price for long positions\n\n"
                     f"📊 Your {token} LONG position:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}\n"
-                    f"• Stop Price: {formatter.format_price_with_symbol(stop_price, token)} ❌\n\n"
-                    f"💡 Try a lower price like: /sl {token} {formatter.format_price(entry_price * 0.95, token)}\n"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}\n"
+                    f"• Stop Price: {await formatter.format_price_with_symbol(stop_price, token)} ❌\n\n"
+                    f"💡 Try a lower price like: /sl {token} {await formatter.format_price(entry_price * 0.95, token)}\n"
                 ))
                 return
             elif position_type == "SHORT" and stop_price <= entry_price:
@@ -405,9 +405,9 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Stop loss price should be ABOVE entry price for short positions\n\n"
                     f"📊 Your {token} SHORT position:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}\n"
-                    f"• Stop Price: {formatter.format_price_with_symbol(stop_price, token)} ❌\n\n"
-                    f"💡 Try a higher price like: /sl {token} {formatter.format_price(entry_price * 1.05, token)}\n"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}\n"
+                    f"• Stop Price: {await formatter.format_price_with_symbol(stop_price, token)} ❌\n\n"
+                    f"�� Try a higher price like: /sl {token} {await formatter.format_price(entry_price * 1.05, token)}\n"
                 ))
                 return
             
@@ -432,20 +432,20 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
 📊 <b>Position Details:</b>
 • Token: {token}
 • Position: {position_type}
-• Size: {formatter.format_amount(contracts, token)} contracts
-• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}
-• Current Price: {formatter.format_price_with_symbol(current_price, token)}
+• Size: {await formatter.format_amount(contracts, token)} contracts
+• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}
+• Current Price: {await formatter.format_price_with_symbol(current_price, token)}
 
 🎯 <b>Stop Loss Order:</b>
-• Stop Price: {formatter.format_price_with_symbol(stop_price, token)}
+• Stop Price: {await formatter.format_price_with_symbol(stop_price, token)}
 • Action: {exit_side.upper()} (Close {position_type})
-• Amount: {formatter.format_amount(contracts, token)} {token}
+• Amount: {await formatter.format_amount(contracts, token)} {token}
 • Order Type: Limit Order
-• {pnl_emoji} Est. P&L: {formatter.format_price_with_symbol(pnl_at_stop)}
+• {pnl_emoji} Est. P&L: {await formatter.format_price_with_symbol(pnl_at_stop)}
 
 ⚠️ <b>Are you sure you want to set this stop loss?</b>
 
-This will place a limit {exit_side} order at {formatter.format_price_with_symbol(stop_price, token)} to protect your {position_type} position.
+This will place a limit {exit_side} order at {await formatter.format_price_with_symbol(stop_price, token)} to protect your {position_type} position.
             """
             
             keyboard = [
@@ -499,9 +499,9 @@ This will place a limit {exit_side} order at {formatter.format_price_with_symbol
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Take profit price should be ABOVE entry price for long positions\n\n"
                     f"📊 Your {token} LONG position:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}\n"
-                    f"• Take Profit: {formatter.format_price_with_symbol(tp_price, token)} ❌\n\n"
-                    f"💡 Try a higher price like: /tp {token} {formatter.format_price(entry_price * 1.05, token)}\n"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}\n"
+                    f"• Take Profit: {await formatter.format_price_with_symbol(tp_price, token)} ❌\n\n"
+                    f"💡 Try a higher price like: /tp {token} {await formatter.format_price(entry_price * 1.05, token)}\n"
                 ))
                 return
             elif position_type == "SHORT" and tp_price >= entry_price:
@@ -509,9 +509,9 @@ This will place a limit {exit_side} order at {formatter.format_price_with_symbol
                 await context.bot.send_message(chat_id=chat_id, text=(
                     f"⚠️ Take profit price should be BELOW entry price for short positions\n\n"
                     f"📊 Your {token} SHORT position:\n"
-                    f"• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}\n"
-                    f"• Take Profit: {formatter.format_price_with_symbol(tp_price, token)} ❌\n\n"
-                    f"💡 Try a lower price like: /tp {token} {formatter.format_price(entry_price * 0.95, token)}\n"
+                    f"• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}\n"
+                    f"• Take Profit: {await formatter.format_price_with_symbol(tp_price, token)} ❌\n\n"
+                    f"💡 Try a lower price like: /tp {token} {await formatter.format_price(entry_price * 0.95, token)}\n"
                 ))
                 return
             
@@ -536,20 +536,20 @@ This will place a limit {exit_side} order at {formatter.format_price_with_symbol
 📊 <b>Position Details:</b>
 • Token: {token}
 • Position: {position_type}
-• Size: {formatter.format_amount(contracts, token)} contracts
-• Entry Price: {formatter.format_price_with_symbol(entry_price, token)}
-• Current Price: {formatter.format_price_with_symbol(current_price, token)}
+• Size: {await formatter.format_amount(contracts, token)} contracts
+• Entry Price: {await formatter.format_price_with_symbol(entry_price, token)}
+• Current Price: {await formatter.format_price_with_symbol(current_price, token)}
 
 🎯 <b>Take Profit Order:</b>
-• Target Price: {formatter.format_price_with_symbol(tp_price, token)}
+• Target Price: {await formatter.format_price_with_symbol(tp_price, token)}
 • Action: {exit_side.upper()} (Close {position_type})
-• Amount: {formatter.format_amount(contracts, token)} {token}
+• Amount: {await formatter.format_amount(contracts, token)} {token}
 • Order Type: Limit Order
-• {pnl_emoji} Est. P&L: {formatter.format_price_with_symbol(pnl_at_tp)}
+• {pnl_emoji} Est. P&L: {await formatter.format_price_with_symbol(pnl_at_tp)}
 
 ⚠️ <b>Are you sure you want to set this take profit?</b>
 
-This will place a limit {exit_side} order at {formatter.format_price_with_symbol(tp_price, token)} to secure profit on your {position_type} position.
+This will place a limit {exit_side} order at {await formatter.format_price_with_symbol(tp_price, token)} to secure profit on your {position_type} position.
             """
             
             keyboard = [

+ 1 - 1
trading_bot.py

@@ -14,7 +14,7 @@ from datetime import datetime
 from pathlib import Path
 
 # Bot version
-BOT_VERSION = "2.4.232"
+BOT_VERSION = "2.4.233"
 
 # Add src directory to Python path
 sys.path.insert(0, str(Path(__file__).parent / "src"))