# 📱 Commands Reference

**Complete guide to all Hyperliquid Trading Bot commands**

## 🚀 Quick Start Commands

The most important commands to get started:

```
/start       # Show main menu with quick action buttons
/balance     # Check your account balance
/long BTC 10 # Open long position with $10 USDC
/sl BTC 9000 # Set stop loss at $9,000
/tp BTC 11000 # Set take profit at $11,000
/monitoring  # Check order monitoring status
/help        # Full command reference
```

**💡 Auto-Notifications:** The bot automatically monitors your orders every 30 seconds and sends notifications when orders are filled!

## 💼 Account Management

### `/balance`
Show your current account balance and P&L summary with detailed breakdown of available vs used funds.

**Example:**
```
/balance
```

**Response:**
```
💰 Account Balance

💵 USDC:
   📊 Total: 1,250.00
   ✅ Available: 1,150.00
   🔒 In Use: 100.00

💵 BTC:
   📊 Total: 0.002
   ✅ Available: 0.001
   🔒 In Use: 0.001

💼 Portfolio Summary:
   💰 Total Value: $1,250.00
   🚀 Available for Trading: $1,150.00
   🔒 In Active Use: $100.00

📊 Performance:
   💵 P&L: $150.00 (+13.64%)
   📈 Initial: $1,100.00
```

### `/positions`
Display all open positions with unrealized P&L.

**Example:**
```
/positions
```

**Response:**
```
📈 Open Positions

📊 BTC/USDC:USDC
   📏 Size: 0.001 contracts
   💰 Entry: $45,230.50
   🟢 PnL: $15.25

💼 Total Unrealized P&L: $15.25
```

### `/orders [token (optional)]`
Show all pending/open orders, optionally filtered by token.

**Usage:**
```
/orders           # Show all open orders
/orders <TOKEN>   # Show open orders for specific token
```

**Examples:**
```
/orders       # Show all open orders
/orders BTC   # Show only Bitcoin orders
/orders ETH   # Show only Ethereum orders
```

**Response (All Orders):**
```
📋 All Open Orders

🟢 BTC
   📊 BUY 0.001 @ $44,500.00
   💵 Value: $44.50
   🔑 ID: abc123

🔴 ETH
   📊 SELL 0.01 @ $3,400.00
   💵 Value: $34.00
   🔑 ID: def456

💡 Filter by token: /orders BTC, /orders ETH
```

**Response (Filtered):**
```
📋 Open Orders - BTC

🟢 BTC
   📊 BUY 0.001 @ $44,500.00
   💵 Value: $44.50
   🔑 ID: abc123

🟢 BTC
   📊 BUY 0.002 @ $44,000.00
   💵 Value: $88.00
   🔑 ID: ghi789

💡 Quick Actions:
• /coo BTC - Cancel all BTC orders
• /orders - View all orders
```

**Response (No Orders):**
```
📭 No open orders for BTC

💡 No pending BTC orders found.
Use /long BTC 100 or /short BTC 100 to create new orders.
```

### `/coo [token]`
Cancel all open orders for a specific token.

**Usage:**
```
/coo <TOKEN>
```

**Examples:**
```
/coo BTC   # Cancel all Bitcoin orders
/coo ETH   # Cancel all Ethereum orders
```

**How it works:**
1. Fetches all open orders for the specified token
2. Shows confirmation dialog with order details
3. Cancels all orders after user confirmation
4. Reports success/failure for each order

**Confirmation Dialog:**
```
⚠️ Cancel All BTC Orders

📋 Orders to Cancel:
🟢 BUY 0.001 @ $44,500.00 ($44.50)
🟢 BUY 0.002 @ $44,000.00 ($88.00)
🔴 SELL 0.001 @ $46,000.00 ($46.00)

💰 Total Value: $178.50
🔢 Orders Count: 3

⚠️ Are you sure you want to cancel ALL BTC orders?

This action cannot be undone.
```

**Success Response:**
```
✅ Cancel Orders Results

📊 Summary:
• Token: BTC
• Cancelled: 3 orders
• Failed: 0 orders
• Total Attempted: 3 orders

🗑️ Successfully Cancelled:
🟢 BUY 0.001 @ $44,500.00
🟢 BUY 0.002 @ $44,000.00
🔴 SELL 0.001 @ $46,000.00

🎉 All BTC orders successfully cancelled!
```

### `/stats`
Complete trading statistics and performance metrics.

**Example:**
```
/stats
```

