Browse Source

Refactor formatter calls in TradingEngine to remove unnecessary token_info parameter, streamlining the code and enhancing readability. This change ensures consistent usage of the formatter across various trading methods.

Carles Sentis 3 days ago
parent
commit
21183cd90d
2 changed files with 7 additions and 7 deletions
  1. 6 6
      src/trading/trading_engine.py
  2. 1 1
      trading_bot.py

+ 6 - 6
src/trading/trading_engine.py

@@ -257,7 +257,7 @@ class TradingEngine:
                                 stop_loss_price: Optional[float] = None) -> Dict[str, Any]:
         symbol = f"{token}/USDC:USDC"
         token_info = await self.get_token_info(token)
-        formatter = get_formatter(token_info)
+        formatter = get_formatter()
         
         try:
             # Validate inputs
@@ -419,7 +419,7 @@ class TradingEngine:
                                  stop_loss_price: Optional[float] = None) -> Dict[str, Any]:
         symbol = f"{token}/USDC:USDC"
         token_info = await self.get_token_info(token)
-        formatter = get_formatter(token_info)
+        formatter = get_formatter()
         
         try:
             if usdc_amount <= 0:
@@ -569,7 +569,7 @@ class TradingEngine:
         if not position:
             return {"success": False, "error": f"No open position found for {token}"}
         
-        formatter = get_formatter() # Get formatter
+        formatter = get_formatter()
         try:
             symbol = f"{token}/USDC:USDC"
             position_type, exit_side, contracts_to_close = self.get_position_direction(position)
@@ -672,7 +672,7 @@ class TradingEngine:
         if not position:
             return {"success": False, "error": f"No open position found for {token} to set stop loss."}
         
-        formatter = get_formatter() # Get formatter
+        formatter = get_formatter()
         try:
             symbol = f"{token}/USDC:USDC"
             position_type, exit_side, contracts = self.get_position_direction(position)
@@ -768,7 +768,7 @@ class TradingEngine:
         if not position:
             return {"success": False, "error": f"No open position found for {token} to set take profit."}
         
-        formatter = get_formatter() # Get formatter
+        formatter = get_formatter()
         try:
             symbol = f"{token}/USDC:USDC"
             position_type, exit_side, contracts = self.get_position_direction(position)
@@ -1070,7 +1070,7 @@ class TradingEngine:
         if not self.stats:
             return {"success": False, "error": "TradingStats not available."}
 
-        formatter = get_formatter() # Get formatter
+        formatter = get_formatter()
         trigger_order_details = self.stats.get_order_by_db_id(original_trigger_order_db_id)
         if not trigger_order_details:
             return {"success": False, "error": f"Original trigger order DB ID {original_trigger_order_db_id} not found."}

+ 1 - 1
trading_bot.py

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