█████╗ ███████╗ ██████╗ ████████╗██╗ ██╗
██╔══██╗╚══███╔╝██╔═══██╗╚══██╔══╝██║ ██║
███████║ ███╔╝ ██║ ██║ ██║ ███████║
██╔══██║ ███╔╝ ██║ ██║ ██║ ██╔══██║
██║ ██║███████╗╚██████╔╝ ██║ ██║ ██║
╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
Azoth is an AI stock trading assistant and terminal CLI for the Vietnam stock market, built for equity research, portfolio analysis, backtesting, paper trading, and broker-aware trading workflows.
It combines an interactive terminal UI, Claude Agent SDK orchestration, Vietnam market-data tools, multi-agent stock research, local journaling, configurable interval backtests, and optional DNSE Entrade X live broker integration. Azoth is designed for disciplined decision support across HOSE, HNX, and UPCOM: every recommendation should be grounded in tool output, written to a journal, and constrained by explicit autonomy and risk settings.
Azoth is investment software, not financial advice. Live trading can place real orders against a real account. Use advisory or paper mode until you have verified configuration, data quality, account state, and risk limits.
Latest release: v0.1.2
Azoth opens as a chat-first terminal workspace. Market data, team analysis, portfolio state, journal rows, and backtest results render inline, so the conversation remains the primary workflow.
Run a full team analysis:
/analyze FPT
Ask a portfolio-level question:
/team Should we rotate from steel into banks this month?
Check market, portfolio, journal, and backtest state:
/quote VCB
/positions
/journal decisions 10
/backtest
- Agent-native CLI: run Azoth from the terminal with a rich Ink-based UI, streaming model output, tool chips, status bar, slash commands, and resumable project sessions.
- Chat-first workflow: market data, team analysis, journals, backtests, and broker state render inline in the conversation instead of a pinned dashboard.
- Automatic subagent routing: broad portfolio questions use
team_question; deep single-ticker recommendations useteam_analyze; the outer agent waits for the team and summarizes role findings. - VN market research tools: quote, OHLCV, technical indicators, fundamentals, company news, macro indices, foreign flow, ticker discovery, portfolio state, and decision journal.
- Multi-agent desk: structured analyst workflow with technical, fundamentals, news, sentiment, bull, bear, research manager, trader, risk, and portfolio roles.
- Broker-aware execution: advisory, confirm, and auto autonomy modes with paper broker support and DNSE Entrade X integration for live accounts.
- Risk controls: position sizing limits, order notional limits, optional ticker whitelist checks, market-session checks, margin-disabled enforcement, daily-loss halt, and drawdown buy-freeze support.
- Backtesting: replay strategy behavior with the paper broker to validate feeds, accounting, lot sizing, fees, and guardrails before using live tools.
- Local-first state: configuration, SQLite cache, broker records,
journals, broker records, team runs, and session logs live under
~/.azothby default.
Requirements:
- Node.js 20 or newer
- npm, pnpm, or another Node package runner
- an Anthropic-compatible API key for the Claude Agent SDK
One-shot usage with npx:
npx @toreleon/azothOn a fresh machine, the TUI opens a first-time LLM setup screen with the Azoth
header. Choose either a direct Anthropic API key or an Anthropic-compatible
provider. Compatible providers also ask for a custom base_url. The setup
writes provider, key, base URL, and model fields only to ~/.azoth/config.yaml.
Manual setup is still supported:
Edit ~/.azoth/config.yaml and fill the llm: block.
Install globally if you prefer a persistent command:
npm install -g @toreleon/azoth
azothInstall from source for development:
pnpm install
pnpm azothPackaged CLI command:
azothThe TUI requires an interactive terminal. In non-TTY environments, use the
development commands such as pnpm test, pnpm build, or programmatic health
checks.
| Area | Features |
|---|---|
| Terminal UI | Ink chat interface, tool chips, slash commands, local cards, status bar, normal scrollback, optional alternate screen. |
| Agent orchestration | Claude Agent SDK, constrained MCP tool server, resumable sessions, local context replay, abortable turns. |
| Team desk | Technical, fundamentals, news, sentiment, bull, bear, research manager, trader, risk, and portfolio roles. |
| Market data | Quotes, OHLCV, technical indicators, fundamentals, CafeF news, macro indices, foreign flow, and ticker discovery. |
| Portfolio and journal | Broker state, positions, cash, unrealized P&L, decision journal, orders, fills, alerts. |
| Execution | Paper broker, optional DNSE broker, advisory/confirm/auto autonomy, human confirmation gate. |
| Risk | Notional cap, concentration cap, whitelist, market session, no-margin cash check, daily-loss halt, drawdown buy freeze. |
| Backtesting | Weekly team-driven replay, paper fills, fees, rejected guardrail orders, benchmark comparison, running-peak max drawdown. |
| Runtime | ~/.azoth config, SQLite state, project session logs, build-safe schema fallback. |
Ask the agent a market question:
Should we add more bank exposure this week?
Run structured team analysis:
/analyze FPT
/analyze HPG --rounds 3
/team Should we rotate from steel into banks this month?
Check market and portfolio state:
/quote VCB
/positions
/journal decisions 10
Run a backtest for the previous calendar week:
/backtest
You can still provide an explicit range and starting cash:
/backtest 2025-01-03 2025-04-30 1000000000
Backtests default to 30-minute turns. Use --interval to choose a slower
cadence such as 1h or 2h:
/backtest 2025-01-03 2025-04-30 1000000000 --interval 1h
Manage sessions:
/new
/sessions
/resume
/resume <session-id>
Azoth is designed so the top-level chat agent delegates complex investment work to a structured team instead of improvising a long single-agent answer.
The team design is documented in more detail in docs/agent-team.md. It is inspired by the TradingAgents multi-agent trading-firm pattern and adapted for Azoth's Vietnam-market data, local TUI, SQLite runtime, and broker guardrails.
User prompt
├─ simple quote/news/position request -> direct market or portfolio tools
├─ broad allocation / portfolio question -> team_question
└─ deep single-ticker view / buy-sell-hold -> team_analyze
team_analyze
├─ analysts: technical, fundamentals, news, sentiment
├─ debate: bull and bear
├─ research manager: synthesis and plan
├─ trader: entry, sizing, and execution view
├─ risk: veto, sizing adjustment, and concerns
└─ portfolio manager: final rating, allocation, rationale, exit plan
When the model automatically calls team_question or team_analyze, the TUI
treats the team like a subagent run: it shows compact running status, suppresses
noisy nested raw tool payloads, waits for the team to finish, then displays a
short findings summary. Direct slash commands such as /team and /analyze
still stream the full local team flow.
| Command | Purpose |
|---|---|
/team <message> |
Run a multi-agent debate on a market or portfolio question. |
/analyze <ticker> [--rounds N] |
Run structured team analysis for one ticker. |
/backtest [start] [end] [cash] [--interval 30m|1h|2h] |
Run an interval backtest and render results inline. Defaults to previous calendar week at 30-minute cadence. |
/journal [decisions|orders|fills|alerts] [N] |
Show recent journal rows. |
/quote <ticker> |
Request quote, technicals, and recent news for a ticker. |
/positions |
Summarize current portfolio positions and exposures. |
/autonomy <advisory|confirm|auto> |
Persist the autonomy mode and rebuild tool access for new turns. |
/health [--probe] |
Check API key, config, DB, broker state, live-trading arm flag, market session, and optionally data providers. |
/new |
Start a new resumable session. |
/resume [id] |
Resume the latest session or a specific session. |
/sessions |
List recent project sessions. |
/help |
Show command help in the TUI. |
Azoth stores runtime state in ~/.azoth unless AZOTH_HOME is set.
A fresh runtime contains:
~/.azoth/config.yaml- user configuration~/.azoth/azoth.db- SQLite cache, journal, broker, and run database~/.azoth/projects/<encoded-cwd>/*.jsonl- per-project session logs
Useful environment variables:
| Variable | Purpose |
|---|---|
AZOTH_HOME |
Override the runtime directory. |
AZOTH_CONFIG |
Override the config file path. |
AZOTH_DB |
Override the SQLite database path. |
AZOTH_ALT_SCREEN=1 |
Run the TUI in the alternate screen buffer. |
AZOTH_LIVE_TRADING=1 |
Explicitly enable live trading paths. |
DNSE_TEST_LIVE=1 |
Run DNSE read-only live probes in tests. |
Default config:
autonomy: advisory
model: glm-5.1
llm:
provider: anthropic
api_key: ""
base_url: ""
team:
quick_model: glm-5.1
deep_model: glm-5.1
output_language: en
broker: paper
risk:
max_position_pct: 0.15
max_daily_loss_pct: 0.03
max_order_notional_vnd: 50000000
ticker_whitelist: []
allow_margin: falseAutonomy modes:
advisory: no order tools are exposed. Azoth recommends; the user executes.confirm: order tools are available, but each order requires CLI approval.auto: order tools run through configured guardrails before submission.
Broker modes:
paper: local paper broker backed by SQLite.dnse: DNSE Entrade X / LightSpeed integration for live accounts.
Azoth uses public and broker APIs for Vietnam market context:
- OHLCV: DNSE Entrade public chart API for daily and intraday bars.
- Quotes and reference prices: SSI iBoard public endpoints for last, reference, ceiling, floor, exchange, and company metadata.
- Technical indicators: computed locally from DNSE bars, including RSI, MACD, moving averages, EMA, and Bollinger Bands.
- Fundamentals: VNDirect Finfo and CafeF for valuation, profitability, balance-sheet, EPS, BVPS, margin, and historical ratio context.
- News and disclosures: CafeF company news, industry news, and filings.
- Macro indices: VNINDEX, VN30, HNXINDEX, and UPCOMINDEX.
- Foreign flow: per-ticker foreign buy, sell, net flow, and ownership.
- Portfolio data: local paper broker or DNSE account snapshots.
- Open web context: model WebSearch for current context not covered by the built-in market tools; responses should cite URLs and dates.
Market responses are cached in SQLite with short TTLs to keep the CLI fast and reduce repeated network calls.
| Integration | Purpose |
|---|---|
| Claude Agent SDK | Top-level agent orchestration, streaming, MCP tool hosting, and tool restrictions. |
| MCP tools | Azoth exposes market, portfolio, journal, team, and broker tools through a local SDK MCP server. |
| Ink | Rich terminal UI with chat, slash commands, cards, status, and keyboard handling. |
| SQLite / better-sqlite3 | Local cache, journal, broker state, orders, sessions, team runs, and backtest records. |
| DNSE public APIs | Market OHLCV and optional live broker adapter support. |
| SSI iBoard | Public quote and reference price data. |
| VNDirect Finfo | Fundamentals and valuation snapshots. |
| CafeF | News, disclosures, and historical financial ratios. |
| DNSE Entrade X / LightSpeed | Optional live account reads and order submission. |
- v0.1.2 - dynamic stock discovery, last-week default backtests, and configurable interval replay cadence.
- v0.1.1 - pipeline-published package release for the v0.1 public baseline.
- v0.1.0 - consolidated public baseline with chat TUI, multi-agent desk, Vietnam market tools, local journaling, paper broker, guardrails, backtesting, DNSE integration foundations, npm packaging, and automated release support.
Azoth is MIT licensed and uses GitHub Actions for pull request validation, security scanning, and npm releases.
User-facing changes should include a Changesets release note:
pnpm changesetThe release workflow opens a version pull request after changes land on
master. Merging that version pull request publishes @toreleon/azoth to npm
and creates the matching GitHub release.
Live mode places real orders. Keep autonomy: advisory or broker: paper
until the checklist below is complete.
- Open a DNSE account and enable Entrade X / LightSpeed API access.
- Export
DNSE_USERNAME,DNSE_PASSWORD, andDNSE_ACCOUNT_NOin your shell or secret manager before starting Azoth. - Find your account-specific
DNSE_LOAN_PACKAGE_ID. After login, callGET https://api.dnse.com.vn/margin-service/loan-productswith the JWT and choose the correct loan product id for your equity sub-account. - Set
broker: dnsein~/.azoth/config.yaml. - Set
autonomy: confirmfirst, so every order prompts for approval. - Run
pnpm testand thenDNSE_TEST_LIVE=1 pnpm testfor read-only live probes. - Verify
broker_stateandlist_ordersreturn the expected cash, positions, and orders. - Only then set
AZOTH_LIVE_TRADING=1. - During market hours, place one small 100-share test order on a liquid ticker and verify the result with DNSE directly.
The first place_order in a live session may trigger an email OTP prompt.
Run the team-driven agent backtest from inside the TUI:
/backtest
Backtests use the paper broker and simulated time. They are intended to validate data feeds, accounting behavior, lot sizing, fees, the built-in team replay strategy, and risk guardrails before using live broker tools.
Common commands:
pnpm azoth # run the Ink TUI
pnpm test # run Vitest
pnpm typecheck # run TypeScript type checks
pnpm build # compile to dist/Project layout:
src/
cli/azoth.tsx Ink terminal UI entrypoint
tui/ TUI components, hooks, cards, theme, commands
agent/orchestrator.ts Agent SDK prompt, tools, sessions
agent/team/ multi-agent research desk
tools/ market, portfolio, journal, broker tools
data/sources/ DNSE, SSI, CafeF, VNDirect clients
broker/ paper and DNSE broker implementations
risk/ pre-trade guardrails
storage/ SQLite schema and database access
runtime/ ~/.azoth paths, bootstrap, session store
config/ YAML defaults and loader
Azoth is built around a few explicit constraints:
- Recommendations must be grounded in tool output, not memory.
- Prices are stated in correct units. VN stock prices from DNSE and SSI are in thousand VND.
- Vietnam listed equity settlement is treated as formal T+2, with securities and sale proceeds typically available before 13:00 ICT on T+2 for afternoon use; Azoth should not call this a formal T+2.5 cycle or propose same-day round trips.
- Buy, sell, or hold recommendations should include technicals, fundamentals, news, and macro context.
- News citations should include source URL and publish date.
- Decisions should be persisted to the local journal with rationale and an exit plan.
- Order placement is disabled in advisory mode and guarded in auto mode.