flatten_and_go_short
Sell your current long position in a stock and immediately initiate a short sale in a single 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.
If no long position exists the flatten step is skipped and only the short order is placed.
Args: symbol: Ticker symbol (e.g. "AAPL"). short_quantity: Number of shares to short after flattening. order_type: MARKET, LIMIT, STOP, or STOP_LIMIT. Default is MARKET. time_in_force: DAY or GTD. Default is DAY. limit_price: Required for LIMIT and STOP_LIMIT 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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| short_quantity | Yes | ||
| order_type | No | MARKET | |
| time_in_force | No | DAY | |
| limit_price | No | ||
| stop_price | No | ||
| expiration_time | No | ||
| equity_market_session | No | ||
| flatten_timeout | No | ||
| account_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |