The Problem
Building an autonomous hedge‑fund‑style system that can analyse markets, manage risk and execute trades normally requires stitching together market‑data APIs, agent frameworks, and execution logic. This repo promises a “minutes‑to‑deployment” swarm‑intelligence stack, but the codebase has several structural and operational weaknesses that affect reproducibility, security and long‑term maintainability.
What This Does
AutoHedge is a Python package (19 source files) that wires together AI agents, market‑data fetchers and trade executors. The core lives in autohedge/ (15 files) with an experimental/ directory containing additional agent prototypes. Execution starts at the CLI entry point autohedge/cli.py:217 (main) or the program‑start autohedge/main.py:33 (run). A run follows a short path: run → market_making_strategy → fetch_market_data (network via session.get) and writes recent‑task logs to logs/ via _append_recent → _get_recent_tasks (filesystem). The module‑import graph has 19 Python modules and 16 import edges; the most connected hub is autohedge/__init__ (2 importers, 2 importers, instability 0.5). Three modules show deep nesting (indentation depth 8) – autohedge/tools/exa_search_tool.py, experimental/market_making.py, experimental/btc_agent.py – making control‑flow hard to follow. Two files have broad except clauses that swallow errors: autohedge/cli.py and autohedge/tools/yahoo_api.py. Two pairs of files duplicate 6‑line blocks: autohedge/tools/jupiter_price.py and autohedge/tools/jupiter_search.py.
How It Is Wired
- Entry points –
run(autohedge/main.py:33) reaches 5 functions and is called by nothing else in the repo;main(autohedge/cli.py:217) reaches 12 functions and is invoked from one place (the CLI). - Call graph – key functions such as
_df_to_json_serializable(4 callers),_get(3 callers),_headers(3 callers),_safe_info(3 callers) andMarketData(2 callers) form the backbone of data flow. - Outbound effects – 9 functions make network calls (e.g.,
exa_search,get_token_price,get_stock_quote) and 3 functions read/write files (_append_recent,_get_recent_tasks,RECENT_FILE.mkdir). - File responsibilities –
experimental/market_making.py(10 functions, 3 classes, network call) defines the core trading pipeline;experimental/btc_agent.py(12 functions, 1 class, network call) implements a crypto agent;autohedge/cli.pyhandles CLI parsing and recent‑task file I/O;autohedge/tools/jupiter_price.pyandjupiter_search.pyprovide price‑and‑search helpers each with a single network‑call function.
How To Use It
Setup
git clone https://github.com/moses-y/AutoHedge
cd AutoHedge
python -m pip install -U . # installs from pyproject.toml
Configuration Create a .env file (copy from .env.example). Required variables (as listed in the README) include:
JUPITER_API_KEY= # token price & search
OPENAI_API_KEY= # experimental agents
ANTHROPIC_API_KEY= # experimental agents
WORKSPACE_DIR="agent_workspace"
WALLET_PRIVATE_KEY="" # Solana trading
Running it
autohedge # invokes the CLI entry point (main)
# or
python -m autohedge.main # runs the program‑start entry point
The CLI (autohedge/cli.py) parses args, loads environment via autohedge/env_loader.py, then starts the agent pipeline (run_repl → _welcome → _append_recent → _get_recent_tasks).
Real‑World Use
A quant wanting to automate Solana‑based arbitrage can spin up an AutoHedge instance, supply a wallet private key and Jupiter API key, and the system will continuously pull market data (fetch_market_data), run the director/quant/risk/execution agent chain, and emit structured JSON trade recommendations. The risk‑first design ensures position sizing is calculated (calculate_order_size) before any order is dispatched (execute_trade). For prototyping new strategies, the experimental/ folders expose additional agent skeletons (btc_agent.py, market_making.py) that can be registered through tools/tools_registry.py.
Code Health & Issues
- Measured static‑analysis findings (6 total):
[HIGH/cognitive_load]Deep nesting x3 – files:autohedge/tools/exa_search_tool.py,experimental/market_making.py,experimental/btc_agent.py(max indent 8).[MEDIUM/resilience]Broad exception handling x2 – files:autohedge/cli.py,autohedge/tools/yahoo_api.py(bareexceptswallows errors).[MEDIUM/clarity]Duplicated code blocks – files:autohedge/tools/jupiter_price.py,autohedge/tools/jupiter_search.py(7 repeated 6‑line blocks).
- Code‑health audit (8 findings, 0 critical):
HIGH– Add a test suite; this repository has none (19 source files, no test files).HIGH– Commit a lockfile beside the manifest (pyproject.toml); currently no lockfile, causing non‑reproducible builds.MEDIUM– Declare least‑privilege permissions forGITHUB_TOKEN–.github/workflows/docs_test.yml(3 workflows have nopermissionsdeclaration).MEDIUM– Gate pull requests on a dependency vulnerability scan – no scan in CI.MEDIUM– Move large binaries to Git LFS or out of the repo –logs/trades_20250305_193100.csv(28.9 MB) andlogs/trades_20250305_193129.csv(6.5 MB).MEDIUM– Setpersist-credentials: falseon checkout –.github/workflows/docs_test.ymlkeeps the token for later steps.MEDIUM– Pin resolution to avoid vulnerable versions – declared ranges reachblack@23.1.0CVE‑2026‑31900 (critical) plus three other advisories; no lockfile fixes this.LOW– Settimeout-minuteson workflow jobs – 4 jobs have no timeout, risking overlap on a two‑hourly schedule.
The Bottom Line
AutoHedge delivers a functional multi‑agent framework for autonomous Solana trading out of the box, with clear entry points and a modular agent pipeline. However, the lack of a lockfile, missing test coverage, broad exception handling, and sizable CSV logs in the repo create reproducibility and security risks. It is well‑suited for teams that can add CI test gates, commit a dependency lockfile, and move trade‑log data out of version control. Organisations needing a ready‑to‑run hedge‑fund prototype will find value here, provided they address the documented health items.