Skip to main content

llama-index finance-tools integration

Project description

Finance Agent Tool

This tool connects to various open finance apis and libraries to gather news, earnings information and doing fundamental analysis.

To use this tool, you'll need a few API keys:

Installation

pip install llama-index-tools-finance

Usage

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.finance import FinanceAgentToolSpec

POLYGON_API_KEY = ""
FINNHUB_API_KEY = ""
ALPHA_VANTAGE_API_KEY = ""
NEWSAPI_API_KEY = ""
OPENAI_API_KEY = ""

GPT_MODEL_NAME = "gpt-4-0613"


def create_agent(
    polygon_api_key: str,
    finnhub_api_key: str,
    alpha_vantage_api_key: str,
    newsapi_api_key: str,
    openai_api_key: str,
) -> FunctionAgent:
    tool_spec = FinanceAgentToolSpec(
        polygon_api_key,
        finnhub_api_key,
        alpha_vantage_api_key,
        newsapi_api_key,
    )
    llm = OpenAI(temperature=0, model=GPT_MODEL_NAME, api_key=openai_api_key)
    return FunctionAgent(
        tools=tool_spec.to_tool_list(),
        llm=llm,
    )


agent = create_agent(
    POLYGON_API_KEY,
    FINNHUB_API_KEY,
    ALPHA_VANTAGE_API_KEY,
    NEWSAPI_API_KEY,
    OPENAI_API_KEY,
)

response = await agent.run(
    "What happened to AAPL stock on February 19th, 2024?"
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_finance-0.4.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_finance-0.4.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_finance-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_finance-0.4.1.tar.gz
Algorithm Hash digest
SHA256 1efb6d17c56c71e31fad9d163243edbc1283d55c7ad307d6dd20dba4f90bd36c
MD5 c40ef5645abd5008442a0e22cbeb1a6d
BLAKE2b-256 ecd23a2d27400532cd7b549093966ec8d383ff5f08506e5d812b3b264283c253

See more details on using hashes here.

File details

Details for the file llama_index_tools_finance-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_finance-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30944c726982e1675c3eb30311cc6acbc594517fbec5107806361b00b225780f
MD5 f704d77c0b93f4b39a66c934dc0f71c4
BLAKE2b-256 f83d967a83f203b98683197487573120c6035a5f656b18e41a92b9b87f0a4696

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page