# ๐Ÿ“ฑ 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
/performance # Token performance ranking
/daily       # Daily performance (last 10 days)
/alarm BTC 50000 # Set price alert for BTC at $50,000
/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 and percentages.

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

**Response:**
```
๐Ÿ“ˆ Open Positions

๐Ÿ“Š BTC (LONG)
   ๐Ÿ“ Size: 0.001000 BTC
   ๐Ÿ’ฐ Entry: $45,230.50
   ๐Ÿ’ต Value: $45.23
   ๐ŸŸข P&L: $1.84 (+4.07%)

๐Ÿ“Š ETH (SHORT)
   ๐Ÿ“ Size: 0.010000 ETH
   ๐Ÿ’ฐ Entry: $3,200.00
   ๐Ÿ’ต Value: $32.00
   ๐Ÿ”ด P&L: -$0.75 (-2.34%)

๐Ÿ’ผ Total Portfolio:
   ๐Ÿ’ต Total Value: $77.23
   ๐ŸŸข Total P&L: $1.09 (+1.43%)
```

### `/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%

๐ŸŽฏ Best/Worst
โ€ข Largest Win: $125.50
โ€ข Largest Loss: $45.25
โ€ข Max Consecutive Wins: 5
โ€ข Max Consecutive Losses: 2

๐Ÿ“… Since: 2024-01-15
```

## ๐Ÿ“ˆ Performance Analytics

### `/performance [token (optional)]`
Show token performance ranking or detailed stats for a specific token.

**Usage:**
```
/performance         # Show all token rankings
/performance <TOKEN> # Detailed stats for specific token
```

**Examples:**
```
/performance       # Token performance ranking
/performance BTC   # Detailed Bitcoin performance
/performance ETH   # Detailed Ethereum performance
```

**Response (Ranking):**
```
๐Ÿ† Token Performance Ranking

๐Ÿฅ‡ BTC
   ๐ŸŸข P&L: $245.50 (+12.3%)
   ๐Ÿ“Š Trades: 15 | Win: 73%

๐Ÿฅˆ ETH
   ๐ŸŸข P&L: $125.75 (+8.9%)
   ๐Ÿ“Š Trades: 12 | Win: 67%

๐Ÿฅ‰ SOL
   ๐Ÿ”ด P&L: -$25.00 (-2.1%)
   ๐Ÿ“Š Trades: 8 | Win: 38%

๐Ÿ’ผ Portfolio Summary:
   ๐ŸŸข Total P&L: $346.25
   ๐Ÿ“ˆ Tokens Traded: 3
   ๐Ÿ”„ Completed Trades: 35

๐Ÿ’ก Usage: /performance BTC for detailed BTC stats
```

**Response (Detailed):**
```
๐Ÿ“Š BTC Detailed Performance

๐Ÿ’ฐ P&L Summary:
โ€ข ๐ŸŸข Total P&L: $245.50 (+12.3%)
โ€ข ๐Ÿ’ต Total Volume: $2,150.00
โ€ข ๐Ÿ“ˆ Expectancy: $16.37

๐Ÿ“Š Trading Activity:
โ€ข Total Trades: 20
โ€ข Completed: 15
โ€ข Buy Orders: 11
โ€ข Sell Orders: 9

๐Ÿ† Performance Metrics:
โ€ข Win Rate: 73.3%
โ€ข Profit Factor: 2.85
โ€ข Wins: 11 | Losses: 4

๐Ÿ’ก Best/Worst:
โ€ข Largest Win: $85.50
โ€ข Largest Loss: $35.25
โ€ข Avg Win: $32.50
โ€ข Avg Loss: $18.75

๐Ÿ”„ Recent Trades:
โ€ข ๐Ÿ”ด SELL $450 @ 12/15 14:30 | P&L: $25.50
โ€ข ๐ŸŸข BUY $425 @ 12/14 09:15
โ€ข ๐Ÿ”ด SELL $380 @ 12/13 16:45 | P&L: $15.25

๐Ÿ”„ Use /performance to see all token rankings
```

### `/daily`
Show daily performance breakdown for the last 10 days.

**Example:**
```
/daily
```

**Response:**
```
๐Ÿ“… Daily Performance (Last 10 Days)

๐Ÿ“Š Dec 15, 2024
   ๐ŸŸข P&L: $45.25 (+2.1%)
   ๐Ÿ”„ Trades: 3

๐Ÿ“Š Dec 14, 2024
   ๐Ÿ”ด P&L: -$15.50 (-0.7%)
   ๐Ÿ”„ Trades: 2

