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.0.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.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_tools_finance-0.4.0.tar.gz
Algorithm Hash digest
SHA256 bcc3aab0726292abaec489cd64d85c6d5fa58519a471336b3f4f907f6d932da6
MD5 eecb806c73310befaffd55bf89440b8e
BLAKE2b-256 259be0e7896fa53ba57d3b04e90c10139cc55a55a943b690f19f349179f83df0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_finance-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fb98e1424af1e01aca660b5ce83c4b9fbc248940c9761b9cf43d6cc7221e88f
MD5 33a336333ffc6d7e94ca82964740689f
BLAKE2b-256 e5c257afdc6adf21e047d04a78da957d89806f24d0ba976357bbf447c63c140f

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