Nocturne is an AI-powered trading loop for Hyperliquid perpetuals. It collects live market data from TAAPI, summarizes account health, prompts an LLM for the next action, and executes the resulting trades with risk controls.
- Runs on Hyperliquid (mainnet or testnet) using your wallet keys.
- Pulls technical indicators from TAAPI and streams account/order state each cycle.
- Leverages OpenRouter-hosted models with structured JSON outputs and TAAPI tool calls.
- Ships with a lightweight HTTP API (
/diary,/logs) for live monitoring.
- Python 3.11+
- Poetry (or compatible virtual environment)
- Accounts + keys:
TAAPI_API_KEYHYPERLIQUID_PRIVATE_KEYorLIGHTER_PRIVATE_KEY(or a mnemonic)OPENROUTER_API_KEY
- Recommended:
.envbased on.env.example
- Ingest – Every interval, the agent fetches Hyperliquid balance, positions, fills, funding, and open orders.
- Enrich – TAAPI supplies intraday (5m) and higher-timeframe (4h) indicators for each configured asset.
- Decide – The LLM receives a compact JSON context and returns a schema-checked plan: buy, sell, or hold with sizing, TP/SL, and rationale.
- Execute – Orders are sent through the Hyperliquid SDK with retries, precision rounding, and follow-up reconciliation.
- Observe – Prompts, responses, and trade diary entries are persisted and exposed through the built-in aiohttp server.
See docs/ARCHITECTURE.md for a subsystem deep dive and the accompanying architecture diagram.
src/main.py– CLI entry point and orchestration loop.src/agent/decision_maker.py– LLM wrapper, tool calling, and response sanitation.src/indicators/taapi_client.py– TAAPI helper with retry/backoff.src/trading/hyperliquid_api.py– Exchange facade with async retries and order helpers.src/config_loader.py– Centralized.envparsing and defaults.
poetry install
cp .env.example .env # fill in keys, ASSETS, INTERVAL
poetry run python src/main.py --assets BTC ETH --interval 1hGET /diary?limit=200– recent JSONL diary entries as JSON or raw text.GET /logs?path=llm_requests.log&limit=2000– tails any local log file. Configure the bind address withAPI_HOSTand port withAPI_PORT/APP_PORT(defaults to0.0.0.0:3000).
docker build --platform linux/amd64 -t trading-agent .
docker run --rm -p 3000:3000 --env-file .env trading-agent
# curl http://localhost:3000/diary- Install the EigenX CLI:
- macOS/Linux:
curl -fsSL https://eigenx-scripts.s3.us-east-1.amazonaws.com/install-eigenx.sh | bash - Windows:
curl -fsSL https://eigenx-scripts.s3.us-east-1.amazonaws.com/install-eigenx.ps1 | powershell -
- macOS/Linux:
- Authenticate:
docker logintheneigenx auth login(oreigenx auth generate --store). - Deploy from the repo root:
cp .env.example .env eigenx app deploy
- Monitor with
eigenx app info --watchandeigenx app logs --watch. Upgrade usingeigenx app upgrade <app-name>.
- GPT-5 Pro — Portfolio | Logs
- DeepSeek R1 (paused) — Portfolio | Logs
- Grok 4 (paused) — Portfolio | Logs
Trading carries risk. This project is unaudited and provided as-is—use at your own discretion.
Developer: @Manokil