๐Ÿ“Š Dec 13, 2024
   ๐ŸŸข P&L: $85.75 (+4.2%)
   ๐Ÿ”„ Trades: 5

๐Ÿ“Š Dec 12, 2024
   ๐ŸŸข P&L: $12.00 (+0.6%)
   ๐Ÿ”„ Trades: 1

๐Ÿ“Š Dec 11, 2024
   ๐ŸŸข P&L: $25.50 (+1.3%)
   ๐Ÿ”„ Trades: 2

๐Ÿ’ผ 10-Day Summary:
   ๐ŸŸข Total P&L: $153.00
   ๐Ÿ”„ Total Trades: 13
   ๐Ÿ“Š Avg per Day: $15.30
```

### `/weekly`
Show weekly performance breakdown for the last 10 weeks.

**Example:**
```
/weekly
```

**Response:**
```
๐Ÿ“Š Weekly Performance (Last 10 Weeks)

๐Ÿ“ˆ Week Dec 9-15, 2024
   ๐ŸŸข P&L: $125.50 (+5.8%)
   ๐Ÿ”„ Trades: 8

๐Ÿ“ˆ Week Dec 2-8, 2024
   ๐ŸŸข P&L: $85.25 (+4.1%)
   ๐Ÿ”„ Trades: 6

๐Ÿ“ˆ Week Nov 25-Dec 1, 2024
   ๐Ÿ”ด P&L: -$25.75 (-1.2%)
   ๐Ÿ”„ Trades: 4

๐Ÿ“ˆ Week Nov 18-24, 2024
   ๐ŸŸข P&L: $45.00 (+2.3%)
   ๐Ÿ”„ Trades: 3

๐Ÿ’ผ 10-Week Summary:
   ๐ŸŸข Total P&L: $230.00
   ๐Ÿ”„ Total Trades: 21
   ๐Ÿ“Š Avg per Week: $23.00
```

### `/monthly`
Show monthly performance breakdown for the last 10 months.

**Example:**
```
/monthly
```

**Response:**
```
๐Ÿ“† Monthly Performance (Last 10 Months)

๐Ÿ“… December 2024
   ๐ŸŸข P&L: $245.50 (+11.2%)
   ๐Ÿ”„ Trades: 15

๐Ÿ“… November 2024
   ๐ŸŸข P&L: $185.25 (+9.1%)
   ๐Ÿ”„ Trades: 12

๐Ÿ“… October 2024
   ๐Ÿ”ด P&L: -$45.75 (-2.1%)
   ๐Ÿ”„ Trades: 8

๐Ÿ“… September 2024
   ๐ŸŸข P&L: $125.00 (+6.5%)
   ๐Ÿ”„ Trades: 10

๐Ÿ’ผ 10-Month Summary:
   ๐ŸŸข Total P&L: $510.00
   ๐Ÿ”„ Total Trades: 45
   ๐Ÿ“Š Avg per Month: $51.00
```

## ๐Ÿš€ 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?

This will place a market sell order to close your entire BTC 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

**Confirmation Dialog:**
```
๐Ÿ›‘ Stop Loss Order Confirmation

๐Ÿ“Š Position Details:
โ€ข Token: BTC
โ€ข Position: LONG
โ€ข Size: 0.002211 contracts
โ€ข Entry Price: $45,230.50
โ€ข Current Price: $46,150.00

๐ŸŽฏ Stop Loss Order:
โ€ข Stop Price: $44,000.00
โ€ข Action: SELL (Close LONG)
โ€ข Amount: 0.002211 BTC
โ€ข Order Type: Limit Order
โ€ข ๐Ÿ”ด Est. P&L: -$272.15

โš ๏ธ Are you sure you want to set this stop loss?

This will place a limit sell order at $44,000.00 to protect your LONG position.
```

### `/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
```

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

**Confirmation Dialog:**
```
๐ŸŽฏ Take Profit Order Confirmation

๐Ÿ“Š Position Details:
โ€ข Token: BTC
โ€ข Position: LONG
โ€ข Size: 0.002211 contracts
โ€ข Entry Price: $45,230.50
โ€ข Current Price: $46,150.00

๐Ÿ’ฐ Take Profit Order:
โ€ข Target Price: $50,000.00
โ€ข Action: SELL (Close LONG)
โ€ข Amount: 0.002211 BTC
โ€ข Order Type: Limit Order
โ€ข ๐ŸŸข Est. P&L: $1,054.35

โš ๏ธ Are you sure you want to set this take profit?

