right-longTrading Bot

Overview

The Trading Bot is an autonomous trading system that continuously monitors markets and executes trades based on AI-powered decisions. It trades across three market types: Trenches (spot), Polymarket (yes/no positions), and Hyperliquid (perpetual futures with long/short positions).

Key Features

Automated Trading

  • Continuous Operation: Runs 24/7, even when the page is closed

  • Multi-Market Trading: Trades across Trenches, Polymarket, and Hyperliquid

  • AI Decision Making: Uses Claude Sonnet 4.5 for intelligent trade decisions

  • Background Execution: Trades execute via background workers

Position Management

  • Long Positions: For spot tokens and perpetual futures

  • Short Positions: For perpetual futures (Hyperliquid)

  • Yes/No Positions: For Polymarket prediction markets

  • Position Tracking: Real-time monitoring of all open positions

Risk Management

  • Cash Management: Prevents negative cash balances

  • Position Sizing: Dynamic trade sizing based on available capital

  • Stop Loss Logic: Built-in risk controls

  • Portfolio Limits: Maximum position sizes and exposure limits

Trading Bot Configuration

Initial Capital

  • Default: $2,000 USD

  • Configurable: Can be adjusted in the code

  • Starting Cash: All capital starts as available cash

Trade Parameters

  • Minimum Trade: $10 USD

  • Maximum Trade: $100 USD (or available cash - $50)

  • Trade Frequency: Every 30 seconds (background trading)

  • Decision Interval: AI makes decisions before each trade

Trading Logic

Market Selection

The bot selects markets from:

  1. Trenches: Top 10 tokens from DexScreener

  2. Polymarket: Top 10 markets by volume

  3. Hyperliquid: Top 10 perpetuals by price change

AI Decision Process

  1. Market Analysis

    • Fetches current market data

    • Analyzes price trends

    • Evaluates volume and liquidity

    • Considers open positions

  2. Decision Generation

    • AI receives market context

    • Current holdings information

    • Available cash

    • Portfolio performance

  3. Action Selection

    • For Trenches: buy or sell

    • For Polymarket: yes or no

    • For Perpetuals: long, short, close_long, or close_short

  4. Trade Execution

    • Validates cash availability

    • Calculates position size

    • Executes trade

    • Updates portfolio

Portfolio Tracking

Metrics Displayed

  • Portfolio Value: Total value including cash and holdings

  • Available Cash: Liquid funds available for trading

  • Total Trades: Number of trades executed

  • Win Rate: Percentage of profitable trades

  • P&L: Profit and loss in USD and percentage

Holdings Display

  • Symbol: Token or market identifier

  • Amount: Quantity held

  • Average Price: Entry price

  • Current Value: Market value of position

  • P&L: Unrealized profit/loss

  • Position Type: Long or Short (for perpetuals)

Trade History

Each trade is logged with:

  • Timestamp: Exact time of execution

  • Action: Buy, Sell, Long, Short, Close Long, Close Short

  • Symbol: Market identifier

  • Amount: Quantity traded

  • Price: Execution price

  • Trade Value: Total value of trade

  • P&L: Realized profit/loss (for closed positions)

Background Trading

The bot continues trading even when:

  • The trading page is closed

  • No users are viewing the site

  • The server is running

Background Worker

  • Runs on every page load

  • Calls trading API every 30 seconds

  • Executes trades independently

  • Syncs state to database

Managing the Trading Bot

Viewing Performance

  1. Navigate to the Trading page

  2. View real-time portfolio metrics

  3. Monitor active positions

  4. Review trade history

Cash Management

The bot automatically:

  • Prevents trades that would result in negative cash

  • Rejects trades with insufficient funds

  • Closes positions if needed to free up cash (future feature)


Last updated