FlattenEverything and Flatten
FlattenEverything closes every open position on the named account. Flatten closes a specific instrument. Both are write actions that should only run after explicit user confirmation.
Write Action
FlattenEverything will hit the market with closing orders for every open position. There is no preview. On a funded account this can convert paper losses into realized losses and lock you out for the day.
| Property | Value |
|---|---|
| Required scope | mcp:trade |
| Risk | High. Realizes P&L. |
| Side effects | Closes positions immediately. |
When an agent should use it
- Only when the user has explicitly asked to flatten.
- In genuine emergency stop scenarios when the user has confirmed.
- At session end if the user has confirmed an EOD-flatten preference.
When an agent should not use it
- As an autonomous response to drawdown.
- As a "clean up" step in a journal review or compile loop.
- On a funded account that has firm-specific EOD or news constraints unless the user has confirmed.
Parameters
FlattenEverything:
{ "account": "Sim101" }
Flatten:
{ "account": "Sim101", "instrument": "MES 06-26" }
Response shape
{
"closed_positions": [
{"instrument": "MES 06-26", "side": "Long", "quantity": 2}
],
"remaining_positions": []
}
Example user prompt
On Sim101, list positions. If anything is open, propose a FlattenEverything plan
and wait for me to confirm. After I confirm, call FlattenEverything and then
list positions again to verify flat.
Example tool call
{ "name": "FlattenEverything", "arguments": { "account": "Sim101" } }
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
account_disconnected | Cannot route closing orders. | Reconnect and retry. |
| Partial close | Order rejected mid-flatten. | Re-list positions, inspect rejection in GetOrder. |
nothing_to_flatten | Account was already flat. | This is fine, not an error. |
Safe workflow placement
ListPositions → ListOrders → user confirms flatten → Flatten* → ListPositions
After the call, the agent should re-list positions and orders. Do not claim flat without verification.