Crypto Bot (Max)
Prompt
Role & Objective You are a Staff Full-Stack Engineer and Quantitative Trading Systems Architect. Build a production-ready, highly responsive cryptocurrency trading bot web application featuring a sleek, dark-mode financial dashboard. The application must support two operational modes: Paper Trading (Sandbox): Simulated order execution, virtual balances, zero financial risk. Live Trading: Real-world trade execution via exchange APIs (Binance.US and Coinbase Advanced Trade). 1. Technical Stack & Architecture Framework: Next.js (App Router) or React + Vite with TypeScript. Styling: Tailwind CSS with a clean, high-contrast dark theme (e.g., slate/zinc dark backgrounds #0B0E14, #151A23, muted borders #2A3241, green #10B981 for gains/buys, red #EF4444 for losses/sells). Component Primitives: Lucide-react icons, Radix UI / shadcn/ui patterns. Charting: TradingView Lightweight Charts (lightweight-charts) or equivalent high-performance canvas candlestick library. State Management: Zustand (or React Context) separating market data, active positions, bot config, and order history. Exchange Integration Layer: Standardized adapter pattern (or ccxt) to normalize data structures between Binance.US and Coinbase Advanced. 2. Core Functional Modules A. Environment & Platform Credentials Mode Toggle: Prominent UI switch between Paper Trading and Live Trading with clear visual indicator (e.g., yellow badge for paper, green badge for live). Exchange Selector: Dropdown to select between Binance.US and Coinbase Advanced. Credential Storage: In Paper mode: Mock balance starts at $10,000 USD (customizable). In Live mode: Inputs for API Key, API Secret, and Passphrase (if required by Coinbase). Credentials must be handled securely in memory/environment or encrypted locally; do not log secret keys to console. B. Market Selection & Dynamic Pair Polling Dropdown/searchable selector for trading pairs (e.g., BTC/USD, SOL/USD, ETH/USD). Dynamic fetching of available ticker pairs from the chosen platform's public endpoints. Current ticker price banner displaying: 24h High, 24h Low, 24h Volume, and percentage change. C. Strategy Engine & Risk Management Strategy Selector: Pluggable architecture allowing strategy selection. Implement a configurable strategy engine that evaluates conditions every 5 seconds against incoming candlestick data. Strategies: Hybrid Volatility-Adaptive (Hybrid) Blends Short-Term Bollinger Band Mean Reversion in compressed bandwidth regimes with Long-Term Trend Pullback when Price > EMA(200) and EMA(50) >= EMA(200); Short-Term Mean Reversion (Short-Term 5m) Close <= Lower Bollinger Band(20, 2.0) * 1.0015, RSI(14) < 33 with positive hook (RSI_t > RSI_t-1), and bullish 5m rejection candle (Close >= Open); Short-Term Momentum Breakout (Short-Term 5m) EMA(9) > EMA(21), 5m Close crosses above Bollinger Midband(20), RSI(14) in 52β68 momentum zone, and Volume >= 1.20x 20-period Volume SMA; Long-Term Macro Trend Pullback (Long-Term Macro + 5m) Close > EMA(200) & EMA(50) > EMA(200) macro bull filter, pullback to EMA(21) or RSI(14) < 42 value zone, with bullish candle turn confirmation (Close >= Open); Long-Term Golden Momentum Stack (Long-Term Macro + 5m) Full exponential stack EMA(9) > EMA(21) > EMA(50) > EMA(200), RSI(14) between 55 and 70, Close > EMA(9), and Volume >= 1.10x 20-period SMA; Risk Controls (Take-Profit & Stop-Loss) Input field for Take-Profit (TP): Toggleable between percentage (%) and fixed dollar amount ($). Input field for Stop-Loss (SL): Toggleable between percentage (%) and fixed dollar amount ($). Validation: Ensure SL and TP values are logically bounded relative to entry price before enabling the bot. D. Bot Execution Engine Master Controls: Start Bot / Stop Bot toggle button with clear status badge (RUNNING, PAUSED, ERROR). Automated 5-second polling loop that: Fetches latest OHLCV and order book snapshot. Evaluates the active strategy criteria. Checks all open positions against active TP and SL thresholds. Triggers order execution when entry or exit conditions are met. E. Manual Order Controls (Overrides) Manual Buy: Instant market buy dialog allowing user to purchase an asset by dollar amount or asset quantity at any time. Manual Sell: One-click "Close Position / Market Sell" button on any open position. Dynamic TP/SL Adjustment: Inline modal or table edit allowing real-time modification of TP and SL on open positions without canceling the trade. 3. UI & Dashboard Layout Requirements Top Header: Total Portfolio Balance (USD equivalent), Unrealized PnL ( / / / %). Mode Badge (Paper Trading vs Live Trading). Exchange Status (Connected / Disconnected). Main Chart Workspace (Center-Left): Candlestick chart updating every 5 seconds. Interval timeframe selector: 1m, 5m, 15m, 1h, 4h, 1d. Technical indicator overlays corresponding to the active strategy (e.g., SMA lines, RSI sub-chart). Visual markers on the chart showing Entry Price, current Stop-Loss level, and current Take-Profit target. Bot Configuration Sidebar / Panel (Center-Right): Pair selector and strategy picker. Order size input (USD or % of balance). TP and SL input controls. Start / Stop Bot trigger. Orders & Positions Table (Bottom Panel): Tabs: Open Positions, Order History, Trade Logs. Filter bar: Filter table by specific Trading Pair, Order Status (OPEN, FILLED, CANCELED, CLOSED), and Type (BUY, SELL). Table columns: Timestamp Pair Side (BUY green, SELL red) Entry Price / Fill Price Current Price (for open orders) Amount (Base & Quote) Take-Profit / Stop-Loss targets PnL ($ and % formatted with color coding) Actions (Inline button to edit TP/SL, and "Close at Market" button) 4. Engineering Standards & Error Handling TypeScript: Strict typing across all components. Provide complete interfaces for Order, Position, Candle, StrategyConfig, and ExchangeCredentials. API Graceful Degradation: If an exchange rate limit or network glitch occurs during the 5-second poll, back off cleanly and display an alert without freezing the UI. No Incomplete Placeholders: Deliver functional, fully connected UI components and complete calculation helpers (e.g., fee estimation, PnL math, slippage calculation for paper trading).
A system prompt was added to support web rendering
Response not available
Response not available