FMP Data
Access financial market data through natural language queries.
Overview
The FMP (Financial Modeling Prep) LangChain integration provides a seamless way to access financial market data through natural language queries. This integration offers two main components:
FMPDataToolkit
: Creates collections of tools based on natural language queriesFMPDataTool
: A single unified tool that automatically selects and uses the appropriate endpoints
The integration leverages LangChain's semantic search capabilities to match user queries with the most relevant FMP API endpoints, making financial data access more intuitive and efficient.
Setup
!pip install -U langchain-fmp-data
import os
# Replace with your actual API keys
os.environ["FMP_API_KEY"] = "your-fmp-api-key" # pragma: allowlist secret
os.environ["OPENAI_API_KEY"] = "your-openai-api-key" # pragma: allowlist secret
It's also helpful (but not needed) to set up LangSmith for best-in-class observability:
# os.environ["LANGCHAIN_TRACING_V2"] = "true"
# os.environ["LANGCHAIN_API_KEY"] = getpass.getpass()
Instantiation
There are two main ways to instantiate the FMP LangChain integration:
- Using FMPDataToolkit
from langchain_fmp_data import FMPDataToolkit
query = "Get stock market prices and technical indicators"
# Basic instantiation
toolkit = FMPDataToolkit(query=query)
# Instantiation with specific query focus
market_toolkit = FMPDataToolkit(
query=query,
num_results=5,
)
# Instantiation with custom configuration
custom_toolkit = FMPDataToolkit(
query="Financial analysis",
num_results=3,
similarity_threshold=0.4,
cache_dir="/custom/cache/path",
)
- Using FMPDataTool
from langchain_fmp_data import FMPDataTool
from langchain_fmp_data.tools import ResponseFormat
# Basic instantiation
tool = FMPDataTool()
# Advanced instantiation with custom settings
advanced_tool = FMPDataTool(
max_iterations=50,
temperature=0.2,
)