Skip to content

A new package is designed to analyze financial news headlines and extract key structured information such as company names, financial targets, timeframes, and goal updates from text inputs. It simplif

Notifications You must be signed in to change notification settings

chigwell/financial-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Financial-Parser

PyPI version License: MIT Downloads LinkedIn

Financial-Parser is a Python package designed to analyze financial news headlines and extract key structured information such as company names, financial targets, timeframes, and goal updates from text inputs. It simplifies monitoring market sentiment and tracking financial forecasts by processing pre-extracted textual data, providing clear, structured summaries that facilitate automated analysis and decision-making.

Features

  • Extracts structured information from financial news headlines.
  • Supports custom language models (LLMs) from LangChain.
  • Defaults to using ChatLLM7 from LangChain for ease of use.
  • Allows custom API keys for higher rate limits.

Installation

You can install the package using pip:

pip install financial_parser

Usage

Basic Usage

from financial_parser import financial_parser

user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
response = financial_parser(user_input)

print(response)

Using a Custom LLM

You can use a custom LLM from LangChain by passing it as an argument. For example, to use OpenAI:

from langchain_openai import ChatOpenAI
from financial_parser import financial_parser

llm = ChatOpenAI()
user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
response = financial_parser(user_input, llm=llm)

print(response)

Similarly, you can use other LLMs like Anthropic or Google:

from langchain_anthropic import ChatAnthropic
from financial_parser import financial_parser

llm = ChatAnthropic()
user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
response = financial_parser(user_input, llm=llm)

print(response)
from langchain_google_genai import ChatGoogleGenerativeAI
from financial_parser import financial_parser

llm = ChatGoogleGenerativeAI()
user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
response = financial_parser(user_input, llm=llm)

print(response)

Using a Custom API Key

You can provide a custom API key for higher rate limits:

from financial_parser import financial_parser

user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
api_key = "your_custom_api_key"
response = financial_parser(user_input, api_key=api_key)

print(response)

Or set the API key via an environment variable:

export LLM7_API_KEY="your_custom_api_key"

Then use the package without passing the API key:

from financial_parser import financial_parser

user_input = "Company XYZ announces Q4 earnings of $1.2 billion, up from $1.1 billion last year."
response = financial_parser(user_input)

print(response)

Input Parameters

  • user_input (str): The user input text to process.
  • llm (Optional[BaseChatModel]): The LangChain LLM instance to use. If not provided, the default ChatLLM7 will be used.
  • api_key (Optional[str]): The API key for LLM7. If not provided, the default API key will be used.

Default Rate Limits

The default rate limits for LLM7 free tier are sufficient for most use cases of this package. If you need higher rate limits, you can pass your own API key via the environment variable LLM7_API_KEY or directly via the api_key parameter.

You can get a free API key by registering at LLM7 Token.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Author