**Response:**
```
📊 Trading Statistics

💰 Balance Overview
• Initial: $1,000.00
• Current: $1,150.00
• Total P&L: $150.00
• Total Return: 15.00%

📈 Trading Activity
• Total Trades: 25
• Buy Orders: 13
• Sell Orders: 12
• Days Active: 30

🏆 Performance Metrics
• Win Rate: 68.0%
• Profit Factor: 2.15
• Avg Win: $45.50
• Avg Loss: $28.75
• Expectancy: $6.25

📊 Risk Metrics
• Sharpe Ratio: 1.85
• Sortino Ratio: 2.41
• Max Drawdown: 8.5%
• Volatility: 12.3%
• VaR (95%): 3.2%
```

📊 Use /stats to view updated performance metrics.

## 🚀 Perps Trading

### `/long [token] [USDC amount] [price (optional)]`
Open a long position using market order or limit order.

**Usage:**
```
/long <TOKEN> <USDC_AMOUNT>           # Market order
/long <TOKEN> <USDC_AMOUNT> <PRICE>   # Limit order
```

**Examples:**
```
/long BTC 100       # Long Bitcoin with $100 USDC (Market Order)
/long BTC 100 45000 # Long Bitcoin with $100 USDC at $45,000 (Limit Order)
/long ETH 50        # Long Ethereum with $50 USDC (Market Order)
/long ETH 50 3200   # Long Ethereum with $50 USDC at $3,200 (Limit Order)
```

**How it works:**
1. **Market Order** (2 parameters): Fetches current market price and places market buy order
2. **Limit Order** (3 parameters): Places limit buy order at specified price
3. Calculates token amount: `token_amount = usdc_amount / price`
4. Records trade in statistics

**Market Order Confirmation:**
```
🟢 Long Position Confirmation

📊 Order Details:
• Token: BTC
• Direction: LONG (Buy)
• USDC Value: $100.00
• Current Price: $45,230.50
• Order Type: Market Order
• Token Amount: 0.002211 BTC

🎯 Execution:
• Will buy 0.002211 BTC at current market price
• Est. Value: $100.00

⚠️ Are you sure you want to open this long position?
```

**Limit Order Confirmation:**
```
🟢 Long Position Confirmation

📊 Order Details:
• Token: BTC
• Direction: LONG (Buy)
• USDC Value: $100.00
• Current Price: $45,230.50
• Order Type: Limit Order
• Token Amount: 0.002222 BTC

🎯 Execution:
• Will buy 0.002222 BTC at $45,000.00
• Est. Value: $100.00

⚠️ Are you sure you want to open this long position?
```

### `/short [token] [USDC amount] [price (optional)]`
Open a short position using market order or limit order.

**Usage:**
```
/short <TOKEN> <USDC_AMOUNT>           # Market order
/short <TOKEN> <USDC_AMOUNT> <PRICE>   # Limit order
```

**Examples:**
```
/short BTC 100       # Short Bitcoin with $100 USDC (Market Order)
/short BTC 100 46000 # Short Bitcoin with $100 USDC at $46,000 (Limit Order)
/short ETH 50        # Short Ethereum with $50 USDC (Market Order)
/short ETH 50 3400   # Short Ethereum with $50 USDC at $3,400 (Limit Order)
```

**How it works:**
1. **Market Order** (2 parameters): Fetches current market price and places market sell order
2. **Limit Order** (3 parameters): Places limit sell order at specified price
3. Calculates token amount: `token_amount = usdc_amount / price`
4. Records trade in statistics

**Market Order Confirmation:**
```
🔴 Short Position Confirmation

📊 Order Details:
• Token: BTC
• Direction: SHORT (Sell)
• USDC Value: $100.00
• Current Price: $45,230.50
• Order Type: Market Order
• Token Amount: 0.002211 BTC

🎯 Execution:
• Will sell 0.002211 BTC at current market price
• Est. Value: $100.00

⚠️ Are you sure you want to open this short position?
```

**Limit Order Confirmation:**
```
🔴 Short Position Confirmation

📊 Order Details:
• Token: BTC
• Direction: SHORT (Sell)
• USDC Value: $100.00
• Current Price: $45,230.50
• Order Type: Limit Order
• Token Amount: 0.002174 BTC

🎯 Execution:
• Will sell 0.002174 BTC at $46,000.00
• Est. Value: $100.00

⚠️ Are you sure you want to open this short position?
```

### `/exit [token]`
Close an open position using market order.

**Usage:**
```
/exit <TOKEN>
```

**Examples:**
```
/exit BTC     # Close Bitcoin position (long or short)
/exit ETH     # Close Ethereum position
/exit SOL     # Close Solana position
```

**How it works:**
1. Checks for existing position in the specified token
2. Determines position direction (long/short) and size
3. Creates opposite market order to close position
4. Shows position details and estimated P&L
5. Executes market order after confirmation

