Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum

groupQuotes

Fold a flat list of quotes into grouped positions — one QuoteGroup per market + side, or per whatever a custom key function decides.

import { groupQuotes, partitionQuotes, SubAccountIsolationType } from "@symmio/trading-core"; const { positions } = partitionQuotes(quotes); const groups = groupQuotes(positions, SubAccountIsolationType.MARKET_DIRECTION);

Strategies

A QuoteGroupingStrategy is either SubAccountIsolationType.MARKET_DIRECTION — the only isolation type accepted — or a custom { keyOf }:

StrategyKeyResult
MARKET_DIRECTIONmd:<symbolId>:<positionType>One group per market + side
{ keyOf: keyQuoteByMarket }m:<symbolId>One group per market
{ keyOf: keyQuotePerQuote }the quote’s own keyOne group per quote
{ keyOf }whatever you returnWhatever you group on

Grouped positions are MARKET_DIRECTION-only. Passing MARKET, POSITION, or CUSTOM throws a SymmError with code UNSUPPORTED_GROUPING_ISOLATION. MARKET_DIRECTION is the one isolation where a market + side cohort is a real on-chain unit — the AccountLayer allocates one Virtual Account per market + direction — so it is the only one where folding the cohort into a single row aggregates values that belong together, and where a group-level action (group close, group TP/SL) acts on quotes that really share a VA. Check first with supportsQuoteGrouping.

To fold on another dimension, say so explicitly with a { keyOf }. keyQuoteByMarket and keyQuotePerQuote ship as ready-made key functions for the market-wide and one-row-per-quote cases — the same folds the removed built-ins performed, now an opt-in rather than a default:

import { groupQuotes, keyQuoteByMarket, keyQuotePerQuote } from "@symmio/trading-core"; // both sides of a market in one row — metrics mix longs and shorts const byMarket = groupQuotes(positions, { keyOf: keyQuoteByMarket }); // no aggregation: one single-child group per quote (isAggregate is always false) const perQuote = groupQuotes(positions, { keyOf: keyQuotePerQuote });

Parameters

Quotes to fold. Pass partitionQuotes(...).positions to keep pending orders flat.

strategyQuoteGroupingStrategyrequired

SubAccountIsolationType.MARKET_DIRECTION or a custom {keyOf}. Any other isolation type throws UNSUPPORTED_GROUPING_ISOLATION.

options.sort(a: QuoteGroup, b: QuoteGroup) => numberoptional

Group ordering override. Defaults to newest-first by the group’s newest child.

Returns

One group per distinct key, newest-first, each with child quotes newest-first.

Last updated on