|
@@ -13,6 +13,17 @@ from src.utils.price_formatter import get_formatter
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
+def _normalize_token_case(token: str) -> str:
|
|
|
+ """
|
|
|
+ Normalize token case: if any characters are already uppercase, keep as-is.
|
|
|
+ Otherwise, convert to uppercase. This handles mixed-case tokens like kPEPE, kBONK.
|
|
|
+ """
|
|
|
+
|
|
|
+ if any(c.isupper() for c in token):
|
|
|
+ return token
|
|
|
+ else:
|
|
|
+ return token.upper()
|
|
|
+
|
|
|
class TradingCommands:
|
|
|
"""Handles all trading-related Telegram commands."""
|
|
|
|
|
@@ -46,7 +57,7 @@ class TradingCommands:
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
usdc_amount = float(context.args[1])
|
|
|
|
|
|
|
|
@@ -170,7 +181,7 @@ This will {"place a limit buy order" if limit_price else "execute a market buy o
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
usdc_amount = float(context.args[1])
|
|
|
|
|
|
|
|
@@ -288,7 +299,7 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
|
|
|
|
|
|
position = self.trading_engine.find_position(token)
|
|
@@ -365,7 +376,7 @@ This will {"place a limit sell order" if limit_price else "execute a market sell
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
stop_price = float(context.args[1])
|
|
|
|
|
|
|
|
@@ -469,7 +480,7 @@ This will place a limit {exit_side} order at {formatter.format_price_with_symbol
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
tp_price = float(context.args[1])
|
|
|
|
|
|
|
|
@@ -573,7 +584,7 @@ This will place a limit {exit_side} order at {formatter.format_price_with_symbol
|
|
|
))
|
|
|
return
|
|
|
|
|
|
- token = context.args[0].upper()
|
|
|
+ token = _normalize_token_case(context.args[0])
|
|
|
|
|
|
confirmation_text = f"""
|
|
|
🚫 <b>Cancel All Orders Confirmation</b>
|