**Confirmation Dialog:**
```
🔴 Exit Position Confirmation

📊 Position Details:
• Token: BTC
• Position: LONG
• Size: 0.002211 contracts
• Entry Price: $45,230.50
• Current Price: $46,150.00
• 🟢 Unrealized P&L: $203.45

🎯 Exit Order:
• Action: SELL (Close LONG)
• Amount: 0.002211 BTC
• Est. Value: ~$102.03
• Order Type: Market Order

⚠️ Are you sure you want to close this LONG position?
```

## 🛡️ Risk Management

### `/sl [token] [price]`
Set a stop loss order to limit downside risk.

**Usage:**
```
/sl <TOKEN> <PRICE>
```

**Examples:**
```
/sl BTC 44000   # Stop loss for Bitcoin at $44,000
/sl ETH 3200    # Stop loss for Ethereum at $3,200
```

**How it works:**
1. Checks for existing position in the specified token
2. Validates stop loss price against position direction:
   - **Long positions**: Stop loss must be BELOW entry price
   - **Short positions**: Stop loss must be ABOVE entry price
3. Places limit order at stop loss price
4. Order executes automatically when price is reached

### `/tp [token] [price]`
Set a take profit order to secure gains.

**Usage:**
```
/tp <TOKEN> <PRICE>
```

**Examples:**
```
/tp BTC 50000   # Take profit for Bitcoin at $50,000
/tp ETH 3800    # Take profit for Ethereum at $3,800
```

## 📊 Market Data

### `/price`
Quick price check for the default trading symbol.

### `/market`
Detailed market data with orderbook information.

### `/trades`
Recent trade history.

## 🔄 Order Monitoring & Notifications

The bot automatically monitors your orders and positions every 30 seconds and sends real-time notifications when orders are filled.

### Automatic Notifications

**🚀 Position Opened Notifications**
```
🚀 Position Opened

📊 Trade Details:
• Token: BTC
• Direction: LONG
• Size: 0.002 contracts
• Entry Price: $45,230.50
• Value: $90.46

✅ Status: New LONG position opened
⏰ Time: 14:25:30
```

**🎯 Position Closed Notifications**
```
🎯 Position Closed

📊 Trade Summary:
• Token: BTC
• Direction: LONG
• Size: 0.002 contracts
• Entry Price: $45,230.50
• Exit Price: $46,150.00
• Exit Value: $92.30

🟢 Profit & Loss:
• P&L: $1.84 (+2.04%)
• Result: PROFIT

✅ Status: Position fully closed
⏰ Time: 16:45:22
```

### `/monitoring`
Check the status of order monitoring system.

**Example:**
```
/monitoring
```

**Response:**
```
🔄 Order Monitoring Status

📊 Current Status:
• Active: ✅ Yes
• Check Interval: 30 seconds
• Orders Tracked: 3
• Positions Tracked: 2

📈 Notifications:
• 🚀 Position Opened
• 📈 Position Increased
• 📉 Position Partially Closed
• 🎯 Position Closed (with P&L)
```

## 💡 Pro Tips

### **🎯 Best Practices**
- Start small and test with small amounts first
- Use confirmations and always review orders
- Monitor positions regularly with `/positions`
- Track performance with `/stats`

### **⚡ Quick Trading**
```bash
/long BTC 10         # Quick $10 long (market)
/long BTC 10 44000   # Quick $10 long at $44k (limit)
/sl BTC 42000        # Set stop loss
/tp BTC 48000        # Set take profit
/exit BTC            # Close position
```

### **🛡️ Risk Management**
```bash
# Long position protection
/long BTC 100        # Open long
/sl BTC 42000        # Stop loss 5% below
/tp BTC 50000        # Take profit 10% above
```

### **📊 Monitoring**
```bash
/balance          # Check account
/stats            # Review performance
/positions        # Monitor open trades
/monitoring       # Check order monitoring status
/orders           # All open orders
```

## ⚠️ Important Notes

### **🛡️ Safety Features**
- **Confirmation dialogs** for all trades
- **Auto-notifications** for order fills
- **Real-time monitoring** every 30 seconds
- **Comprehensive logging** of all activities

### **🔄 Order Monitoring**
- **30-second intervals** for order fill detection
- **Automatic P&L calculation** for closed positions
- **Position change tracking** (opens, closes, increases)
- **Instant Telegram notifications** for all fills

### **📱 Mobile Optimized**
- **One-tap buttons** for quick actions
- **Clean formatting** for mobile screens
- **Instant notifications** for trade results
- **Real-time order fill alerts**

## 🚀 Getting Started

1. **Configure**: Set up your `.env` file
2. **Test**: Start with `/balance` and `/price`
3. **Trade**: Try `/long BTC 10` for a small market order
4. **Monitor**: Use `/monitoring` to check auto-notifications
5. **Track**: Use `/positions` and `/stats`

**Happy trading! 📱💰**