Skip to main content

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

Two plugins work together:
  1. Markets Plugin — Fetches and caches price data
  2. 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)
Reference: See 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()
Reference: See the src/plugins directory for plugin patterns.

Plugin Dependencies

The trading plugin depends on the markets plugin:
This ensures markets data is available when making trading decisions.

Agent Setup

Risk Controls

This example includes several safeguards:

Running

This is for educational purposes only. Never trade real money based on AI agent decisions without proper risk management and human oversight.

Next Steps

Social Agent

Build an agent that posts content.

Custom Plugins

Learn plugin development patterns.