Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/e2e/src/nuanze-client/leaderboardQueries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,14 @@ void describe(
username: FOLLOWED_LEADERBOARD_USERNAME,
timeframe: '24h',
includeUntraded: true,
includePrivate: true,
limit: 2,
}),
tc.nuanze.getFollowedLeaderboard({
username: FOLLOWED_LEADERBOARD_USERNAME,
timeframe: '24h',
includeUntraded: false,
includePrivate: false,
limit: 2,
}),
]);
Expand Down Expand Up @@ -309,6 +311,25 @@ void describe(
}
});

void test('forwards followed leaderboard private visibility for server validation', async () => {
try {
await tc.nuanze.getFollowedLeaderboard({
username: FOLLOWED_LEADERBOARD_USERNAME,
timeframe: '24h',
includePrivate: 'invalid' as unknown as boolean,
});
assert.fail('expected BAD_REQUEST for an invalid includePrivate value');
} catch (error) {
assert.ok(
error instanceof NuanzeServerFailureError,
'should throw NuanzeServerFailureError',
);
assert.equal(error.errorCode, 'BAD_REQUEST');
assert.equal(error.httpStatus, 400);
assertNonEmptyString(error.requestId, 'error.requestId');
}
});

void test('rejects an unknown followed leaderboard username', async () => {
try {
await tc.nuanze.getFollowedLeaderboard({
Expand Down
27 changes: 27 additions & 0 deletions apps/e2e/src/nuanze-client/positioningQueries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ void describe(
}
});

void test('binds global open-position cursors to private visibility', async () => {
const first = await tc.nuanze.getOpenPositions({
limit: 2,
includePrivate: false,
});
const { nextCursor } = first;
assertNonEmptyString(nextCursor, 'first.nextCursor');
assert.ok(nextCursor !== null);

try {
await tc.nuanze.getOpenPositions({
limit: 2,
includePrivate: true,
cursor: nextCursor,
});
assert.fail('expected CURSOR_FILTER_MISMATCH for changed filters');
} catch (error) {
assert.ok(
error instanceof NuanzeServerFailureError,
'should throw NuanzeServerFailureError',
);
assert.equal(error.errorCode, 'CURSOR_FILTER_MISMATCH');
assert.equal(error.httpStatus, 400);
assertNonEmptyString(error.requestId, 'error.requestId');
}
});

void test('rejects an unknown ticker with MARKET_NOT_FOUND', async () => {
try {
await tc.nuanze.getMarketPositioning({ ticker: 'NOTAREALTICKERXYZ' });
Expand Down
6 changes: 4 additions & 2 deletions packages/nuanze-client/src/NuanzeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export class NuanzeClient {
/**
* Gets a keyset-paginated leaderboard for every subaccount a username actively follows, sorted
* by PnL descending with nulls last. Subaccounts with no PnL in the window are included by
* default with null PnL/rank, zero counts, and no products.
* default with null PnL/rank, zero counts, and no products. Private subaccounts are excluded
* unless `includePrivate=true`.
*
* @throws {NuanzeServerFailureError} With `BAD_REQUEST` when params are invalid, or
* `USERNAME_NOT_FOUND` when the supplied username has no claimed identity.
Expand Down Expand Up @@ -509,7 +510,8 @@ export class NuanzeClient {
* Lists current open perpetual position legs across every market by signed unrealized PnL.
* Descending returns the largest gainers and ascending returns the largest losers. This is a
* latest indexed snapshot with no timeframe. Legs below $10 absolute notional are excluded.
* Each row includes market identity and its source snapshot timestamp.
* Private subaccounts are excluded unless `includePrivate=true`. Each row includes market
* identity and its source snapshot timestamp.
*
* @throws {NuanzeServerFailureError} With `INVALID_CURSOR`, `CURSOR_FILTER_MISMATCH`, or
* `BAD_REQUEST` when the query or cursor is invalid.
Expand Down
6 changes: 5 additions & 1 deletion packages/nuanze-client/src/types/clientTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export interface GetNuanzeFollowedLeaderboardParams {
timeframe: NuanzeLeaderboardTimeframe;
/** Include followed subaccounts with no PnL in the requested window, default true. */
includeUntraded?: boolean;
/** Include followed subaccounts with Private Mode enabled, default false. */
includePrivate?: boolean;
/** Page size, 1-200, default 100. */
limit?: number;
/**
Expand Down Expand Up @@ -742,7 +744,9 @@ export interface GetNuanzeOpenPositionsParams {
limit?: number;
/** Signed unrealized-PnL direction, default `desc` (largest gainers first). */
sortDirection?: NuanzeOpenPositionSortDirection;
/** Opaque exclusive cursor bound to the sort direction. */
/** Include positions from subaccounts with Private Mode enabled, default false. */
includePrivate?: boolean;
/** Opaque exclusive cursor bound to the sort direction and private visibility. */
cursor?: string;
}

Expand Down
Loading