Atomic Agents Integration

Purple Flea for Atomic Agents

Atomic Agents is built on the principle that agents should be modular, composable, and fully controllable via Pydantic schemas. Purple Flea's crypto tools fit perfectly into this philosophy โ€” small, focused tools that compose into powerful financial agent systems.

Get Free API Key โ†’ View Docs

Why Atomic Agents + Purple Flea?

Atomic Agents' schema-first philosophy aligns perfectly with financial precision. Every tool has typed inputs and outputs โ€” critical when your agent is managing real money.

๐Ÿงฉ
Schema-First Design
Atomic Agents uses Pydantic for all tool I/O. Purple Flea tools wrapped in Atomic's BaseIOSchema give you fully typed, validated inputs before any crypto transaction is executed.
๐Ÿ”Œ
Composable Tool Chains
Chain Purple Flea tools: get_price โ†’ analyze โ†’ open_trade. Each tool's output schema feeds the next tool's input, creating type-safe pipelines that can't hallucinate parameters.
๐Ÿงช
Testable in Isolation
Atomic's design makes individual tools unit-testable without running the full agent. Mock Purple Flea API responses to test your trading logic without real transactions.

Atomic Agents Code Example

Define Crypto Tools with Atomic Schema

from atomic_agents.tools.base_tool import BaseTool, BaseToolConfig from atomic_agents.lib.base.base_io_schema import BaseIOSchema import purpleflea as pf from pydantic import Field from typing import Literal pf_client = pf.Client(api_key="YOUR_KEY") # Input/Output schemas class GetPriceInput(BaseIOSchema): symbol: str = Field(description="Crypto symbol e.g. BTC, ETH") class GetPriceOutput(BaseIOSchema): symbol: str price: float change_24h: float funding_rate: float signal: Literal["bullish", "bearish", "neutral"] class OpenTradeInput(BaseIOSchema): symbol: str = Field(description="Market to trade") side: Literal["long", "short"] size_usd: float = Field(gt=0, le=500) leverage: int = Field(1, ge=1, le=10) class OpenTradeOutput(BaseIOSchema): position_id: str symbol: str side: str fill_price: float liquidation_price: float estimated_pnl: float # Tool implementations class GetPriceTool(BaseTool): input_schema = GetPriceInput output_schema = GetPriceOutput def run(self, params: GetPriceInput) -> GetPriceOutput: data = pf_client.trading.get_price(params.symbol) signal = "bullish" if data['change_24h'] > 2 else \ "bearish" if data['change_24h'] < -2 else "neutral" return GetPriceOutput( symbol=params.symbol, price=data['price'], change_24h=data['change_24h'], funding_rate=data['funding_rate'], signal=signal ) class OpenTradeTool(BaseTool): input_schema = OpenTradeInput output_schema = OpenTradeOutput def run(self, params: OpenTradeInput) -> OpenTradeOutput: price = pf_client.trading.get_price(params.symbol)['price'] trade = pf_client.trading.open_trade( symbol=params.symbol, side=params.side, size=params.size_usd / price, leverage=params.leverage ) return OpenTradeOutput( position_id=trade['position_id'], symbol=params.symbol, side=params.side, fill_price=trade['fill_price'], liquidation_price=trade['liquidation_price'], estimated_pnl=0 )

Build an Atomic Trading Agent

from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator from instructor import from_openai from openai import OpenAI # Create Atomic agent with Purple Flea tools price_tool = GetPriceTool(BaseToolConfig()) trade_tool = OpenTradeTool(BaseToolConfig()) llm_client = from_openai(OpenAI()) prompt_generator = SystemPromptGenerator( background=[ "You are a disciplined crypto trading agent.", "You check prices before making trading decisions.", "You never risk more than 5% of portfolio per trade." ], steps=[ "Check the price and signal for the requested market.", "If signal is 'bullish', open a long. If 'bearish', open a short.", "If 'neutral', do not trade and explain why." ], output_instructions=[ "Always report: symbol, action taken, and reasoning." ] ) agent = BaseAgent( config=BaseAgentConfig( client=llm_client, model="gpt-4o", system_prompt_generator=prompt_generator, tools=[price_tool, trade_tool] ) ) # Run the agent response = agent.run("Evaluate BTC and make a trading decision.") print(response) # The tools enforce schemas โ€” hallucinated params are impossible # leverage > 10 = validation error, not a bad trade

Modular. Composable. Financial.

Atomic Agents' schema-first design + Purple Flea's crypto APIs = the safest way to build financial AI agents. Get your free key today.