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.
- 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.
You can install the package using pip:
pip install financial_parserfrom 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)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)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)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.
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.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
- Eugene Evstafev
- Email: hi@euegne.plus
- GitHub: chigwell