|
@@ -904,48 +904,49 @@ class InfoCommands:
|
|
|
|
|
|
if not daily_stats:
|
|
|
await context.bot.send_message(chat_id=chat_id, text=
|
|
|
- "๐
<b>Daily Performance</b>\n\n"
|
|
|
- "๐ญ No daily performance data available yet.\n\n"
|
|
|
- "๐ก Daily stats are calculated from completed trades.\n"
|
|
|
- "Start trading to see daily performance!",
|
|
|
+ "๐
<b>Daily Performance</b>\\n"
|
|
|
+ "๐ญ No daily performance data available yet.\\n"
|
|
|
+ "๐ก Daily stats are calculated from completed trades. Start trading to see them!",
|
|
|
parse_mode='HTML'
|
|
|
)
|
|
|
return
|
|
|
|
|
|
- daily_text = "๐
<b>Daily Performance (Last 10 Days)</b>\n\n"
|
|
|
+ daily_text_parts = [f"๐
<b>Daily Performance (Last 10 Days)</b>"]
|
|
|
|
|
|
- total_pnl_all_days = 0 # Renamed to avoid conflict
|
|
|
- total_trades_all_days = 0 # Renamed
|
|
|
- trading_days_count = 0 # Renamed
|
|
|
+ total_pnl_all_days = 0
|
|
|
+ total_trades_all_days = 0
|
|
|
+ trading_days_count = 0
|
|
|
|
|
|
- for day_stats_item in daily_stats: # Renamed to avoid conflict
|
|
|
+ period_lines = []
|
|
|
+ for day_stats_item in daily_stats:
|
|
|
if day_stats_item['has_trades']:
|
|
|
pnl_emoji = "๐ข" if day_stats_item['pnl'] >= 0 else "๐ด"
|
|
|
pnl_str = formatter.format_price_with_symbol(day_stats_item['pnl'])
|
|
|
- daily_text += f"๐ <b>{day_stats_item['date_formatted']}</b>\n"
|
|
|
- daily_text += f" {pnl_emoji} P&L: {pnl_str} ({day_stats_item['pnl_pct']:+.1f}%)\n"
|
|
|
- daily_text += f" ๐ Trades: {day_stats_item['trades']}\n\n"
|
|
|
-
|
|
|
+ period_lines.append(f"๐ <b>{day_stats_item['date_formatted']}</b>: {pnl_emoji} {pnl_str} ({day_stats_item['pnl_pct']:+.1f}%) | Trades: {day_stats_item['trades']}")
|
|
|
total_pnl_all_days += day_stats_item['pnl']
|
|
|
total_trades_all_days += day_stats_item['trades']
|
|
|
trading_days_count += 1
|
|
|
else:
|
|
|
- daily_text += f"๐ <b>{day_stats_item['date_formatted']}</b>\n"
|
|
|
- daily_text += f" ๐ญ No trading activity\n\n"
|
|
|
+ period_lines.append(f"๐ <b>{day_stats_item['date_formatted']}</b>: ๐ญ No trading activity")
|
|
|
|
|
|
+ if period_lines: # Add collected period lines if any
|
|
|
+ daily_text_parts.append("\\n".join(period_lines))
|
|
|
+
|
|
|
if trading_days_count > 0:
|
|
|
avg_daily_pnl = total_pnl_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)
|
|
|
|
|
|
- daily_text += f"๐ <b>Period Summary:</b>\n"
|
|
|
- daily_text += f" {avg_pnl_emoji} Total P&L: {total_pnl_all_days_str}\n"
|
|
|
- daily_text += f" ๐ Trading Days: {trading_days_count}/10\n"
|
|
|
- daily_text += f" ๐
Avg Daily P&L: {avg_daily_pnl_str}\n"
|
|
|
- daily_text += f" ๐ Total Trades: {total_trades_all_days}\n"
|
|
|
-
|
|
|
- await context.bot.send_message(chat_id=chat_id, text=daily_text.strip(), parse_mode='HTML')
|
|
|
+ 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}")
|
|
|
+ daily_text_parts.append(f" Trading Days: {trading_days_count}/10 | Total Trades: {total_trades_all_days}")
|
|
|
+ else:
|
|
|
+ if not period_lines: # If there were no stat items at all, the header is the only part
|
|
|
+ daily_text_parts = [daily_text_parts[0]] # Keep only the title
|
|
|
+ daily_text_parts.append("\\n\\n๐ No trading activity in the last 10 days.")
|
|
|
+
|
|
|
+ await context.bot.send_message(chat_id=chat_id, text="\\n".join(daily_text_parts).strip(), parse_mode='HTML')
|
|
|
|
|
|
except Exception as e:
|
|
|
error_message = f"โ Error processing daily command: {str(e)}"
|
|
@@ -969,34 +970,33 @@ class InfoCommands:
|
|
|
|
|
|
if not weekly_stats_list:
|
|
|
await context.bot.send_message(chat_id=chat_id, text=
|
|
|
- "๐ <b>Weekly Performance</b>\n\n"
|
|
|
- "๐ญ No weekly performance data available yet.\n\n"
|
|
|
- "๐ก Weekly stats are calculated from completed trades.\n"
|
|
|
- "Start trading to see weekly performance!",
|
|
|
+ "๐ <b>Weekly Performance</b>\\n"
|
|
|
+ "๐ญ No weekly performance data available yet.\\n"
|
|
|
+ "๐ก Weekly stats are calculated from completed trades. Start trading to see them!",
|
|
|
parse_mode='HTML'
|
|
|
)
|
|
|
return
|
|
|
|
|
|
- weekly_text = "๐ <b>Weekly Performance (Last 10 Weeks)</b>\n\n"
|
|
|
+ weekly_text_parts = [f"๐ <b>Weekly Performance (Last 10 Weeks)</b>"]
|
|
|
|
|
|
- total_pnl_all_weeks = 0 # Renamed
|
|
|
- total_trades_all_weeks = 0 # Renamed
|
|
|
- trading_weeks_count = 0 # Renamed
|
|
|
+ total_pnl_all_weeks = 0
|
|
|
+ total_trades_all_weeks = 0
|
|
|
+ trading_weeks_count = 0
|
|
|
|
|
|
- for week_stats_item in weekly_stats_list: # Renamed
|
|
|
+ period_lines = []
|
|
|
+ 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'])
|
|
|
- weekly_text += f"๐ <b>{week_stats_item['week_formatted']}</b>\n"
|
|
|
- weekly_text += f" {pnl_emoji} P&L: {pnl_str} ({week_stats_item['pnl_pct']:+.1f}%)\n"
|
|
|
- weekly_text += f" ๐ Trades: {week_stats_item['trades']}\n\n"
|
|
|
-
|
|
|
+ period_lines.append(f"๐ <b>{week_stats_item['week_formatted']}</b>: {pnl_emoji} {pnl_str} ({week_stats_item['pnl_pct']:+.1f}%) | Trades: {week_stats_item['trades']}")
|
|
|
total_pnl_all_weeks += week_stats_item['pnl']
|
|
|
total_trades_all_weeks += week_stats_item['trades']
|
|
|
trading_weeks_count += 1
|
|
|
else:
|
|
|
- weekly_text += f"๐ <b>{week_stats_item['week_formatted']}</b>\n"
|
|
|
- weekly_text += f" ๐ญ No trading activity\n\n"
|
|
|
+ period_lines.append(f"๐ <b>{week_stats_item['week_formatted']}</b>: ๐ญ No trading activity")
|
|
|
+
|
|
|
+ if period_lines:
|
|
|
+ weekly_text_parts.append("\\n".join(period_lines))
|
|
|
|
|
|
if trading_weeks_count > 0:
|
|
|
avg_weekly_pnl = total_pnl_all_weeks / trading_weeks_count
|
|
@@ -1004,13 +1004,15 @@ class InfoCommands:
|
|
|
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)
|
|
|
|
|
|
- weekly_text += f"๐
<b>Period Summary:</b>\n"
|
|
|
- weekly_text += f" {avg_pnl_emoji} Total P&L: {total_pnl_all_weeks_str}\n"
|
|
|
- weekly_text += f" ๐ Trading Weeks: {trading_weeks_count}/10\n"
|
|
|
- weekly_text += f" ๐
Avg Weekly P&L: {avg_weekly_pnl_str}\n"
|
|
|
- weekly_text += f" ๐ Total Trades: {total_trades_all_weeks}\n"
|
|
|
+ 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}")
|
|
|
+ weekly_text_parts.append(f" Trading Weeks: {trading_weeks_count}/10 | Total Trades: {total_trades_all_weeks}")
|
|
|
+ else:
|
|
|
+ if not period_lines:
|
|
|
+ weekly_text_parts = [weekly_text_parts[0]]
|
|
|
+ weekly_text_parts.append("\\n\\n๐ No trading activity in the last 10 weeks.")
|
|
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text=weekly_text.strip(), parse_mode='HTML')
|
|
|
+ await context.bot.send_message(chat_id=chat_id, text="\\n".join(weekly_text_parts).strip(), parse_mode='HTML')
|
|
|
|
|
|
except Exception as e:
|
|
|
error_message = f"โ Error processing weekly command: {str(e)}"
|
|
@@ -1034,34 +1036,33 @@ class InfoCommands:
|
|
|
|
|
|
if not monthly_stats_list:
|
|
|
await context.bot.send_message(chat_id=chat_id, text=
|
|
|
- "๐๏ธ <b>Monthly Performance</b>\n\n"
|
|
|
- "๐ญ No monthly performance data available yet.\n\n"
|
|
|
- "๐ก Monthly stats are calculated from completed trades.\n"
|
|
|
- "Start trading to see monthly performance!",
|
|
|
+ "๐๏ธ <b>Monthly Performance</b>\\n"
|
|
|
+ "๐ญ No monthly performance data available yet.\\n"
|
|
|
+ "๐ก Monthly stats are calculated from completed trades. Start trading to see them!",
|
|
|
parse_mode='HTML'
|
|
|
)
|
|
|
return
|
|
|
|
|
|
- monthly_text = "๐๏ธ <b>Monthly Performance (Last 12 Months)</b>\n\n"
|
|
|
+ monthly_text_parts = [f"๐๏ธ <b>Monthly Performance (Last 12 Months)</b>"]
|
|
|
|
|
|
- total_pnl_all_months = 0 # Renamed
|
|
|
- total_trades_all_months = 0 # Renamed
|
|
|
- trading_months_count = 0 # Renamed
|
|
|
+ total_pnl_all_months = 0
|
|
|
+ total_trades_all_months = 0
|
|
|
+ trading_months_count = 0
|
|
|
|
|
|
- for month_stats_item in monthly_stats_list: # Renamed
|
|
|
+ period_lines = []
|
|
|
+ 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'])
|
|
|
- monthly_text += f"๐
<b>{month_stats_item['month_formatted']}</b>\n"
|
|
|
- monthly_text += f" {pnl_emoji} P&L: {pnl_str} ({month_stats_item['pnl_pct']:+.1f}%)\n"
|
|
|
- monthly_text += f" ๐ Trades: {month_stats_item['trades']}\n\n"
|
|
|
-
|
|
|
+ period_lines.append(f"๐
<b>{month_stats_item['month_formatted']}</b>: {pnl_emoji} {pnl_str} ({month_stats_item['pnl_pct']:+.1f}%) | Trades: {month_stats_item['trades']}")
|
|
|
total_pnl_all_months += month_stats_item['pnl']
|
|
|
total_trades_all_months += month_stats_item['trades']
|
|
|
trading_months_count += 1
|
|
|
else:
|
|
|
- monthly_text += f"๐
<b>{month_stats_item['month_formatted']}</b>\n"
|
|
|
- monthly_text += f" ๐ญ No trading activity\n\n"
|
|
|
+ period_lines.append(f"๐
<b>{month_stats_item['month_formatted']}</b>: ๐ญ No trading activity")
|
|
|
+
|
|
|
+ if period_lines:
|
|
|
+ monthly_text_parts.append("\\n".join(period_lines))
|
|
|
|
|
|
if trading_months_count > 0:
|
|
|
avg_monthly_pnl = total_pnl_all_months / trading_months_count
|
|
@@ -1069,13 +1070,15 @@ class InfoCommands:
|
|
|
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)
|
|
|
|
|
|
- monthly_text += f"๐ <b>Period Summary:</b>\n"
|
|
|
- monthly_text += f" {avg_pnl_emoji} Total P&L: {total_pnl_all_months_str}\n"
|
|
|
- monthly_text += f" ๐ Trading Months: {trading_months_count}/12\n"
|
|
|
- monthly_text += f" ๐๏ธ Avg Monthly P&L: {avg_monthly_pnl_str}\n"
|
|
|
- monthly_text += f" ๐ Total Trades: {total_trades_all_months}\n"
|
|
|
+ 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}")
|
|
|
+ monthly_text_parts.append(f" Trading Months: {trading_months_count}/12 | Total Trades: {total_trades_all_months}")
|
|
|
+ else:
|
|
|
+ if not period_lines:
|
|
|
+ monthly_text_parts = [monthly_text_parts[0]]
|
|
|
+ monthly_text_parts.append("\\n\\n๐ No trading activity in the last 12 months.")
|
|
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text=monthly_text.strip(), parse_mode='HTML')
|
|
|
+ await context.bot.send_message(chat_id=chat_id, text="\\n".join(monthly_text_parts).strip(), parse_mode='HTML')
|
|
|
|
|
|
except Exception as e:
|
|
|
error_message = f"โ Error processing monthly command: {str(e)}"
|