OpenAlice

OpenAlice

File-driven AI trading agent engine for crypto and securities markets

Stars: 293

Visit
 screenshot

Open Alice is an AI trading agent that provides users with their own research desk, quant team, trading floor, and risk management, all running on their laptop 24/7. It is file-driven, reasoning-driven, and OS-native, allowing interactions with the operating system. Features include dual AI providers, crypto trading, securities trading, market analysis, cognitive state, event log, cron scheduling, evolution mode, and a web UI. The architecture includes providers, core components, extensions, tasks, and interfaces. Users can quickly start by setting up prerequisites, AI providers, crypto trading, securities trading, environment variables, and running the tool. Configuration files, project structure, and license information are also provided.

README:

Open Alice

๐Ÿ“– Documentation ยท ๐Ÿ”ด Live Demo ยท MIT License

Open Alice

Your one-person Wall Street. Alice is an AI trading agent that gives you your own research desk, quant team, trading floor, and risk management โ€” all running on your laptop 24/7.

  • File-driven โ€” Markdown defines persona and tasks, JSON defines config, JSONL stores conversations. Both humans and AI control Alice by reading and modifying files. The same read/write primitives that power vibe coding transfer directly to vibe trading. No database, no containers, just files.
  • Reasoning-driven โ€” every trading decision is based on continuous reasoning and signal mixing. Visit traderalice.com/live to see how Alice reasons in real time.
  • OS-native โ€” Alice can interact with your operating system. Search the web through your browser, send messages via Telegram, and connect to local devices.

Features

  • Dual AI provider โ€” switch between Claude Code CLI and Vercel AI SDK at runtime, no restart needed
  • Crypto trading โ€” CCXT-based execution (Bybit, OKX, Binance, etc.) with a git-like wallet (stage, commit, push)
  • Securities trading โ€” Alpaca integration for US equities with the same wallet workflow
  • Market analysis โ€” technical indicators, news search, and price simulation via sandboxed tools
  • Cognitive state โ€” persistent "brain" with frontal lobe memory, emotion tracking, and commit history
  • Event log โ€” persistent append-only JSONL event log with real-time subscriptions and crash recovery
  • Cron scheduling โ€” event-driven cron system with AI-powered job execution and automatic delivery to the last-interacted channel
  • Evolution mode โ€” two-tier permission system. Normal mode sandboxes the AI to data/brain/; evolution mode gives full project access including Bash, enabling the agent to modify its own source code
  • Web UI โ€” built-in local chat interface on port 3002, no Telegram account needed

Architecture

graph LR
  subgraph Providers
    CC[Claude Code CLI]
    VS[Vercel AI SDK]
  end

  subgraph Core
    PR[ProviderRouter]
    AC[AgentCenter]
    E[Engine]
    TC[ToolCenter]
    S[Session Store]
    EL[Event Log]
    CR[Connector Registry]
  end

  subgraph Extensions
    AK[Analysis Kit]
    CT[Crypto Trading]
    ST[Securities Trading]
    BR[Brain]
    BW[Browser]
  end

  subgraph Tasks
    CRON[Cron Engine]
    HB[Heartbeat]
  end

  subgraph Interfaces
    WEB[Web UI]
    TG[Telegram]
    HTTP[HTTP API]
    MCP[MCP Server]
  end

  CC --> PR
  VS --> PR
  PR --> AC
  AC --> E
  E --> S
  TC -->|Vercel tools| VS
  TC -->|MCP tools| MCP
  AK --> TC
  CT --> TC
  ST --> TC
  BR --> TC
  BW --> TC
  CRON --> EL
  HB --> CRON
  EL --> CRON
  CR --> WEB & TG
  WEB --> E
  TG --> E
  HTTP --> E
  MCP --> E

Providers โ€” interchangeable AI backends. Claude Code spawns claude -p as a subprocess; Vercel AI SDK runs a ToolLoopAgent in-process. ProviderRouter reads ai-provider.json on each call to select the active backend at runtime.

Core โ€” Engine is a thin facade that delegates to AgentCenter, which routes all calls (both stateless and session-aware) through ProviderRouter. ToolCenter is a centralized tool registry โ€” extensions register tools there, and it exports them in Vercel AI SDK and MCP formats. EventLog provides persistent append-only event storage (JSONL) with real-time subscriptions and crash recovery. ConnectorRegistry tracks which channel the user last spoke through.

Extensions โ€” domain-specific tool sets registered in ToolCenter. Each extension owns its tools, state, and persistence.

Tasks โ€” scheduled background work. CronEngine manages jobs and fires cron.fire events into the EventLog on schedule; a listener picks them up, runs them through the AI engine, and delivers replies via the ConnectorRegistry. Heartbeat is a periodic health-check that uses a structured response protocol (HEARTBEAT_OK / CHAT_NO / CHAT_YES).

Interfaces โ€” external surfaces. Web UI for local chat, Telegram bot for mobile, HTTP for webhooks, MCP server for tool exposure. External agents can also converse with Alice via a separate MCP endpoint.

Quick Start

Prerequisites

  • Node.js 22+
  • pnpm 10+

Setup

git clone https://github.com/TraderAlice/OpenAlice.git
cd OpenAlice
pnpm install
cp .env.example .env    # then fill in your keys

AI Provider