This will place a limit sell order at $50,000.00 to capture profits from your LONG position.
```

## ๐Ÿ“Š Market Data

### `/price [token (optional)]`
Quick price check for any token.

**Usage:**
```
/price           # Default trading token price
/price <TOKEN>   # Specific token price
```

**Examples:**
```
/price       # Default token price
/price BTC   # Bitcoin price
/price ETH   # Ethereum price
/price SOL   # Solana price
```

**Response:**
```
๐Ÿ’ต BTC: $45,230.50
โฐ Updated: 14:25:30
๐Ÿ’ก Usage: /price BTC or /price for default
```

### `/market [token (optional)]`
Detailed market data with orderbook information.

**Usage:**
```
/market           # Default trading token market data
/market <TOKEN>   # Specific token market data
```

**Examples:**
```
/market       # Default token market data
/market BTC   # Bitcoin market data
/market ETH   # Ethereum market data
```

**Response:**
```
๐Ÿ“Š Market Data - BTC

๐Ÿ’ต Current Price: $45,230.50
๐Ÿ“ˆ 24h High: $46,850.00
๐Ÿ“‰ 24h Low: $44,120.00
๐Ÿ“Š 24h Volume: 2,450.25

๐ŸŸข Best Bid: $45,225.00
๐Ÿ”ด Best Ask: $45,235.00
๐Ÿ“ Spread: $10.00 (0.022%)

๐Ÿ’ก Usage: /market BTC or /market for default
```

### `/trades`
Recent trade history.

**Example:**
```
/trades
```

**Response:**
```
๐Ÿ”„ Recent Trades

๐ŸŸข BUY 0.002211 BTC/USDC:USDC
   ๐Ÿ’ฐ $45,230.50 | ๐Ÿ’ต $100.00
   ๐Ÿ“… 12/15 14:25

๐Ÿ”ด SELL 0.001850 ETH/USDC:USDC
   ๐Ÿ’ฐ $3,200.00 | ๐Ÿ’ต $59.20
   ๐Ÿ“… 12/15 13:40

๐ŸŸข BUY 0.008500 SOL/USDC:USDC
   ๐Ÿ’ฐ $85.00 | ๐Ÿ’ต $72.25
   ๐Ÿ“… 12/15 12:15
```

## ๐Ÿ”” Price Alerts

### `/alarm [token] [price] OR [token] OR [alarm_id] OR (no args)`
Comprehensive price alert system with multiple usage patterns.

**Usage:**
```
/alarm                    # List all active alarms
/alarm <TOKEN>            # List alarms for specific token
/alarm <TOKEN> <PRICE>    # Set new alarm
/alarm <ALARM_ID>         # Remove alarm by ID
```

**Examples:**
```
/alarm                # List all alarms
/alarm BTC            # List Bitcoin alarms
/alarm BTC 50000      # Set BTC alarm at $50,000
/alarm ETH 3500       # Set ETH alarm at $3,500
/alarm 3              # Remove alarm ID 3
```

**Set New Alarm:**
```
/alarm BTC 50000
```

**Response:**
```
โœ… Price Alarm Created

๐Ÿ“Š Alarm Details:
โ€ข Alarm ID: 5
โ€ข Token: BTC
โ€ข Target Price: $50,000.00
โ€ข Current Price: $45,230.50
โ€ข Direction: ABOVE

๐Ÿ“ˆ Alert Condition:
Will trigger when BTC price moves above $50,000.00

๐Ÿ’ฐ Price Difference:
โ€ข Distance: $4,769.50 (10.55%)
โ€ข Status: ACTIVE โœ…

โฐ Created: 14:25:30

๐Ÿ’ก The alarm will be checked every 30 seconds and you'll receive a notification when triggered.
```

**List All Alarms:**
```
/alarm
```

**Response:**
```
๐Ÿ”” Active Price Alarms (5 total)

๐Ÿšจ Alarm #1: BTC
โ€ข Target: $50,000.00 (ABOVE)
โ€ข Current: $45,230.50
โ€ข Distance: $4,769.50 (10.55%)

๐Ÿšจ Alarm #2: ETH  
โ€ข Target: $3,500.00 (ABOVE)
โ€ข Current: $3,200.00
โ€ข Distance: $300.00 (9.38%)

๐Ÿšจ Alarm #3: BTC
โ€ข Target: $44,000.00 (BELOW)
โ€ข Current: $45,230.50
โ€ข Distance: $1,230.50 (2.72%)

๐Ÿ’ก Usage:
โ€ข /alarm BTC - Show BTC alarms only
โ€ข /alarm BTC 52000 - Set new BTC alarm
โ€ข /alarm 3 - Remove alarm ID 3
```

**List Token Alarms:**
```
/alarm BTC
```

**Response:**
```
๐Ÿ”” BTC Price Alarms (2 total)

