Filters & Utilities

Helper methods on MMPricingModule for filtering, sorting, and selecting pricing data from a pricing array.

Setup

All utilities are methods on client.mmPricing. Start by fetching a pricing array:

import { ThetanutsClient } from '@thetanuts-finance/thetanuts-client';

const client = new ThetanutsClient({ chainId: 8453 });

const all = await client.mmPricing.getAllPricing('ETH');
const values = Object.values(all);

filterExpired

Removes options whose expiry has already passed.

const active = client.mmPricing.filterExpired(values);
// Returns only options with expiry > Date.now()

sortByExpiryAndStrike

Sorts options by nearest expiry first, then ascending strike within each expiry.


getUniqueExpiries

Returns a deduplicated list of expiry date strings in YYYY-MM-DD format, sorted ascending.


filterByType

Filters the array to only calls (isCall: true) or only puts (isCall: false).


filterByExpiry

Filters the array to options expiring on a specific date string (YYYY-MM-DD).


filterByStrikeRange

Filters the array to options whose strike falls within [min, max] (inclusive).


getPricingArray

Convenience method: fetches all pricing for an underlying, removes expired entries, and returns the result as a sorted array in one call.


Combining Utilities

Utilities can be chained to build a precise subset. Example: active put options near ATM for a specific expiry.


See Also

Last updated