> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/trader-documentation/building-a-trading-bot.md).

# Building a Trading Bot

This is an integration guide for hooking a trading bot into a Symmio deployment.

There are two parts.

[**Part 1: one-time on-chain setup**](/trader-documentation/building-a-trading-bot/part-1-one-time-on-chain-setup.md) is everything the wallet has to do *once* before any trading happens: create the sub-account, fund it, hand a session key the right authorities, and bind the sub-account to a PartyB. After Part 1 you should never see a wallet popup again on the trade path.

[**Part 2: trading**](/trader-documentation/building-a-trading-bot/part-2-trading.md) is the actual trading: opening a position, closing it, and attaching a TP/SL. This is the part the session key handles end-to-end.

### Three addresses, three jobs

Three addresses do different jobs, and people mix them up constantly.

* **Owner EOA** is your real wallet. It signs all the *on-chain* setup transactions in Part 1, and never signs an EIP-712 trading message.
* **SubAccount** is a deterministic address derived from your EOA plus affiliate. It holds collateral. It's a *virtual* address with no bytecode: you reference it as the "account" in the calldata for opens, and as the `signerAccount.addr` field of the EIP-712 messages you sign to open positions.
* **Virtual Account (VA)** is a deterministic address spawned the first time a `(symbol, direction)` pair is traded under a sub-account. It holds margin and the active quotes. **You sign closes against the VA, not the sub-account.** That's the single most common authorization mistake.

Whenever you build calldata for an EIP-712 op, ask yourself: *whose account is this for?* The session key always *signs*, but `signerAccount.addr` flips between the sub-account (opens) and the VA (closes and TPSL).

Every contract address and service endpoint this guide refers to is deployment-specific; gather the ones for your deployment from Reference: [Solver Addresses & Endpoints](/api-endpoints-and-deployments/solver-addresses-and-endpoints.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.symm.io/trader-documentation/building-a-trading-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