๐Ÿšจ Alarm #1: BTC
โ€ข Target: $50,000.00 (ABOVE)
โ€ข Current: $45,230.50
โ€ข Distance: $4,769.50 (10.55%)

๐Ÿšจ Alarm #3: BTC
โ€ข Target: $44,000.00 (BELOW)
โ€ข Current: $45,230.50
โ€ข Distance: $1,230.50 (2.72%)

๐Ÿ’ก Set new: /alarm BTC 52000
๐Ÿ’ก Remove: /alarm 1 or /alarm 3
```

**Alarm Triggered Notification:**
```
๐Ÿšจ PRICE ALARM TRIGGERED! ๐Ÿšจ

๐Ÿ“Š Alarm Details:
โ€ข Token: BTC
โ€ข Target Price: $50,000.00
โ€ข Current Price: $50,125.50
โ€ข Direction: ABOVE

โœ… Condition Met: BTC moved ABOVE $50,000.00
โฐ Triggered: 16:45:22
๐ŸŽฏ Alarm ID: 1 (automatically removed)

๐Ÿ’ก Price has increased by $4,895.00 (+10.82%) since alarm was set.
```

**Remove Alarm:**
```
/alarm 3
```

**Response:**
```
โœ… Alarm ID 3 has been removed.
```

## ๐Ÿ”„ 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

๐Ÿ“ฑ Use /positions to view all positions
```

**๐ŸŽฏ 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

๐Ÿ“Š Use /stats to view updated performance
```

**๐Ÿ“‰ Partial Position Closed**
```
๐Ÿ“‰ Position Partially Closed

๐Ÿ“Š Partial Close Details:
โ€ข Token: BTC
โ€ข Direction: LONG
โ€ข Closed Size: 0.001 contracts
โ€ข Entry Price: $45,230.50
โ€ข Exit Price: $46,150.00

๐ŸŸข Partial P&L:
โ€ข P&L: $0.92 (+2.04%)

โœ… Status: Partial position closed
โฐ Time: 15:30:15

๐Ÿ“ˆ Use /positions to view remaining position
```

**๐Ÿ”„ External Trade Detection**
```
๐Ÿ”„ External Trade Detected

๐Ÿ“Š Trade Details:
โ€ข Token: ETH
โ€ข Side: BUY
โ€ข Amount: 0.015 ETH
โ€ข Price: $3,200.00
โ€ข Value: $48.00

๐ŸŸข Source: Direct Platform Trade
โฐ Time: 14:35:20

๐Ÿ“ˆ Note: This trade was executed outside the Telegram bot
๐Ÿ“Š Stats have been automatically updated
```

### `/monitoring`
Check the status of all monitoring systems.

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

**Response:**
```
๐Ÿ”„ System Monitoring Status

๐Ÿ“Š Order Monitoring:
โ€ข Active: โœ… Yes
โ€ข Check Interval: 30 seconds
โ€ข Orders Tracked: 3
โ€ข Positions Tracked: 2

๐Ÿ”” Price Alarms:
โ€ข Active Alarms: 5
โ€ข Triggered Today: 2
โ€ข Tokens Monitored: 3
โ€ข Next Alarm ID: 6

๐Ÿ”„ External Trade Monitoring:
โ€ข Last Check: 2024-12-15 14:25:30
โ€ข Auto Stats Update: โœ… Enabled
โ€ข External Notifications: โœ… Enabled

๐Ÿ›ก๏ธ Risk Management:
โ€ข Automatic Stop Loss: โŒ Disabled
โ€ข Stop Loss Threshold: 5.0%
โ€ข Position Monitoring: โŒ Inactive

๐Ÿ“ˆ Notifications:
โ€ข ๐Ÿš€ Position Opened/Increased
โ€ข ๐Ÿ“‰ Position Partially/Fully Closed
โ€ข ๐ŸŽฏ P&L Calculations
โ€ข ๐Ÿ”” Price Alarm Triggers
โ€ข ๐Ÿ”„ External Trade Detection
โ€ข ๐Ÿ›‘ Automatic Stop Loss Triggers

โฐ Last Check: 14:25:30

๐Ÿ’ก Monitoring Features:
โ€ข Real-time order fill detection
โ€ข Automatic P&L calculation
โ€ข Position change tracking
โ€ข Price alarm monitoring
โ€ข External trade monitoring
โ€ข Auto stats synchronization
โ€ข Instant Telegram notifications

