AutoHedge Documentation

repository·main·Indexed 26 days ago

https://github.com/the-swarm-corporation/autohedge

An autonomous agent hedge fund designed for trading in the Solana ecosystem. AutoHedge uses a multi-agent architecture consisting of Director, Quant, Risk Management, and Execution agents to perform market analysis, risk assessment, and order execution. It provides a programmatic interface via the AutoHedge class and an interactive CLI REPL for executing trading tasks through natural language prompts.

Tokens
1.2K
Snippets
4
Records
15
Agent score
88%

What's inside AutoHedge

  1. Overview of AutoHedge Multi-Agent Architecture

    main

    AutoHedge operates using a specialized multi-agent pipeline where each agent handles a specific stage of the trading lifecycle:

    1. Director Agent: Responsible for strategy and thesis generation.
    2. Quant Agent: Performs technical and statistical analysis.
    3. Risk Management Agent: Handles position sizing and risk assessment.
    4. Execution Agent: Manages order generation and execution.
  2. Configure AutoHedge environment variables

    main

    AutoHedge requires several environment variables for API access and trading. Set these in your environment or a .env file.

    Jupiter API

    Required for token prices and search tools. Obtain a key at https://portal.jup.ag.

    • JUPITER_API_KEY

    AI Agents

    Required for experimental agent functionality (OpenAI/Anthropic).

    • OPENAI_API_KEY
    • ANTHROPIC_API_KEY
    • WORKSPACE_DIR: The directory used for agent workspaces (e.g., "agent_workspace").

    Trading

    Required for executing trades on Solana.

    • WALLET_PRIVATE_KEY: Your Solana wallet private key.
    # Jupiter API (token price & search tools)
    JUPITER_API_KEY=
    
    # OpenAI (experimental agents)
    OPENAI_API_KEY=
    ANTHROPIC_API_KEY=
    WORKSPACE_DIR="agent_workspace"
    
    # Trading
    WALLET_PRIVATE_KEY=""
  3. Use the AutoHedge CLI REPL

    main

    The AutoHedge CLI provides an interactive REPL (Read-Eval-Print Loop) for executing research and hedging tasks via natural language prompts.

    To start the interactive session, run the autohedge command from your terminal. Once inside the REPL, you can enter task prompts directly.

    REPL Commands:

    • <task>: Enter a natural language instruction (e.g., Analyze NVDA for 50k allocation) to execute a task.
    • help, ?, or h: Display usage tips.
    • quit, exit, or q: Exit the REPL session.
  4. Load environment variables with load_env()

    main
    Use load_env() to automatically locate and load a .env file. The function searches for a .env file by walking up the directory tree from the current working directory until it finds one (the project root approach). If a .env file is found in the project root, it is loaded without overriding existing environment variables. If no project-root .env is found, it falls back to loading from the current working directory. This ensures API keys are available even when running scripts from subdirectories.