# core concepts

#### High-level architecture

The architecture of Agent Trader is organized into several key layers, each responsible for distinct functions:

#### Inputs

Utilizes data critical for decision-making:

* **Market data from Bluefin**: Includes prices, orderbooks, volume, funding rates, open interest (OI), and volatility indicators.
* **Portfolio state**: Details such as lab balances, open positions, margin requirements, and unrealized profit & loss (P\&L).
* **Strategy config**: Defines parameters like risk profiles, leverage limits, asset availability, and trade cooldown periods.

#### Agent brain (decision loop)

Handles the complete decision-making cycle:

1. **Observe**: Ingests current market and portfolio data.
2. **Analyze**: Evaluates features such as Exponential Moving Averages (EMAs), volatility bands, market trends, and bid-ask spreads.
3. **Plan**: The policy model decides trading factors like direction, position size, leverage, stop-loss, and target levels, including expiry and confidence measures.
4. **Act**: Issues structured trade actions based on analysis.
5. **Evaluate**: Monitors trade outcomes to inform future decisions.

#### Execution layer

Ensures effective trade implementation:

* Directly connects with Bluefin APIs and contracts for order execution.
* Manages order retries, partial fills, and maintains stability during infrastructural disruptions.

#### Risk & policy layer

* **Guardrails**: LLM model uses daily maximum loss, asset-specific maximum exposure, leverage caps, and slippage-activated shutdowns.

#### UX layer

Enhances user interaction and visibility:

* **Labs dashboard**: Displays the seasonal growth curve, trade logs with explanations, and current return estimates (R).
* **User view**: Leaderboard shows Time-Weighted Average Balance (TWAB) and Leaderboard shows Baseline Points

#### Beep × Bluefin integration

Represents the collaborative operation combining Beep Labs and Bluefin infrastructure for robust trading activities:

* **Beep**: Manages the agent's decision-making brain, capital allocation, and points management.
* **Bluefin**: Facilitates on-chain perpetual markets order execution
