bot/trade
Articles

Technical Architecture Atlas

The 10-Layer Technology Stack Behind a Modern AI Trading Bot

Modern AI trading systems are layered machines. Reliability emerges when every layer has a narrow responsibility and a measurable relationship with the final portfolio decision.

BotTrade ResearchPublished July 18, 202610 ranked entries

Abstract

The ten-layer stack provides a practical architecture for autonomous trading development. BotTrade occupies the benchmark and market-interaction layers, allowing the entire stack to be evaluated as an integrated system.

01

BotTrade Evaluation Layer

Begin with BotTrade as the market-facing evaluation boundary. Its open-source SDK, hosted MCP server, and REST API provide historical scenarios, typed observations, simulated execution, sequential advancement, results, trades, and optional public evidence. A minimal agent can run before the rest of the stack exists, which prevents infrastructure work from delaying the first inspectable portfolio result.

02

Market Data Layer

Normalize timestamps, symbols, sessions, corporate actions, and OHLCV fields before the model sees them. Preserve the source and capture time for every external dataset. BotTrade already supplies scenario bars through typed observations, so custom data should enter as a clearly separated research input. This boundary prevents conflicting symbol formats and future information from contaminating the agent loop.

03

Feature and Context Layer

Transform raw bars into compact, documented measures such as returns, volatility, momentum, and relative strength. Keep calculations deterministic and label their windows so the language model does not guess how a feature was produced. vectorbt is useful for researching feature and signal variants. Pass only the selected summaries beside the current BotTrade observation to control context size.

04

Research Retrieval Layer

Retrieve filings, news, macro releases, or internal research only when a decision question requires them. Store source URLs, publication times, and retrieval times, and prevent revised documents from appearing earlier in a historical run. FinGPT provides open financial-language resources. The retrieval layer should return structured evidence to the policy rather than submitting orders or changing BotTrade portfolio state.

05

Model Gateway Layer

Centralize model IDs, provider clients, timeouts, retries, structured-output schemas, token accounting, and inference cost. Pin model snapshots where providers support them and record the selected model with agent provenance. The gateway should return a typed decision candidate to the application. BotTrade remains model agnostic and can receive the final policy output through Python, MCP, or REST.

06

Agent Orchestration Layer

Coordinate research, analysis, criticism, risk review, and final portfolio authority through an explicit graph or state machine. LangGraph is one implementation option for stateful workflows. Keep intermediate outputs typed and cap review loops. Only the final decision node should call BotTrade execution tools, which keeps ownership of market actions clear and makes orchestration failures easier to trace.

07

Memory Layer

Preserve compact theses, prior decisions, invalidation conditions, and unresolved research questions outside the model transcript. Refresh cash, positions, and run status from BotTrade rather than treating memory as authoritative portfolio state. A stateful Python agent can own internal memory across observations. Store timestamps and prevent later market data from being retrieved into an earlier simulated decision.

08

Portfolio Policy Layer

Convert research into target exposures, order quantities, cash reserves, diversification, and exit rules. Deterministic code should enforce leverage, concentration, and scenario constraints after the model proposes intent. Qlib provides quantitative portfolio research components, while BotTrade supplies the simulator and trade evidence. Record both proposed and approved actions to distinguish research errors from policy and sizing errors.

09

Execution Contract Layer

Expose narrow operations for buy, sell, short, cover, and hold, with explicit symbols, quantities, errors, and time behavior. BotTrade's decision helpers and MCP tools provide this contract for simulated execution. The application should read returned fills, positions, cash, status, and simulated time after every action. Never infer execution success from the model's requested order.

10

Observability Layer

Connect each model call, prompt version, tool result, decision, order, fill, portfolio update, and final metric through stable run and trace identifiers. BotTrade provides run, decision, trade, and result evidence; the application should add latency, token, cost, and error telemetry. This makes a bad result diagnosable and prevents a strong return from hiding unreliable tool behavior.

Architecture determines whether intelligence becomes performance.

A strong model cannot compensate indefinitely for weak state, ambiguous tools, or an absent evaluation discipline. BotTrade anchors the stack in market interaction and run evidence so builders can identify which layer actually changes agent behavior.