Improved sim with trader personalities#108
Conversation
parent-order execution
TakerContext::new
and ignore taker-bot/agents.json
There was a problem hiding this comment.
Pull request overview
Reworks the local maker/taker simulation services to generate more realistic order flow, adds per-agent identity for takers, and exposes an agent registry so the frontend can label fills by trader personality.
Changes:
- Taker bot: introduces market snapshots + execution profiles, runs multiple independently-keyed agents, and adds per-agent execution metrics.
- Maker bot: adds style presets, local-book-driven quoting/spread logic, hit detection, and quote TTL refresh behavior.
- Localnet + frontend: initialization helper now generates per-agent keypairs +
agents.json; frontend adds/api/agents+ client hook and UI labeling in the transaction log.
Reviewed changes
Copilot reviewed 18 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/taker-bot/src/taker_context.rs | Adds per-agent context with shared RPC/faucet clients and market snapshot fetching. |
| services/taker-bot/src/taker.rs | Implements market-aware, stateful parent/child execution and execution profiles; updates tests/helpers. |
| services/taker-bot/src/main.rs | Runs one loop per configured agent, adds per-agent metrics and snapshot caching per tick. |
| services/taker-bot/src/config.rs | Moves from single strategy config to multi-agent config with archetype defaults + keypair paths. |
| services/taker-bot/src/archetype.rs | Adds taker archetype presets mapping to activity + execution profiles. |
| services/taker-bot/compose.yaml | Mounts keypairs/ directory for multi-agent keypairs in container. |
| services/taker-bot/Cargo.toml | Adds transaction-parser dependency for event parsing/snapshots. |
| services/shared/examples/initialization_helper.rs | Funds each agent, creates missing agent keypairs, and writes services/taker-bot/agents.json. |
| services/run-services-on-localnet.sh | New helper script to start validator, deploy, init, and run services via Docker. |
| services/maker-bot/src/tasks/throttled_order_update.rs | Adds quote TTL-driven refresh even without websocket-triggered updates. |
| services/maker-bot/src/maker_context.rs | Major quoting logic update: local-book signals, hit detection, jitter, throttled replenishment, TTL tracking. |
| services/maker-bot/src/main.rs | Switches price anchor granularity/window for faster fair-value updates. |
| services/maker-bot/src/config.rs | Adds maker style presets and new configurable quoting/spread/TTL/refill knobs. |
| services/maker-bot/Cargo.toml | Adds rand dependency for jitter/refill delay sampling. |
| services/.gitignore | Ignores runtime-generated keypairs directory and agent registry (but pattern needs adjustment). |
| frontend/src/app/api/agents/route.ts | New API route to read services/taker-bot/agents.json and return [] if missing. |
| frontend/src/lib/queries/fetch-agent-registry.ts | New client fetch helper for the agent registry. |
| frontend/src/lib/hooks/use-agent-registry.ts | New React Query hook exposing a pubkey→agent map. |
| frontend/src/components/TransactionLog.tsx | Labels fills with trader personality (agent or fallback signer pubkey) and colors by archetype. |
| Cargo.lock | Locks new Rust deps (transaction-parser, rand). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 20 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 20 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@finnfujimura the detailed PR summary is helpful for making sense of the architecture, but once this merges it'll be hard to follow things along from the repo itself. How about updating the relevant README(s) to describe the new layout? Might be useful to talk about the new neat activity profiles like aggressive/passive etc. Glad to do a more detailed review once you've addressed comments from Copilot and @val-levy |
doesn't silently disable
pressure/volatility denominator constants
per-agent keypairs
taker-bot/agents.json as helper-generated
Summary
Reworks the local maker and taker simulation bots to produce more realistic
order flow, and adds per-agent identity so the frontend can label fills by
trader personality.
Taker bot
Reworks taker execution from IID order generation into stateful parent-order
execution with archetype-driven style differences, book-aware sizing, and
per-agent metrics.
services/taker-bot/src/taker.rs(+661): core rework. NewMarketSnapshot/BookSideSnapshot/BookLeveltypes; statefulparent-order execution with slice counts, urgency, persistence across ticks,
imbalance-sensitive side selection; market-aware child sizing based on visible
opposing depth with configurable sweep limits; spread-sensitive
waiting/cooldown so takers don't cross every book state immediately; only
advance parent orders after a successful submit.
services/taker-bot/src/archetype.rs(new, +84):ExecutionProfilepresets so retail / whale / sniper / noise differ by execution style, not
just rate and size.
services/taker-bot/src/config.rs(+73): plumbs execution-profile knobsthrough agent config; archetype defaults wired to
ExecutionProfilepresets.services/taker-bot/src/taker_context.rs(+93): RPC market-accountsnapshot fetching cached per tick; restored
fetch_market_snapshot; switchedTakerContext::newtoArc-based shared state.services/taker-bot/src/main.rs(+185): per-agent execution metrics inthe service loop — submitted children, swept levels, filled base/quote,
skipped wide-spread ticks, empty-book skips, faucet refills.
services/taker-bot/config.toml.example(+60): documents the newexecution-profile knobs.
services/taker-bot/Cargo.toml(+1): addstransaction-parser.Maker bot
Adds maker style support, dynamic spread driven by local-book signals, hit
detection, and quote-TTL refresh.
services/maker-bot/src/maker_context.rs(+527): bulk of the rework.Market-wide book storage so quoting reacts to local top-of-book, not just the
maker's own orders; local microprice, book imbalance, recent volatility,
dynamic half-spread; hit detection by comparing maker-owned bid/ask depth
before and after each market update; refill delays and side-specific
replenishment throttling after hits; ladder generation now allows fewer than
10 quotes/side, skips the touch on recently hit sides, applies per-level
size/price jitter; batch replace switched to
UnvalidatedOrders::new_from_sliceso dynamic quote counts are valid.services/maker-bot/src/config.rs(+167): style presets (tight/balanced/defensive) and configurable knobs — quote TTL, refill delaywindow, partial replenishment ratio, ladder size/price jitter, local-book
fair-value weighting, hit-driven spread widening, max quote levels, spread
multiplier.
services/maker-bot/src/tasks/throttled_order_update.rs(+42):quote-TTL refresh logic so resting liquidity ages and refreshes even without a
websocket-triggered state change.
services/maker-bot/src/main.rs(+38): switches the external priceanchor from
M15/ single candle toS5/ recent candle window for a fasterfair-value input.
services/maker-bot/config.toml.example(+45): documents the newstyle/knobs.
services/maker-bot/Cargo.toml(+1): addsrand.Initialization, deployment, registry
services/shared/examples/initialization_helper.rs(~220 lineschanged): funds each taker agent individually during init; emits
services/taker-bot/agents.json(a generated{name, kind, pubkey}registry)for the frontend to consume.
services/taker-bot/compose.yaml(+1): mounts akeypairs/directoryso multiple agent keypairs run inside the container.
services/.gitignore: ignoreskeypairs/andtaker-bot/agents.json(both runtime-generated).
Frontend
frontend/src/app/api/agents/route.ts(new, +35): readsservices/taker-bot/agents.json, returns[]when the file is missing(devnet/mainnet path).
frontend/src/lib/queries/fetch-agent-registry.ts(new, +13) andfrontend/src/lib/hooks/use-agent-registry.ts(new, +29): client-sidefetch + hook exposing a
pubkey → agentmap.frontend/src/components/TransactionLog.tsx(+68): each fill is labeledwith its trader personality (
retail-1,whale-1,sniper-1,noise-1,maker), color-coded by archetype; falls back to truncated signer pubkey whenunknown.