@@ -57,7 +57,7 @@ def patched_get_localzone():
5757MIN_PROFIT = 0.8 # %
5858TRAIL_STOP = 0.5 # %
5959MAX_HOLD_TIME = 900 # seconds
60- INVEST_AMOUNT = 10 # USD per coin
60+ INVEST_AMOUNT = 12 # USD per coin (increased to ensure min_notional compliance)
6161TRADE_LOG_FILE = "trades_detailed.csv"
6262YAML_SYMBOLS_FILE = "symbols.yaml"
6363BOT_STATE_FILE = "bot_state.json"
@@ -2338,7 +2338,7 @@ def cross_asset_trade(from_asset, to_asset, amount, symbol_for_position=None):
23382338 print (f"[ERROR] Insufficient { from_asset } balance: { from_balance :.8f} < { rounded_amount :.8f} (rounded)" )
23392339 return None
23402340
2341- # ✅ STEP 2: Check minimum notional value
2341+ # ✅ STEP 2: Check minimum notional value and auto-adjust if needed
23422342 min_notional = min_notional_for (symbol )
23432343 current_price = get_latest_price (symbol )
23442344 if not current_price :
@@ -2347,8 +2347,20 @@ def cross_asset_trade(from_asset, to_asset, amount, symbol_for_position=None):
23472347
23482348 trade_value = rounded_amount * current_price
23492349 if trade_value < min_notional :
2350- print (f"[ERROR] Trade value ${ trade_value :.2f} below minimum notional ${ min_notional :.2f} " )
2351- return None
2350+ print (f"[AUTO-ADJUST] Trade value ${ trade_value :.2f} below minimum notional ${ min_notional :.2f} " )
2351+
2352+ # Calculate required amount to meet minimum notional (with 5% buffer)
2353+ required_amount = (min_notional * 1.05 ) / current_price
2354+ adjusted_amount = round_qty (symbol , required_amount )
2355+
2356+ # Check if we have enough balance for the adjusted amount
2357+ if balance [balance_key ] >= adjusted_amount :
2358+ print (f"[AUTO-ADJUST] Increasing trade amount from { rounded_amount :.8f} to { adjusted_amount :.8f} " )
2359+ rounded_amount = adjusted_amount
2360+ trade_value = rounded_amount * current_price
2361+ else :
2362+ print (f"[ERROR] Cannot meet minimum notional. Required: { adjusted_amount :.8f} , Available: { balance [balance_key ]:.8f} " )
2363+ return None
23522364
23532365 print (f"[CROSS-TRADE] Trade validation passed - Value: ${ trade_value :.2f} , Min: ${ min_notional :.2f} " )
23542366
0 commit comments