<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02" -->

---
title: Simulate a market with 200 agents | daily.dev
description: A tutorial walks through building a market simulation on AgentField where 200 trader reasoners read a shared order book from global memory, decide...
canonical: https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Simulate a market with 200 agents | daily.dev
og:description: A tutorial walks through building a market simulation on AgentField where 200 trader reasoners read a shared order book from global memory, decide...
og:url: https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02
og:image: https://api.daily.dev/og/posts/kVQ1djm02.png
og:image:alt: Simulate a market with 200 agents
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate a market with 200 agents

**[AgentField.ai](https://daily.dev/sources/agentfield)** · 9 min read · 0 upvotes · 0 comments

## Summary

A tutorial walks through building a market simulation on AgentField where 200 trader reasoners read a shared order book from global memory, decide buy/sell/hold with a cheap LLM, and post orders back each round. An orchestrator fans out all 200 traders concurrently via asyncio.gather, while a deterministic Python function clears supply against demand and updates the price between rounds. The build covers seeding shared state, writing the async trader reasoner, the clearing math, running via async API endpoints, and limits of local SQLite mode (serialized writes, need for async def reasoners, and a read-modify-write race on shared order lists).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://agentfield.ai/blog/simulate-a-market-with-200-agents>

## Questions this post answers

### How much does it cost to run 2,000 agent calls with a cheap model like gpt-4o-mini?

Running 2,000 agent calls (200 trader agents across 10 rounds) on a cheap model costs roughly 30 to 60 cents for the entire run. Each round fans out all 200 traders concurrently via asyncio.gather, and each trader makes one model call to decide buy, sell, or hold, resulting in 2,000 total calls from a single request.

_Developers estimating multi-agent run costs can track pricing shifts for cheap models on daily.dev._

### Why does a reasoner function need to be async def instead of a regular def in AgentField?

A plain def reasoner serializes inline and runs the whole round sequentially, collapsing the fan-out into a loop and eliminating the parallelism that makes running 200 agents concurrently possible. Every reasoner in a fan-out build must be declared async def so the orchestrator can dispatch all agents at once via asyncio.gather instead of one at a time.

_Developers debugging stalled concurrency in async orchestration can compare patterns like this on daily.dev._

### Why does SQLite become a bottleneck when many concurrent agents write to shared memory?

A single SQLite writer serializes all writes, so when 200 concurrent traders call global_scope.set on the same shared key in one round, they all hit one writer one at a time. This creates a latency ceiling rather than a failure in local mode; the run still completes but paces itself, and switching the control plane to PostgreSQL removes that ceiling.

_Engineers weighing SQLite versus PostgreSQL for concurrent workloads can compare trade-offs on daily.dev._

## Similar posts on daily.dev

- [​Build a Stock Market Research Agentic Workflow​](https://daily.dev/posts/build-a-stock-market-research-agentic-workflow--xv4thp4qj) · Daily Dose of Data Science \| Avi Chawla \| Substack · 6 upvotes · 0 comments
- [How to Build a Multi-Agent Trading Research System with LangChain Deep Agents \[Full Handbook\]](https://daily.dev/posts/how-to-build-a-multi-agent-trading-research-system-with-langchain-deep-agents-full-handbook--ticxj0m12) · freeCodeCamp · 6 upvotes · 0 comments
- [Thousand Token Wood: shipping a multi-agent economy on a 3B model](https://daily.dev/posts/thousand-token-wood-shipping-a-multi-agent-economy-on-a-3b-model-joglg8hjh) · Hugging Face · 3 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#ai-agents](https://daily.dev/tags/ai-agents), [#orchestration](https://daily.dev/tags/orchestration)

[View this post on daily.dev](https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Simulate a market with 200 agents","url":"https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02"},"datePublished":"2026-10-02T17:45:20.754Z","dateModified":"2026-10-02T18:08:20.539Z","description":"A tutorial walks through building a market simulation on AgentField where 200 trader reasoners read a shared order book from global memory, decide...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fa5c4d834aaa89f447836e34c1b3b50b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fa5c4d834aaa89f447836e34c1b3b50b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"AgentField.ai","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"AgentField.ai","logo":"https://media.daily.dev/image/upload/s--VLFHaedl--/f_auto/v1791063152/squads/33beeb91-1f14-4d9b-9cf8-db7d9f69160a?_a=BAMAMicg0","url":"https://daily.dev/squads/agentfield"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,ai-agents,orchestration","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AgentField.ai","item":"https://daily.dev/squads/agentfield"},{"@type":"ListItem","position":3,"name":"Simulate a market with 200 agents"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/simulate-a-market-with-200-agents-kvq1djm02#faq","mainEntity":[{"@type":"Question","name":"How much does it cost to run 2,000 agent calls with a cheap model like gpt-4o-mini?","acceptedAnswer":{"@type":"Answer","text":"Running 2,000 agent calls (200 trader agents across 10 rounds) on a cheap model costs roughly 30 to 60 cents for the entire run. Each round fans out all 200 traders concurrently via asyncio.gather, and each trader makes one model call to decide buy, sell, or hold, resulting in 2,000 total calls from a single request. Developers estimating multi-agent run costs can track pricing shifts for cheap models on daily.dev."}},{"@type":"Question","name":"Why does a reasoner function need to be async def instead of a regular def in AgentField?","acceptedAnswer":{"@type":"Answer","text":"A plain def reasoner serializes inline and runs the whole round sequentially, collapsing the fan-out into a loop and eliminating the parallelism that makes running 200 agents concurrently possible. Every reasoner in a fan-out build must be declared async def so the orchestrator can dispatch all agents at once via asyncio.gather instead of one at a time. Developers debugging stalled concurrency in async orchestration can compare patterns like this on daily.dev."}},{"@type":"Question","name":"Why does SQLite become a bottleneck when many concurrent agents write to shared memory?","acceptedAnswer":{"@type":"Answer","text":"A single SQLite writer serializes all writes, so when 200 concurrent traders call global_scope.set on the same shared key in one round, they all hit one writer one at a time. This creates a latency ceiling rather than a failure in local mode; the run still completes but paces itself, and switching the control plane to PostgreSQL removes that ceiling. Engineers weighing SQLite versus PostgreSQL for concurrent workloads can compare trade-offs on daily.dev."}}]}
```

