|
@@ -278,9 +278,33 @@ class HyperliquidClient:
|
|
|
logger.error("❌ Client not initialized")
|
|
|
return None
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ ticker = self.sync_client.fetch_ticker(symbol)
|
|
|
+ if not ticker:
|
|
|
+ logger.error(f"❌ Could not fetch ticker for {symbol}")
|
|
|
+ return None
|
|
|
+
|
|
|
+ current_price = ticker.get('last')
|
|
|
+ if not current_price:
|
|
|
+ logger.error(f"❌ Could not get current price for {symbol}")
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+ slippage_percent = 0.5
|
|
|
+ if side == 'buy':
|
|
|
+
|
|
|
+ slippage_price = current_price * (1 + slippage_percent / 100)
|
|
|
+ else:
|
|
|
+
|
|
|
+ slippage_price = current_price * (1 - slippage_percent / 100)
|
|
|
+
|
|
|
+ logger.info(f"🔄 Market order: {side} {amount} {symbol} @ current ${current_price:.2f} (slippage price: ${slippage_price:.2f})")
|
|
|
+
|
|
|
+
|
|
|
order_params = params or {}
|
|
|
- order = self.sync_client.create_market_order(symbol, side, amount, params=order_params)
|
|
|
+ order_params['price'] = slippage_price
|
|
|
+
|
|
|
+ order = self.sync_client.create_market_order(symbol, side, amount, price=slippage_price, params=order_params)
|
|
|
|
|
|
logger.info(f"✅ Successfully placed {side} market order for {amount} {symbol}")
|
|
|
logger.debug(f"📄 Order details: {order}")
|