searchTpSlOrders
Search conditional orders at the TP/SL handler.
Hits POST /api/v5/search/. Where getQuoteTpSl reads a single quote, this returns every matching order in one request — so a merged position’s legs cost one call rather than one call per leg.
Every filter is optional, including account. Pass one to read a single account’s legs; omit it to read across accounts, which is how a pool’s order book is read: filter by symbolId and conditionalOrderType and the rows come back for every trader on that market. The handler files conditional orders under the Virtual Account that owns them, so that is what account takes when you do pass it.
import { searchTpSlOrders } from "@symmio/trading-core";
const { orders, isComplete } = await searchTpSlOrders(config, {
account: virtualAccount,
});Parameters
accountAddressoptionalAccount whose orders to search — the Virtual Account the handler stores as party_a_address.
stateQuoteTpSlRowState[]optionalRow states to include. Defaults to TPSL_LIVE_ORDER_STATES — pending, new, triggered, triggered_pending.
symbolIdnumberoptionalRestrict to one market.
conditionalOrderTypeQuoteTpSlConditionalOrderTypeoptionalRestrict to one side.
conditionalPriceTypeQuoteTpSlActionPriceTypeoptionalRestrict to one trigger-price source.
startnumberoptionalPage offset. Defaults to 0.
sizenumberoptionalPage size. Defaults to 200.
timeoutMsnumberoptionalAbort the request after this many milliseconds. Unset means axios’s “wait forever” — pass one when the call is on a repeating schedule, so a stalled connection fails the attempt instead of hanging it.
Returns
SearchTpSlOrdersReturnTypeorders — the page’s rows (QuoteTpSlRow). count — the handler’s reported total,
advisory only. isComplete — whether this page provably exhausted the filtered result set.
Why the default state filter matters
Absence from the result is how a caller learns an order is gone. That inference is only sound if the filter matches the set of states that represent a live order, which is why TPSL_LIVE_ORDER_STATES includes the two triggered states: filtering to ["pending", "new"] would drop a take-profit that fired between two reads, and its absence would read as “cancelled”.
Why isComplete ignores count
isComplete is derived from orders.length < size, not from count. A short page provably exhausted the result set under any interpretation of count, whereas count’s exact meaning on this endpoint is unverified — and this endpoint’s sibling GET already contradicts its own spec. Reading absence from a truncated page would report a live order as cancelled, so the safe signal is the one that cannot be misread.
Throws
SymmErrorwhen the chain has notpslconfig.SymmApiErrorwhen the HTTP request fails, taggedSEARCH_TPSL_FAILED.
Query options
import { searchTpSlOrdersQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(searchTpSlOrdersQueryOptions(config, { account: virtualAccount }));Disabled until the search is scoped by something — an account or a symbolId. Both are legitimate scopes: an account reads one trader’s legs, a symbolId reads one market’s book across every trader. What stays disabled is the unscoped case, which would sweep every order the handler holds.
Related
getQuoteTpSl— the per-quote read.QuoteTpSlRow— the raw row shape.- TP/SL hooks — the React layer, where this backs the confirmation fallback sweep.
Reading a pool’s order book
Omitting account and filtering by market is how the Pools detail view fills its limit-orders table:
import { searchTpSlOrders, TpSlSearchOrderType } from "@symmio/trading-core";
const { orders } = await searchTpSlOrders(config, {
symbolId,
conditionalOrderType: TpSlSearchOrderType.SEND_QUOTE,
});TpSlSearchOrderType is a superset of TpSlConditionalOrderType: besides the two TP/SL legs that close a position, the handler also stores send_quote orders, which open one when a trigger price is hit.
That distinction matters. A send_quote order is not a protocol LIMIT order — the lowcap solver declares limitOrder: false and can still have them, so do not gate the table on that capability.
See Pool detail tables.