๐Ÿ“‹ Active Alarms by Token:
โ€ข BTC: 2 alarms
โ€ข ETH: 2 alarms
โ€ข SOL: 1 alarm
```

## ๐Ÿ—‚๏ธ System Management

### `/logs [cleanup] [days (optional)]`
View log file statistics and manage log cleanup.

**Usage:**
```
/logs                    # Show log statistics
/logs cleanup            # Clean logs older than 30 days (default)
/logs cleanup <DAYS>     # Clean logs older than specified days
```

**Examples:**
```
/logs               # View log stats
/logs cleanup       # Clean old logs (30 days)
/logs cleanup 7     # Clean logs older than 7 days
```

**Log Statistics:**
```
๐Ÿ“Š System Logging Status

๐Ÿ“ Current Log Files:
โ€ข Main Log: trading_bot_20241215.log (2.5 MB)
โ€ข Error Log: bot_errors.log (0.8 MB)
โ€ข Archive Files: 5 files (12.3 MB total)

๐Ÿ“ˆ Log Activity (Last 24h):
โ€ข Total Entries: 2,450
โ€ข Info: 2,180 (89%)
โ€ข Warning: 195 (8%)
โ€ข Error: 75 (3%)

๐Ÿ’พ Disk Usage:
โ€ข Current Logs: 3.3 MB
โ€ข Archive Logs: 12.3 MB
โ€ข Total Usage: 15.6 MB

๐Ÿ“ˆ Log Configuration:
โ€ข Log Level: INFO
โ€ข Heartbeat Interval: 30s
โ€ข Bot Uptime: 2024-12-15 14:25:30

๐Ÿ’ก Log Management:
โ€ข /logs cleanup - Clean old logs (30 days)
โ€ข /logs cleanup 7 - Clean logs older than 7 days
โ€ข Log rotation happens automatically
โ€ข Old backups are removed automatically

๐Ÿ”ง Configuration:
โ€ข Rotation Type: SIZE
โ€ข Max Size: 10MB (size rotation)
โ€ข Backup Count: 5
```

**Log Cleanup:**
```
/logs cleanup 7
```

**Response:**
```
๐Ÿงน Cleaning up log files older than 7 days...
โœ… Log cleanup completed!
```

## ๐Ÿ’ก 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` and `/performance`
- Set up price alerts with `/alarm` for key levels
- Review daily/weekly performance with `/daily` and `/weekly`

### **โšก 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
/alarm BTC 41000     # Emergency alert
```

### **๐Ÿ“Š Performance Tracking**
```bash
/stats            # Overall performance
/performance      # Token rankings
/daily            # Daily breakdown
/weekly           # Weekly trends
/monthly          # Monthly analysis
/performance BTC  # Detailed BTC stats
```

### **๐Ÿ”” Alert Management**
```bash
/alarm BTC 50000     # Set upside alert
/alarm BTC 40000     # Set downside alert
/alarm               # Check all alarms
/alarm BTC           # Check BTC alarms
/alarm 3             # Remove alarm ID 3
```

### **๐Ÿ“Š Monitoring**
```bash
/balance          # Check account
/positions        # Monitor open trades
/monitoring       # Check system status
/orders           # All open orders
/logs             # System health
```

## โš ๏ธ 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
- **Price alerts** for key levels
- **External trade detection** and sync

### **๐Ÿ”„ 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
- **External trade monitoring** and sync

### **๐Ÿ“ˆ Performance Analytics**
- **Token-level performance tracking** with rankings
- **Period-based analysis** (daily/weekly/monthly)
- **Comprehensive statistics** with risk metrics
- **Real-time P&L calculations** with percentages
- **Trade history** and pattern analysis

### **๐Ÿ”” Alert System**
- **Price alerts** with automatic monitoring
- **Customizable thresholds** for any token
- **Direction-based triggers** (above/below)
- **Automatic removal** after trigger
- **Multi-token support** with unlimited alerts

### **๐Ÿ“ฑ Mobile Optimized**
- **One-tap buttons** for quick actions
- **Clean formatting** for mobile screens
- **Instant notifications** for trade results
- **Real-time order fill alerts**
- **Comprehensive emoji indicators**

## ๐Ÿš€ Getting Started

1. **Configure**: Set up your `.env` file with API keys
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`, `/stats`, and `/performance`
6. **Alerts**: Set up `/alarm BTC 50000` for price notifications
7. **Analyze**: Review `/daily`, `/weekly` performance

**Happy trading! ๐Ÿ“ฑ๐Ÿ’ฐ**