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.agent.openai import OpenAIAgent
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,
) -> OpenAIAgent:
    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 OpenAIAgent.from_tools(
        tool_spec.to_tool_list(), llm=llm, verbose=True
    )


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

response = agent.chat("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.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: llama_index_tools_finance-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0

File hashes

Hashes for llama_index_tools_finance-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cdb886f53f21d7ab96a28513a6550697771749410097a015b37a8b3d77b83d4d
MD5 1c2b26b9a8619aa56f691fb6eece9cac
BLAKE2b-256 3f88fe150c814390a2e79598c364b89aeb23597ddf3528cf6de41b99c5b08ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_finance-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d944974f87989ec970ea1601e5551e5ab1f4d0c7b099da7f857f244b72025c6
MD5 eb926fe43923f69ea28ff60a4a2c1458
BLAKE2b-256 6be849faea9015692f19c652a425aa18c441d55928df5db73a6d7558f438bfef

See more details on using hashes here.

Supported by

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