Create a conditional order
tossinvest_create_conditional_orderWatch a symbol and automatically place a buy or sell when the price hits your trigger. Create single orders, OCO take-profit/stop-loss brackets, or OTO buy-then-sell sequences.
Instructions
Register a REAL price-triggered order: watch a symbol and automatically place a buy or sell when the price reaches a trigger. Confirm every parameter with the user first.
Types:
SINGLE — watch one condition ('first'). Either side. LIMIT or MARKET. No per-symbol limit.
OCO (one-cancels-the-other) — watch two conditions at once; when one fires the other is cancelled. Both must be SELL, LIMIT only, and first.trigger_price > current price > second.trigger_price. This is the take-profit / stop-loss bracket on an existing position.
OTO (one-triggers-the-other) — 'second' only starts being watched after 'first' fills. first must be BUY, second must be SELL, LIMIT only. This is buy-then-auto-exit. OCO and OTO are limited to one per symbol; a second one fails with 422 duplicate-conditional-order.
Args:
symbol (string): the symbol to watch.
type ('SINGLE' | 'OCO' | 'OTO').
quantity (string): share count, shared by every leg in the group.
order_type ('LIMIT' | 'MARKET'): shared by every leg. LIMIT requires order_price on each condition; MARKET forbids it. OCO/OTO accept LIMIT only.
expire_date (string): YYYY-MM-DD. The conditional order auto-expires unfired on this date.
first (object): { order_side, trigger_price, order_price? } — the first watched condition.
second (object, optional): same shape. Omit for SINGLE, required for OCO and OTO.
client_order_id (string, optional): idempotency key.
confirm_high_value_order (boolean): default false. Required true at ₩100,000,000 or more.
account_seq (number, optional): resolved automatically for single-account credentials.
response_format ('markdown' | 'json'): default 'markdown'.
Returns { accountSeq, conditionalOrderId, clientOrderId, operation: 'created' }.
Errors: 422 condition-already-met when the trigger price has already been reached (pick another price), 422 duplicate-conditional-order, 400 invalid-request for a bad leg combination.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | SINGLE = one condition; OCO = two SELL conditions, one cancels the other; OTO = BUY then auto-SELL. | |
| first | Yes | First watched condition. For OTO this is the parent BUY leg. | |
| second | No | Second condition. Omit for SINGLE; required for OCO and OTO. | |
| symbol | Yes | Stock symbol. KRX: 6 digits (e.g. '005930' for Samsung Electronics). US: ticker (e.g. 'AAPL'). | |
| quantity | Yes | Share count, shared by every leg of the group. | |
| order_type | Yes | Shared by every leg. OCO and OTO accept 'LIMIT' only. | |
| account_seq | No | accountSeq of the account to act on (the `X-Tossinvest-Account` header). Optional: falls back to TOSSINVEST_ACCOUNT_SEQ, then to the sole account on the credentials. Get valid values from tossinvest_list_accounts. | |
| expire_date | Yes | Expiry date (YYYY-MM-DD). The conditional order is dropped if it has not fired by then. | |
| client_order_id | No | Idempotency key, max 36 chars. Re-sending the same value within 10 minutes returns the original order instead of creating a second one. Strongly recommended so a retry never double-fills. | |
| response_format | No | Output format: 'markdown' for a compact human-readable summary, 'json' for the complete raw payload. | markdown |
| confirm_high_value_order | No | Set true to acknowledge an order of ₩100,000,000 or more; such orders are rejected with `confirm-high-value-required` otherwise. Only set this after the user has confirmed the amount. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | ||
| operation | Yes | created, modified or canceled | |
| accountSeq | Yes | ||
| clientOrderId | No | ||
| conditionalOrderId | Yes | Identifier to use from now on — a modify issues a NEW id and invalidates the old one |