dralves/ai-agent

★ 0Forks 0RustGitHub ↗Compare

README

AI Trader

Rust-based, modular AI trading agent for crypto (extensible to other asset classes). Combines market data, technical features, and source-aware news signals with a model-driven decision engine.

Quickstart

Prereqs: Rust stable (see rust-toolchain.toml), SQLite (optional), Docker (optional) for Postgres.

Install deps and run tests:

cargo build
cargo test

Run CLI help:

cargo run --bin trader -- --help

Fetch historical klines:

cargo run --bin trader -- fetch --symbol BTCUSDT --interval 60 --limit 10 --http-base https://api.binance.us

Stream live candles:

cargo run --bin trader -- stream --symbol BTCUSDT --interval 60 --ws-base wss://stream.binance.com:9443

Inspect features (M4):

cargo run --bin trader -- features --symbol BTCUSDT --interval 60 --window 32
cargo run --bin trader -- features-dump --symbol BTCUSDT --interval 60 --limit 50 --http-base https://api.binance.us --window 32

News (RSS + optional Twitter):

# RSS only
cargo run --bin trader -- news
# With Twitter (requires TRADER__TWITTER_BEARER_TOKEN)
cargo run --bin trader -- news --twitter

Parity tests

Loose parity (fixture included):

cargo test -q --test parity_indicators

Strict parity against exported reference CSV (TradingView/Binance):

STRICT_PARITY_CSV=/abs/path/to/ref.csv cargo test -q --test parity_indicators_strict

Configuration

See config/default.toml and environment overrides (prefix TRADER__, supports JSON arrays via try_parsing).

Important env vars:

  • TRADER__DATABASE_URL
  • TRADER__BINANCE_HTTP_BASE, TRADER__BINANCE_WS_BASE
  • TRADER__NEWS_FEEDS, TRADER__NEWS_POLL_SECS
  • TRADER__TWITTER_BEARER_TOKEN, TRADER__TWITTER_QUERIES, TRADER__TWITTER_API_BASE

Database schema

See docs/SCHEMA.md for tables and PG vs SQLite differences. Postgres is recommended with pgvector for embeddings.

Development

  • Formatting: rustfmt (see rustfmt.toml)
  • Linting: clippy (see clippy.toml)
  • Toolchain: rust-toolchain.toml (stable with clippy + rustfmt components)

Roadmap

See docs/TODO.md for milestones. M5 introduces embeddings + news features; M5.5 adds source scoring, responsiveness, and automated discovery.