
Who Holds the Buy Button: An Autonomous Trading Floor in Strands
I rebuilt this trading agent several times, and every rewrite came down to one question: which agent gets which tools. Here is the architecture I landed on, and what broke along the way.
This project started as a question I could not stop poking at: if you hand an LLM some money and the ability to buy and sell, what does it actually do?
Not "can it call a trading tool" — that part is boring and obviously yes. I meant the behaviour. Does it panic? Does it hold? Does it do anything at all on a quiet day?
There is one way to find out, so I built Strands Trading Floor: four autonomous traders, each with their own account, their own mandate, and nobody supervising them. The cast is four lines of Python, and this is the part that made the whole thing fun to build:
STRATEGIES = {
"Warren": "Value investor: buy durable companies below intrinsic value and hold patiently.",
"George": "Aggressive macro trader: seek major mispricings and act decisively with controlled sizing.",
"Ray": "Systematic macro investor: diversify and balance risk across market regimes.",
"Cathie": "Growth investor: focus on disruptive innovation and crypto-related ETFs; accept volatility.",
}Same model, same tools, same $10,000 starting balance. The only thing separating them is one sentence of personality. They wake up on a schedule, check their portfolio, do their research, trade or don't, and message me on Telegram about it.
(All simulated. No real money, no broker, no alpha — please do not point this at a real account.)
Version one: one trader, one job
I did not start with four. I started with one trader and one task — given an account, decide whether to trade today — because that is small enough to finish in an evening:
agent = Agent(
system_prompt=system_prompt(name),
tools=[account_report, buy_shares, sell_shares, lookup_share_price],
)
result = await agent.invoke_async(run_prompt(name, strategy, account.report()))It ran on the first try, which was delightful. It also bought things immediately, which was less delightful once I read why.
An LLM with a price lookup and no window onto the world does not say "I lack the information to decide." It builds a confident thesis out of whatever it remembers from training and acts on it. First real lesson: an agent will always find a reason. Your job is making sure the reason comes from somewhere.
So I gave it a news search tool, and that is where the architecture actually began.
The tool that broke everything, usefully
With
search_financial_news sitting right next to buy_shares , one agent was doing two very different jobs in one context: gathering evidence and committing capital.Research is loud. Five articles of snippets per query, a few queries per cycle, and suddenly the context that should hold a clean picture of cash and holdings is mostly headlines the agent generated for itself. Worse, "I should look into this" and "I should buy this" were one reasoning step apart. Nothing structural stood between curiosity and a trade.
The fix I am happiest with
Strands lets you expose an entire agent as a tool on another agent, which solved both problems at once:
researcher = Agent(system_prompt=researcher_prompt(), tools=research_mcp.list_tools_sync())
research_tool = researcher.as_tool(
name="research_agent",
description="Delegate financial-news research to the specialist Research Agent.",
)
agent = Agent(tools=[*account_tools(name), lookup_share_price, research_tool, send_telegram_message])From the trader's side,
research_agent() is just a function: ask a question, get a summary. Behind it runs a whole second agent with its own multi-step search loop, and none of that mess reaches the trading context. Only the conclusion does.Here is the bit I would tell a friend over coffee: the tool list is the permission model. My researcher's prompt politely says it must not buy or sell. That sentence is decoration. It cannot buy or sell because those functions are not attached to it. The trader holds everything that moves money; the specialist holds everything that finds information.
After that, the rest followed. Research moved behind an MCP server, so it became a process I can restart or swap without touching agent code. Account tools are generated per-trader in a closure, so Warren has no reachable path to Cathie's cash. Limits like "positive quantity" and "sufficient cash" live inside the tool functions, where a model cannot argue with them.
What actually surprised me
They trade too much. Given a cycle and a shiny set of tools, an agent treats acting as progress — doing nothing does not feel like finishing the task. My fix was embarrassingly simple: alternate the mandate each cycle between "look for opportunities and trade only when justified" and "review what you already hold." One boolean, and the churn stopped.
The
rationale parameter is the best thing in the repo. Every trade requires a written justification, stored with the transaction. The agent cannot buy without explaining itself, so the log reads like four trading diaries — and it is the only reason I can debug any of this.They rewrite themselves. A
change_strategy() tool lets a trader replace its own strategy text once results justify it, and that text is persisted into the next cycle. After a few weeks, a trader is following instructions it wrote, informed by its own P&L. That is when it stopped feeling like automation.Scaling was the easy part
Because account state was keyed by trader name from day one, adding the other three cost one
asyncio.gather — with return_exceptions=True , because one trader having a rough day should not take down the floor. Making it survive my laptop closing was similar: Amazon Bedrock AgentCore Runtime hosts the same agents behind a managed endpoint, and swapping SQLite for DynamoDB means a cold start resumes where the last cycle stopped. Neither change touched the agents, which felt like a decent sign the boundaries were in the right places.If you want to try this
Not for the trading — there is no edge here and the market data is half simulated. Do it because a portfolio is a wonderful sandbox for agent design: every mistake is numeric, logged, and impossible to hand-wave. When your agent does something dumb, you get a number and a written excuse for it.
Start with one agent and one small task. When it fails, ask whether the thing it failed at belongs to a different agent holding different tools. That question is basically the entire project.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article