Overview
This example demonstrates a trading agent that monitors cryptocurrency markets, forms opinions based on data, and makes paper trading decisions. It shows how to build plugins that work together.View Source
See the complete example agent implementation on GitHub
What It Does
- Fetches real-time market data from CoinGecko
- Makes paper trading decisions based on agent mood and market conditions
- Tracks portfolio performance over time
- Only trades when agent is expressive and healthy
Architecture
- Markets Plugin — Fetches and caches price data
- Paper Trading Plugin — Manages portfolio, executes trades
Markets Plugin
Fetches cryptocurrency prices and detects significant moves. Key features:- Configurable symbol list
- Automatic refresh on interval
- Caches data between ticks
- Actions:
getMarkets(),getPrice(symbol)
src/services/market.ts in the example agent.
Paper Trading Plugin
Manages a simulated portfolio with position limits. Key features:- Initial cash balance
- Max position size (% of portfolio)
- Only trades when mood is expressive and health >50
- Actions:
buy(symbol, price),sell(symbol, price),getPortfolio()
src/plugins directory for plugin patterns.
Plugin Dependencies
The trading plugin depends on the markets plugin:Agent Setup
Risk Controls
This example includes several safeguards:| Control | Description |
|---|---|
| Position limits | Max 20% of portfolio per trade |
| Mood gating | Only trades when expressive |
| Health threshold | Requires health >50 |
| Paper trading | No real money at risk |