Skip to content
Closed
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
2 changes: 1 addition & 1 deletion sdks/typescript/pmxt/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3112,7 +3112,7 @@ export abstract class Exchange {
// Price change filter
if (criteria.priceChange24h) {
const outcome = market[criteria.priceChange24h.outcome];
if (!outcome || outcome.priceChange24h === undefined) return false;
if (!outcome || outcome.priceChange24h == null) return false;

if (criteria.priceChange24h.min !== undefined && outcome.priceChange24h < criteria.priceChange24h.min) {
return false;
Expand Down
31 changes: 31 additions & 0 deletions sdks/typescript/tests/filter-markets-local.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Polymarket } from '../pmxt/client';

describe('filterMarkets', () => {
it('filters out markets where priceChange24h is null while keeping zero', () => {
const client = new Polymarket({ autoStartServer: false });

const nullPriceChangeMarket: any = {
marketId: 'null-market',
title: 'Null market',
yes: { outcomeId: 'yes', outcome: 'Yes', label: 'Yes', price: 0.5, priceChange24h: null },
no: { outcomeId: 'no', outcome: 'No', label: 'No', price: 0.5, priceChange24h: null },
};

const zeroPriceChangeMarket: any = {
marketId: 'zero-market',
title: 'Zero market',
yes: { outcomeId: 'yes', outcome: 'Yes', label: 'Yes', price: 0.5, priceChange24h: 0 },
no: { outcomeId: 'no', outcome: 'No', label: 'No', price: 0.5, priceChange24h: 0.2 },
};

const out = client.filterMarkets([nullPriceChangeMarket, zeroPriceChangeMarket], {
priceChange24h: {
outcome: 'yes',
min: -1,
},
});

expect(out).toHaveLength(1);
expect(out[0].marketId).toBe('zero-market');
});
});