logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

fiscal-data-retriever-toolkit

A specialized library granting programmatic access to expansive economic datasets, encompassing corporate financial records and market intelligence. It promotes advanced analytical workflows and automated decision support via seamless Large Language Model integration. Includes robust exception handling and complete API interfacing for fetching financial reports.

Author

fiscal-data-retriever-toolkit logo

leomercier

No License

Quick Info

GitHub GitHub Stars 56
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

financialdatasetsapiapisfinancialdatasets sdkleomercier financialdatasetsfinancial data

Economic Intelligence Retrieval Toolkit / LLM Connector

A robust TypeScript Software Development Kit engineered for effortless interaction with the Economic Data Service API, featuring intrinsic interoperability with sophisticated language models through the Vercel AI SDK.

Core Capabilities

  • Full TypeScript schema definitions covering every endpoint of the Economic Data Service API
  • Native integration layer supporting LLM function invocation via the Vercel AI SDK
  • Comprehensive fault tolerance mechanisms and strict input validation
  • Intuitive, descriptive API surface with precise type enforcement and integrated documentation

Setup Instructions

# Via npm
npm install fiscal-data-retriever-toolkit

# Via Yarn
yarn add fiscal-data-retriever-toolkit

# Via Bun
bun add fiscal-data-retriever-toolkit

Primary Application Example

import { initializeFinancialTooling } from "fiscal-data-retriever-toolkit";

// Instantiate the data querying mechanisms using your access credential
const dataAccessTools = initializeFinancialTooling("your-secret-api-key");

// Invoke the tools directly
async function fetchAppleQuarterlyEarnings() {
  const report = await dataAccessTools.retrieveIncomeStatements.invoke({
    identifier: "AAPL",
    timeframe: "quarterly",
    count: 5
  });

  console.log(report);
}

LLM Interfacing (Vercel AI SDK)

The toolkit is architected for fluid operation alongside Generative AI agents utilizing the Vercel AI SDK's capacity for tool invocation.

Deployment within Next.js App Router

// app/api/conversation/route.ts
import { StreamingTextResponse, ChatCompletionRequestConfig } from "ai";
import { initializeFinancialTooling } from "fiscal-data-retriever-toolkit";
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY
});

// Setup data interaction layer
const dataAccessTools = initializeFinancialTooling(
  process.env.FINANCIAL_DATA_API_SECRET_KEY! 
);

// Define the functions available to the language model agent
const availableFunctionSpecs: ChatCompletionRequestConfig['tools'] = [
  dataAccessTools.retrieveIncomeStatements,
  dataAccessTools.retrieveBalanceSheets,
  dataAccessTools.fetchStockQuote,
  dataAccessTools.queryCompanyProfile
];

export async function POST(req: Request) {
  const { messages } = await req.json();

  const response = await client.chat.completions.create({
    model: "gpt-4-turbo-preview",
    messages,
    tools: availableFunctionSpecs,
    stream: true
  });

  return new StreamingTextResponse(response.body);
}

Integration with Anthropic's Claude

// app/api/conversation/route.ts
import { StreamingTextResponse } from "ai";
import { initializeFinancialTooling } from "fiscal-data-retriever-toolkit";
import Anthropic from "@anthropic-ai/sdk";

const anthropicClient = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY
});

// Setup data interaction layer
const dataAccessTools = initializeFinancialTooling(
  process.env.FINANCIAL_DATA_API_SECRET_KEY! 
);

export async function POST(req: Request) {
  const { messages } = await req.json();

  const response = await anthropicClient.messages.create({
    model: "claude-3-opus-20240229",
    messages,
    tools: [
      dataAccessTools.retrieveIncomeStatements,
      dataAccessTools.retrieveBalanceSheets,
      dataAccessTools.fetchStockQuote,
      dataAccessTools.queryCompanyProfile
    ],
    stream: true
  });

  return new StreamingTextResponse(response);
}

Tool Index Reference

The SDK exposes the following callable instruments:

Corporate Financial Statements

Function Name Purpose
retrieveIncomeStatements Fetch profit and loss statements by security code
retrieveBalanceSheets Obtain balance sheet data by security code
retrieveCashFlows Get statements detailing cash movements by code
fetchComprehensiveStatements Retrieve all primary financial reports for a symbol
getRevenueBreakdowns Acquire granular, segmented revenue figures
searchStatements Query financial reports using definable criteria
locateMetric Search for specific accounting line items across records

Market Intelligence

Function Name Purpose
fetchStockQuote Get the current market valuation for a ticker
queryHistoricalPrices Retrieve time-series price information by code

Entity Metadata

Function Name Purpose
queryCompanyProfile Retrieve organizational background and core details for a code
fetchRegulatorySubmissions Access official regulatory filings (e.g., SEC) for an entity
getInsiderActivity Pull records of internal stock transactions (buys/sells)

Derivatives Data

Function Name Purpose
getDerivativesBook Retrieve current trading data for options contracts on an asset

Key Performance Indicators (KPIs)

Function Name Purpose
getKpiSummary Fetch an instantaneous summary of critical financial ratios and metrics for a code

Illustrative LLM Context Prompts

When configuring agents to utilize these instruments, context regarding their capabilities is beneficial. Examples follow:

For Multi-Instrument Comparative Analysis

You are equipped with data querying mechanisms for market figures and corporate specifics.
Undertake an evaluation of 'Apple' (AAPL) using the available utilities:
1. Retrieve the corporate profile details
2. Ascertain the latest trading price
3. Acquire the last three fiscal years of annual income statements
4. Synthesize observations regarding growth trajectories in sales, net income yields, and overall fiscal stability

For Sector Performance Benchmarking

Contrast the fiscal achievements of 'Tesla' (TSLA) versus 'Ford' (F) across the previous two reporting periods.
Employ the designated tools to fetch:
- Annual income reports
- The KPI summary
- Current market capitalization figures

Subsequently, articulate a comparative assessment focusing on growth velocity, profitability margins, and solvency health.

For Technical Investment Due Diligence

I am assessing a potential position in 'Microsoft' (MSFT). Can you execute the following steps:
1. Retrieve daily trading data covering the last 90 trading days
2. Analyze the resulting price momentum
3. Review the most recent quarterly P&L statement
4. Examine the KPI summary data
5. Formulate an investment recommendation based on technical movement and underlying financial strength

Advanced Configuration Options

Custom Service Root

To interface with an alternative backend endpoint:

const dataAccessTools = initializeFinancialTooling(
  "your-secret-api-key",
  "https://alternative-data-source.net/v1"
);

Response Error Management

All functions incorporate pre-configured error handling routines:

const data = await dataAccessTools.retrieveIncomeStatements.invoke({
  identifier: "NULLED_TICKER",
  timeframe: "annual"
});

if ("error" in data) {
  console.error(`Failure Code: ${data.error} - Detail: ${data.message}`);
} else {
  // Proceed with successful data processing
  console.log(data.statements_array);
}

Development Workflow

Building the Library

# Install project dependencies
bun install

# Compile the library source code
bun run build

# Generate client bindings from OpenAPI specification
bun run generate-client

Licensing

Proprietary

See Also

`