OpenAlice ships with two provider modes:

  • Vercel AI SDK (default) โ€” runs the agent in-process. Supports any provider compatible with the Vercel AI SDK (Anthropic, OpenAI, Google, etc.). Swap the provider implementation in src/providers/vercel-ai-sdk/ to use your preferred model. Requires an API key for your chosen provider (e.g. ANTHROPIC_API_KEY for Anthropic).
  • Claude Code (file-driven mode) โ€” spawns claude -p as a subprocess, giving the agent full Claude Code capabilities. Requires Claude Code installed and authenticated on the host machine. No separate API key needed โ€” uses your Claude Code login. To switch models, see how to change Claude Code's model.

Crypto Trading

Powered by CCXT. Defaults to Bybit demo trading. Configure the exchange and API keys in data/config/crypto.json and .env. Any CCXT-supported exchange can be used by modifying the provider implementation.

Securities Trading

Powered by Alpaca. Supports paper and live trading โ€” toggle via data/config/securities.json. Sign up at Alpaca and add your keys to .env. IBKR support is planned.

Environment Variables

Variable Description
ANTHROPIC_API_KEY API key for Vercel AI SDK provider (not needed if using Claude Code CLI)
EXCHANGE_API_KEY Crypto exchange API key (optional)
EXCHANGE_API_SECRET Crypto exchange API secret (optional)
TELEGRAM_BOT_TOKEN Telegram bot token (optional)
TELEGRAM_CHAT_ID Comma-separated chat IDs to allow (optional)
ALPACA_API_KEY Alpaca API key for securities (optional)
ALPACA_SECRET_KEY Alpaca secret key for securities (optional)

Run

pnpm dev        # start backend (port 3002) with watch mode
pnpm dev:ui     # start frontend dev server (port 5173) with hot reload
pnpm build      # production build (backend + UI)
pnpm test       # run tests

Web UI

The backend (port 3002) serves both the API and the built frontend from dist/ui/. During development, run pnpm dev:ui to start Vite's dev server on port 5173, which proxies API requests to port 3002 and provides hot module replacement.

Port What When
5173 Vite dev server (hot reload) pnpm dev:ui
3002 Backend API + built UI pnpm dev / pnpm build && node dist/main.js

Note: Port 3002 only serves the UI after pnpm build (or pnpm build:ui). If you haven't built yet, use port 5173 for frontend development.

Configuration

All config lives in data/config/ as JSON files with Zod validation. Missing files fall back to sensible defaults.

File Purpose
engine.json Trading pairs, tick interval, HTTP/MCP ports, timeframe
model.json AI model provider and model name
agent.json Max agent steps, evolution mode toggle, Claude Code tool permissions
crypto.json Allowed symbols, exchange provider (CCXT), demo trading flag
securities.json Allowed symbols, broker provider (Alpaca), paper trading flag
compaction.json Context window limits, auto-compaction thresholds
heartbeat.json Heartbeat enable/disable, interval, active hours
ai-provider.json Active AI provider (vercel-ai-sdk or claude-code), switchable at runtime

Persona and heartbeat prompts use a default + user override pattern:

Default (git-tracked) User override (gitignored)
data/default/persona.default.md data/brain/persona.md
data/default/heartbeat.default.md data/brain/heartbeat.md

On first run, defaults are auto-copied to the user override path. Edit the user files to customize without touching version control.

Project Structure

src/
  main.ts                    # Composition root โ€” wires everything together
  core/
    engine.ts                # Thin facade, delegates to AgentCenter
    agent-center.ts          # Centralized AI agent management, owns ProviderRouter
    ai-provider.ts           # AIProvider interface + ProviderRouter (runtime switching)
    tool-center.ts           # Centralized tool registry (Vercel + MCP export)
    ai-config.ts             # Runtime provider config read/write
    session.ts               # JSONL session store + format converters
    compaction.ts            # Auto-summarize long context windows
    config.ts                # Zod-validated config loader
    event-log.ts             # Persistent append-only event log (JSONL)
    connector-registry.ts    # Last-interacted channel tracker
    media.ts                 # MediaAttachment extraction from tool outputs
    types.ts                 # Plugin, EngineContext interfaces
  providers/
    claude-code/             # Claude Code CLI subprocess wrapper
    vercel-ai-sdk/           # Vercel AI SDK ToolLoopAgent wrapper
  extension/
    analysis-kit/            # Market data, indicators, news, sandbox
    crypto-trading/          # CCXT integration, wallet, tools
    securities-trading/      # Alpaca integration, wallet, tools
    brain/                   # Cognitive state (memory, emotion)
    browser/                 # Browser automation bridge (via OpenClaw)
  connectors/
    web/                     # Web UI chat (Hono, SSE push)
    telegram/                # Telegram bot (grammY, polling, commands)
    mcp-ask/                 # MCP Ask connector (external agent conversation)
  task/
    cron/                    # Cron scheduling (engine, listener, AI tools)
    heartbeat/               # Periodic heartbeat with structured response protocol
  plugins/
    http.ts                  # HTTP health/status endpoint
    mcp.ts                   # MCP server for tool exposure
  openclaw/                  # Browser automation subsystem (frozen)
data/
  config/                    # JSON configuration files
  default/                   # Factory defaults (persona, heartbeat prompts)
  sessions/                  # JSONL conversation histories
  brain/                     # Agent memory and emotion logs
  crypto-trading/            # Crypto wallet commit history
  securities-trading/        # Securities wallet commit history
  cron/                      # Cron job definitions (jobs.json)
  event-log/                 # Persistent event log (events.jsonl)
docs/                        # Architecture documentation

Star History

Star History Chart

License

MIT

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for OpenAlice

Similar Open Source Tools

For similar tasks

For similar jobs