flatten_and_go_short
Sells off any existing long position, then places a short-sale order. Converts long exposure to short in a two-step workflow.
Instructions
Sell any existing long position in a symbol, then place a short-sale order.
⚠️ Experimental — this is a two-order workflow, not atomic. Market conditions may change between the flatten fill and the short entry. Both orders execute as real trades.
Each order is preflighted just before it is sent. The server preflights the flatten (a MARKET sell of the whole long position) and asks the user to confirm the whole workflow when the client supports it. After the flatten fills, it preflights the short and checks it against the configured limits. If that check fails, the short is not placed and the account is left flat: the response then has status "flattened_not_shorted" and the flatten's order ID. If the user cancels or the first preflight fails, the response has "submitted": false and nothing is sent.
If no long position exists the flatten step is skipped, and the short is preflighted and confirmed like place_short_order.
Args: symbol: Ticker symbol (e.g. "AAPL"). short_quantity: Number of shares to short after flattening. order_type: MARKET, LIMIT, STOP, STOP_LIMIT, MARKET_ON_CLOSE or LIMIT_ON_CLOSE. Default is MARKET. The on-close types execute at the closing auction. time_in_force: DAY or GTD. Default is DAY. limit_price: Required for LIMIT, STOP_LIMIT and LIMIT_ON_CLOSE orders. stop_price: Required for STOP and STOP_LIMIT orders. expiration_time: Required when time_in_force is GTD. ISO 8601 format. equity_market_session: CORE or EXTENDED. flatten_timeout: Seconds to wait for the flatten order to fill (default 60). account_id: Account ID. Optional if PUBLIC_COM_ACCOUNT_ID is set.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"symbol": "<symbol>",
"short_quantity": "<short_quantity>"
},
"name": "flatten_and_go_short"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| account_id | No | ||
| order_type | No | MARKET | |
| stop_price | No | ||
| limit_price | No | ||
| time_in_force | No | DAY | |
| short_quantity | Yes | ||
| expiration_time | No | ||
| flatten_timeout | No | ||
| equity_market_session | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |