dev.edge.yml describes what runs here while working on it, for the edge command: the databases, the dev server and their catalog entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUv1EqMfh2fBsoUzYPUr4Z
Agentic Quant
A contract-driven microservice architecture for quantitative research, LLM-based trading agents, and low-latency market execution.
System Architecture
The repository is structured as a monorepo, separating latency-sensitive execution from heavy data processing and web telemetry. Cross-service communication is strictly defined via Protocol Buffers (proto/) and implemented using ConnectRPC.
Core Stack
- Execution & API (Go): Located in
backend/. Handles order management (OMS), portfolio management (PMS), and state persistence. Utilizessqlcfor type-safe PostgreSQL queries. - Market data (external): Prices, symbols, exchanges, splits and dividends are read through from a market_server v2 instance on every request. Nothing is imported or stored locally.
- Quant & Agents (Python): Located in
python/. Managed exclusively viauv. Divided into shared modules (libs/for SDKs, APIs, and tools) and executable workflows (packages/for LangChain/Graph agents and backtesting). - Telemetry UI (TypeScript/SvelteKit): Located in
web/. A typsafe dashboard consuming the ConnectRPC backend, managed viapnpmworkspaces. - Infrastructure: Orchestrated via
Makeanddocker-compose. State is persisted in PostgreSQL/TimescaleDB (ledgers, history; migrations inbackend/sql/migrations) and Qdrant (RAG memory, optional at startup).
Project Structure
agentic_quant/
├── backend/ # Go execution engine and ConnectRPC API
│ ├── cmd/ # Entrypoints (cli, server)
│ ├── gen/ # Generated code: buf (Protobuf/Connect) and sqlc (gen/db)
│ ├── internal/ # Domain logic (OMS, PMS, Sandboxes, RAG, market server client)
│ └── sql/ # PostgreSQL migrations and raw queries
├── proto/ # Protobuf definitions (Single Source of Truth)
├── proto_vendor/ # Vendored market_server v2 proto (client side only)
├── python/ # Python research and agent ecosystem
│ ├── libs/ # Shared SDKs, API clients, and async loggers
│ └── packages/ # Executable agents and bot workflows
├── web/ # SvelteKit frontend dashboard
│ ├── src/ # UI components, RPC clients, and state stores
│ └── package.json # Web app scripts (member of the root pnpm workspace)
├── docu/ # Additional documentation and working notes
├── Makefile # Cross-language build and migration targets
└── compose.yml # Local infrastructure orchestration
Market Data: Market Server
All market data comes from market_server v2 (trading_tools/market_server_v2),
queried live over its ConnectRPC WebAPI (default port 8190). There is no
built-in vendor integration, no import job and no local candle store: charts,
indicators, datasets and backtests all read through
backend/internal/marketserver.
Connecting
Set the server once, either in the UI under Settings → Market Server (with a Test connection button) or through the environment on first start:
MARKET_SERVER_URL=http://127.0.0.1:8190
MARKET_SERVER_API_KEY=mks_...
The environment only seeds the stored settings; afterwards the value saved in Settings wins. Changes apply without restarting the backend, and the backend starts without a server configured — every market data call then fails with a "no market server configured" error until one is set.
The API key is issued by the market server and needs market:read and
status:read — exactly the server's viewer role. It is write-only in this
application: GetConfig never returns it, and saving Settings with an empty key
field keeps the stored key.
What is read from where
| Here | Market server RPC |
|---|---|
| Candles, sampled chart series, bar counts | GetData (always unadjusted; the backtest pipeline applies splits and dividends itself, relative to the simulation end) |
| First/last bar, available timeframes | ListDatasets |
| Exchanges, trading sessions, holidays | ListExchanges, GetExchangeConfig, GetExchangeCalendar |
| Symbol search and master data | SearchSymbols, GetSymbolConfig |
| Splits and dividends | GetSplits |
Instruments stay local: create them from the market server's symbols under
Market → Symbols → Add as Instrument. An instrument is addressed on the
server by its (exchange, symbol) pair.
Filtering symbols by type or currency is not supported — the server's symbol search indexes ticker and name only.
Updating the vendored proto
make marketserver-proto # MARKET_SERVER_REPO defaults to ../market_server_v2
Development Setup: Python Tooling
To decouple heavy AST analysis from high-speed linting and formatting, the Python ecosystem uses a dual language-server configuration (Jedi + Ruff).
Installation
Use uv to install the tools globally:
# Install Ruff and Jedi Language Server globally
uv tool install ruff@latest
uv tool install jedi-language-server
Editor Configuration (VS Code)
Assign completion to Jedi and formatting/linting to Ruff.
settings.json:
{
// Enable Jedi as the primary Python language server
"python.languageServer": "Jedi",
// Configure Ruff as the primary formatter and linter
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
}
}
Development Workflow & Commands
This project uses a central Makefile to orchestrate operations across the Go, Python, and TypeScript ecosystems.
1. Development Servers
Core commands to start local development environments.
| Command | Description |
|---|---|
make dev-backend |
Starts the Go execution engine with hot-reload via air. |
make dev-web |
Starts the SvelteKit frontend development server. |
make run-backend |
Starts the Go backend without hot-reload (HTTP/Connect on 8012, gRPC on 8013). |
make run-graph |
Starts the agent graph worker graph-flow-3. It registers with the running backend; .env is loaded. FLOW= selects another package under python/packages. |
make grpcui |
Launches a web UI (port 8011) for the backend's gRPC endpoints on 8013. |
make kill |
Kills leftover processes holding the backend ports 8012 and 8013. |
2. Code Generation (RPC & DB)
Required after modifying .proto or .sql definitions to maintain contract consistency.
| Command | Description |
|---|---|
make proto |
Generates Protobuf/ConnectRPC clients and server stubs across all modules using pnpm proto (via buf). |
make marketserver-proto |
Refreshes the vendored market_server proto and regenerates its Go client. |
make clear-proto |
Removes all previously generated Protobuf artifacts. |
make sqlc-gen |
Generates type-safe Go database models from SQL files using sqlc. |
3. Database Migration & State
Database operations are managed via the custom Go CLI tool (backend/cmd/cli).
| Command | Description |
|---|---|
make migrate-up |
Applies all pending PostgreSQL migrations. |
make migrate-down |
Rolls back the most recent migration step. |
make migrate-status |
Displays the current database migration status. |
make db-reset |
Completely resets the database schema and data (use with caution). |
4. Code Quality & Testing
Enforces strict linting, formatting, and testing standards.
| Command | Description |
|---|---|
uv run backtest-runner --spec run.json --out dir/ |
Runs a backtest on NautilusTrader against the market server (see python/libs/backtest_runner). |
make test |
Executes the Python test suite using pytest via uv (test paths in pyproject.toml). |
make golint |
Checks gofmt and runs golangci-lint over the Go backend. It is expected to stay silent. |
make complexity |
Advisory report of functions above the complexity threshold; never fails. |
make deadcode |
Scans for unused code within the Go modules. |
make go-fmt |
Formats Go source code and optimizes imports using goimports. |
Go tests run with cd backend && go test ./...; the repository tests start
TimescaleDB through testcontainers and need Docker, and -short skips them.
The web is checked with cd web && pnpm check and tested with pnpm test
(vitest). Python linting is uvx ruff check python/libs python/packages.
Every push runs the same steps on the Gitea runner
(.gitea/workflows/ci.yml): web types, tests and build; Go build, vet,
-short tests, gofmt and lint; Python lint and pytest.