Files
trading_bot_v4/docs/markets/FARTCOIN-PERP.md
copilot-swe-agent[bot] 2df6c69b92 feat: Add FARTCOIN-PERP market support with percentage-based sizing
- Added FARTCOIN-PERP to SUPPORTED_MARKETS (market index 22)
- Updated TradingConfig interface with fartcoin symbol settings
- Added default config: 20% portfolio, 10x leverage, disabled by default
- Updated normalizeTradingViewSymbol to detect FARTCOIN
- Enhanced getPositionSizeForSymbol for FARTCOIN-PERP handling
- Enhanced getActualPositionSizeForSymbol for percentage-based sizing
- Added FARTCOIN ENV variable loading in getConfigFromEnv
- Updated Settings UI with FARTCOIN section and percentage badge
- Added FARTCOIN fields to settings API endpoints (GET/POST)
- Created comprehensive documentation in docs/markets/FARTCOIN-PERP.md
- Build successful: TypeScript compilation and static generation complete

Co-authored-by: mindesbunister <32161838+mindesbunister@users.noreply.github.com>
2025-12-06 17:44:19 +00:00

4.9 KiB
Raw Blame History

FARTCOIN-PERP Market Configuration

Market Details

  • Market Index: 22
  • Symbol: FARTCOIN-PERP
  • Oracle: 2sZomfWMDuQLcFak3nuharXorHrZ3hK8iaML6ZGSHtso
  • Min Order Size: 1 FARTCOIN
  • Tick Size: $0.0001 (price precision)
  • Initial Margin Ratio: 10% (max 10x leverage)
  • Maintenance Margin Ratio: 5%

Configuration Mode

  • Mode: PROFIT GENERATION 💰
  • Position Sizing: Percentage-based (20% of portfolio default)
  • Default Leverage: 10x
  • Status: Disabled by default

Environment Variables

FARTCOIN_ENABLED=false          # Enable/disable FARTCOIN trading
FARTCOIN_POSITION_SIZE=20       # 20% of portfolio (not fixed USD)
FARTCOIN_LEVERAGE=10            # Max 10x leverage
FARTCOIN_USE_PERCENTAGE_SIZE=true  # Always true for FARTCOIN

Enabling FARTCOIN Trading

  1. Navigate to Settings page: http://localhost:3001/settings
  2. Scroll to "🎈 Fartcoin (FARTCOIN-PERP)" section
  3. Toggle "Enable Fartcoin Trading" to ON
  4. Adjust position size percentage (recommended: 10-20%)
  5. Set leverage (recommended: 10x for max profit potential)
  6. Click "Save Settings"

Via Environment Variables

  1. Edit .env file
  2. Set FARTCOIN_ENABLED=true
  3. Adjust FARTCOIN_POSITION_SIZE (1-100%)
  4. Adjust FARTCOIN_LEVERAGE (1-10x)
  5. Restart container: docker restart trading-bot-v4

Via TradingView Alert

Ensure your TradingView alert includes FARTCOIN symbol:

{
  "symbol": "FARTCOINUSDT",  // or "FARTCOIN"
  "direction": "long",
  // ... other fields
}

The bot will automatically normalize FARTCOINUSDT to FARTCOIN-PERP.

Position Size Calculation

Percentage-based sizing formula:

Base Capital = Portfolio × Position Size %
Notional Position = Base Capital × Leverage

Example with $1000 portfolio:
- Position Size: 20% → Base = $200
- Leverage: 10x → Notional = $2000
- Risk Exposure: $200 (max loss is your base capital)

Risk/Reward Example:

  • Portfolio: $1000
  • Position: 20% ($200) × 10x = $2000 notional
  • Max Loss (1.5% SL): $30 (1.5% of $2000)
  • Target Win (1.8% TP): $36 (1.8% of $2000)
  • R:R Ratio: 1:1.2

Key Differences from SOL/ETH

Feature FARTCOIN SOL ETH
Position Sizing Percentage-based Fixed USD Fixed USD
Default Enabled Disabled Enabled Enabled
Purpose Profit generation Profit generation Data collection
Default Size 20% portfolio $210 fixed $4 fixed
Default Leverage 10x 10x 1x
Max Leverage 10x 20x 20x

Risk Management

Important Notes:

  1. Disabled by default - Safe to deploy, enable when ready
  2. Max 10x leverage - Based on Drift Protocol margin requirements
  3. Percentage sizing - Automatically scales with portfolio size
  4. Quality thresholds - Uses same signal quality filters as SOL/ETH
  5. Adaptive leverage - Quality score determines actual leverage used

TradingView Setup

Your indicator should include FARTCOIN detection logic. The bot will:

  1. Receive webhook with "symbol": "FARTCOINUSDT"
  2. Normalize to FARTCOIN-PERP via normalizeTradingViewSymbol()
  3. Check if FARTCOIN_ENABLED=true
  4. Calculate position size as percentage of free collateral
  5. Apply max 10x leverage
  6. Execute trade on Drift Protocol market index 22

Testing Checklist

Before enabling FARTCOIN trading in production:

  • Settings UI shows FARTCOIN section correctly
  • Toggle switch works (enabled/disabled state)
  • Position size slider adjusts (1-100%)
  • Leverage slider adjusts (1-10x)
  • Risk calculator shows correct values
  • Percentage calculation: 20% of $1000 = $200 base
  • Notional calculation: $200 × 10x = $2000
  • Settings save successfully to .env
  • Container restart applies new settings
  • Symbol detection works: "FARTCOINUSDT" → "FARTCOIN-PERP"
  • Test trade executes with correct position size

Monitoring

Watch for these log messages when FARTCOIN trading is active:

📊 Percentage sizing: 20% of $1000.00 = $200.00
📊 Adaptive leverage: Quality 92 → 10x leverage
🎯 Opening position: FARTCOIN-PERP LONG $2000.00 (10x leverage)
✅ Position opened successfully

Troubleshooting

FARTCOIN trades not executing:

  1. Check FARTCOIN_ENABLED=true in settings
  2. Verify symbol normalization in logs
  3. Check quality score meets threshold (90+ for LONG, 95+ for SHORT)
  4. Ensure TradingView alert includes correct symbol
  5. Verify free collateral > required amount

Position size incorrect:

  1. Check FARTCOIN_USE_PERCENTAGE_SIZE=true (should always be true)
  2. Verify percentage calculation in logs
  3. Check free collateral value
  4. Ensure leverage is between 1-10x

Settings not saving:

  1. Check .env file permissions (should be writable)
  2. Verify container has access to .env file
  3. Check logs for "Settings updated" message
  4. Restart container after manual .env changes