- Add SymbolSettings interface with enabled/positionSize/leverage fields - Implement per-symbol ENV variables (SOLANA_*, ETHEREUM_*) - Add SOL and ETH sections to settings UI with enable/disable toggles - Add symbol-specific test buttons (SOL LONG/SHORT, ETH LONG/SHORT) - Update execute and test endpoints to check symbol enabled status - Add real-time risk/reward calculator per symbol - Rename 'Position Sizing' to 'Global Fallback' for clarity - Fix position manager P&L calculation for externally closed positions - Fix zero P&L bug affecting 12 historical trades - Add SQL scripts for recalculating historical P&L data - Move archive TypeScript files to .archive to fix build Defaults: - SOL: 10 base × 10x leverage = 100 notional (profit trading) - ETH: base × 1x leverage = notional (data collection) - Global: 10 × 10x for BTC and other symbols Configuration priority: Per-symbol ENV > Market config > Global ENV > Defaults
6.2 KiB
6.2 KiB
Per-Symbol Settings Quick Reference
Access Settings UI
http://localhost:3001/settings
Symbol Sections
💎 Solana (SOL-PERP)
- Toggle: Enable/disable SOL trading
- Position Size: Base USD amount (default: 210)
- Leverage: Multiplier 1-20x (default: 10x)
- Notional: $210 × 10x = $2100 position
- Use Case: Primary profit generation
⚡ Ethereum (ETH-PERP)
- Toggle: Enable/disable ETH trading
- Position Size: Base USD amount (default: 4)
- Leverage: Multiplier 1-20x (default: 1x)
- Notional: $4 × 1x = $4 position
- Use Case: Data collection with minimal risk
- Note: Drift minimum is ~$38-40 (0.01 ETH)
💰 Global Fallback
- Applies To: BTC-PERP and any future symbols
- Position Size: Default: 54
- Leverage: Default: 10x
Environment Variables
# SOL Settings
SOLANA_ENABLED=true
SOLANA_POSITION_SIZE=210
SOLANA_LEVERAGE=10
# ETH Settings
ETHEREUM_ENABLED=true
ETHEREUM_POSITION_SIZE=4
ETHEREUM_LEVERAGE=1
# Global Fallback (BTC, etc.)
MAX_POSITION_SIZE_USD=54
LEVERAGE=10
Common Scenarios
Scenario 1: Disable ETH Trading
- Go to Settings UI
- Toggle off "Enable Ethereum Trading"
- Click "Save Settings"
- Click "Restart Bot"
- All ETH signals will now be rejected
Scenario 2: Increase SOL Position Size
- Go to Settings UI
- Adjust "SOL Position Size" slider or input
- Adjust "SOL Leverage" if needed
- Review Risk/Reward calculator
- Click "Save Settings"
- Click "Restart Bot"
Scenario 3: Test Single Symbol
- Go to Settings UI
- Click "💎 Test SOL LONG" or "⚡ Test ETH LONG"
- Confirm warning dialog
- Watch for success/error message
- Check Position Manager logs
Scenario 4: Minimal Risk on Both
SOLANA_ENABLED=true
SOLANA_POSITION_SIZE=4
SOLANA_LEVERAGE=1
ETHEREUM_ENABLED=true
ETHEREUM_POSITION_SIZE=4
ETHEREUM_LEVERAGE=1
Test Buttons
💎 SOL Test Buttons
- Test SOL LONG: Opens long position with SOL settings
- Test SOL SHORT: Opens short position with SOL settings
- Disabled when
SOLANA_ENABLED=false
⚡ ETH Test Buttons
- Test ETH LONG: Opens long position with ETH settings
- Test ETH SHORT: Opens short position with ETH settings
- Disabled when
ETHEREUM_ENABLED=false
Checking Current Settings
Via UI
http://localhost:3001/settings
Via API
curl http://localhost:3001/api/settings | jq
Via Container Logs
docker logs trading-bot-v4 | grep "Symbol-specific sizing"
Via Environment
docker exec trading-bot-v4 printenv | grep -E "SOLANA|ETHEREUM|POSITION_SIZE|LEVERAGE"
Priority Order
When bot receives signal, it checks in this order:
- ✅ Per-symbol ENV (
SOLANA_POSITION_SIZE) - highest priority - Market-specific config (code level)
- Global ENV (
MAX_POSITION_SIZE_USD) - fallback - Default config (code level) - last resort
Risk Calculator
Each symbol section shows:
- Max Loss: Base × Leverage × |SL%|
- Full Win: TP1 gain + TP2 gain
- R:R Ratio: How much you win vs how much you risk
Example: SOL with $210 × 10x
- SL: -1.5% → Max Loss: $31.50
- TP1: +0.7% (50% position) → $7.35
- TP2: +1.5% (50% position) → $15.75
- Full Win: $23.10
- R:R: 1:0.73
Monitoring Per-Symbol Trading
Check if Symbol Enabled
# Look for "Symbol trading disabled" errors
docker logs trading-bot-v4 | grep "trading disabled"
Check Position Sizes
# Look for symbol-specific sizing logs
docker logs trading-bot-v4 | grep "Symbol-specific sizing"
Recent ETH Trades
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c "
SELECT
entry_time::timestamp,
symbol,
direction,
base_position_size,
leverage,
ROUND(position_size, 2) as notional,
ROUND(realized_pnl, 2) as pnl
FROM trades
WHERE symbol = 'ETH-PERP'
AND test_trade = false
ORDER BY entry_time DESC
LIMIT 10;
"
Recent SOL Trades
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c "
SELECT
entry_time::timestamp,
symbol,
direction,
base_position_size,
leverage,
ROUND(position_size, 2) as notional,
ROUND(realized_pnl, 2) as pnl
FROM trades
WHERE symbol = 'SOL-PERP'
AND test_trade = false
ORDER BY entry_time DESC
LIMIT 10;
"
Troubleshooting
"Symbol trading disabled" Error
Cause: Symbol is toggled off in settings Solution:
- Check settings UI - is toggle on?
- Check ENV:
docker exec trading-bot-v4 printenv | grep ENABLED - If needed, set
SOLANA_ENABLED=trueorETHEREUM_ENABLED=true - Restart bot
ETH Trades Using $540 Instead of $4
Cause: Global ENV override Solution:
- Check:
docker exec trading-bot-v4 printenv | grep ETHEREUM - Should see:
ETHEREUM_POSITION_SIZE=4 - If not, update settings UI and restart
- Verify logs show:
ETH Position size: $4
SOL Trades Using Wrong Size
Cause: Global ENV override Solution:
- Check:
docker exec trading-bot-v4 printenv | grep SOLANA - Should see:
SOLANA_POSITION_SIZE=210 - If not, update settings UI and restart
Changes Not Applied After Save
Cause: Bot not restarted Solution:
- Settings page shows: "Click Restart Bot to apply changes"
- Must click "🔄 Restart Bot" button
- Wait ~10 seconds for restart
- Verify with
docker logs trading-bot-v4
Best Practices
- Test First: Use test buttons before enabling live trading
- Check Risk: Review Risk/Reward calculator before changing sizes
- Save + Restart: Always restart after saving settings
- Monitor Logs: Watch logs for first few trades after changes
- Verify Sizes: Check database to confirm actual executed sizes
- One at a Time: Change one symbol setting at a time for easier debugging
Quick Commands
# Full system restart
docker compose restart trading-bot
# View real-time logs
docker logs -f trading-bot-v4
# Check ENV variables
docker exec trading-bot-v4 printenv | grep -E "POSITION|LEVERAGE|ENABLED"
# Test settings API
curl http://localhost:3001/api/settings | jq
# Check recent trades by symbol
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c \
"SELECT symbol, COUNT(*), ROUND(SUM(realized_pnl),2) FROM trades WHERE test_trade=false GROUP BY symbol;"