npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@texashighfrequency/thf-labs

v0.1.1

Published

Components for utilization with Texas High Frequency API routing services.

Downloads

17

Readme

THF Labs React Component Library

A React component library designed for Texas High Frequency API routing services. This library provides reusable components and services for displaying and managing financial data.

Installation

npm install thf-labs

API Configuration

⚠️ Important: An API key is required to use any of the THF Labs services. Components can be used independently without an API key.

Before using any services (like DealerGammaService), configure the ApiClient with your API key:

import { ApiClient } from 'thf-labs';

// Initialize the API client with your key
const apiClient = ApiClient.getInstance();

// Best practice: Set this in your app's entry point (e.g., App.js or index.js)
// Make sure to use environment variables for the API key
apiClient.setApiKey(process.env.REACT_APP_THF_API_KEY);

Environment Variables

For security, we recommend storing your API key in environment variables:

  1. Create a .env file in your project root:
REACT_APP_THF_API_KEY=your-api-key
  1. Add .env to your .gitignore file:
# .gitignore
.env
.env.local
  1. Create a .env.example file:
REACT_APP_THF_API_KEY=your-api-key-here

Components

THFtable

A flexible and feature-rich table component that supports sorting, pagination, and customizable styling.

Features

  • Column sorting (ascending/descending)
  • Pagination with customizable page size
  • Responsive design with horizontal scrolling
  • Error state handling
  • Loading state display
  • TypeScript support
  • Customizable styling

Props

| Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| | data | array | Yes | - | Array of objects to display in the table | | columns | Column[] | Yes | - | Array of column definitions | | pageSize | number | No | 10 | Number of rows per page | | title | string | No | - | Optional table title |

Column Definition

interface Column {
  key: string;          // Unique identifier for the column
  header: string;       // Display text for column header
  sortable?: boolean;   // Enable sorting for this column
}

Basic Usage

import { THFtable } from 'thf-labs';

const MyComponent = () => {
  const columns = [
    { key: 'symbol', header: 'Symbol', sortable: true },
    { key: 'strike', header: 'Strike', sortable: true },
    { key: 'gamma', header: 'Gamma', sortable: true }
  ];

  const data = [
    { symbol: 'SPY', strike: 432, gamma: -1 },
    { symbol: 'SPY', strike: 440, gamma: -1 },
    // ... more data
  ];

  return (
    <THFtable 
      data={data}
      columns={columns}
      pageSize={15}
      title="Options Data"
    />
  );
};

Services

DealerGammaService

A singleton service for fetching and transforming dealer gamma data. Requires API key configuration (see API Configuration section above).

Features

  • Singleton pattern for consistent state management
  • Built-in data transformation for THFtable compatibility
  • TypeScript support with proper typing
  • Integrated with ApiClient for API communication

Usage

import { DealerGammaService, THFtable } from 'thf-labs';

const GammaDataComponent = () => {
  const [tableData, setTableData] = useState([]);
  const [error, setError] = useState(null);
  const [isLoading, setIsLoading] = useState(true);
  const dealerGammaService = DealerGammaService.getInstance();

  useEffect(() => {
    const fetchData = async () => {
      setIsLoading(true);
      try {
        const response = await dealerGammaService.getGammaData('SPY');
        const formattedData = dealerGammaService.transformGammaDataForTable(response);
        setTableData(formattedData);
        setError(null);
      } catch (error) {
        setError(error.message || 'Failed to fetch gamma data');
        setTableData([]);
      } finally {
        setIsLoading(false);
      }
    };

    fetchData();
  }, []);

  const columns = [
    { key: 'symbol', header: 'Symbol', sortable: true },
    { key: 'zerogex', header: 'Zero GEX', sortable: true },
    { key: 'strike', header: 'Strike', sortable: true },
    { key: 'gamma', header: 'Gamma', sortable: true }
  ];

  if (isLoading) {
    return <div>Loading...</div>;
  }

  if (error) {
    return <div>{error}</div>;
  }

  return <THFtable data={tableData} columns={columns} />;
};

API Methods

getInstance()

Returns the singleton instance of DealerGammaService.

const service = DealerGammaService.getInstance();
getGammaData(symbol: string)

Fetches dealer gamma data for a specific symbol.

const data = await service.getGammaData('SPY');
transformGammaDataForTable(data: DealerGammaResponse)

Transforms the API response into a format compatible with THFtable.

const tableData = service.transformGammaDataForTable(data);

CSS Customization

The library provides default styling that can be customized using CSS classes:

THFtable Classes

  • .thf-table-container - Main table container
  • .thf-table - Table element
  • .thf-table-title - Table title
  • .thf-table th.sortable - Sortable column headers
  • .thf-table th.sorted-asc - Ascending sorted column
  • .thf-table th.sorted-desc - Descending sorted column
  • .sort-indicator - Sort direction indicator
  • .loading-container - Loading state container
  • .loading-spinner - Loading spinner animation
  • .error-container - Error state container
  • .error-message - Error message styling

TypeScript Support

This library is written in TypeScript and includes type definitions. No additional @types packages are required.

License

ISC