Skip to main content

tradeodds-langchain

LangChain tools for the TradeOdds REST API. Drop the four tools below into any LangChain agent and it can reason about quantitative pattern analysis on ~3,200 symbols.

pip install tradeodds-langchain

Quickstart

import os
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from tradeodds_langchain import all_tools

os.environ.setdefault("TRADEODDS_API_KEY", "sk-to-...")

tools = all_tools()
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a quantitative trading research assistant. Ground every claim in TradeOdds base rates."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
executor.invoke({"input": "What usually happens in SPY 5 days after a high-VIX bull-regime day?"})

Tools

Tool What it does Auth Cost
TradeOddsListSymbolsTool List every available symbol (~3,200) none free
TradeOddsPriceHistoryTool Daily OHLCV bars for a symbol none free
TradeOddsAnalyzeTool Historical pattern analysis on one symbol API key $0.05
TradeOddsFactorMatchTool Scan all symbols for current matches API key $0.15

Each tool subclasses langchain_core.tools.BaseTool with a Pydantic v2 args_schema. Tool descriptions are written for the LLM — they explain what the tool does, when to use it, and what shape it returns, so most agents pick the right tool with no extra prompting.

Configuration

Set TRADEODDS_API_KEY in your environment (or pass client=TradeOddsClient(api_key=...) per tool). Get a key at https://tradeodds.io/account.

Sharing a client

By default each tool builds its own TradeOddsClient. To share an HTTP session (e.g. with retries) across all four tools:

from tradeodds import TradeOddsClient
from tradeodds_langchain import all_tools

client = TradeOddsClient(api_key="sk-to-...", timeout=120.0)
tools = all_tools(client=client)

Manual tool wiring

If you only need one tool, import it directly:

from tradeodds_langchain import TradeOddsFactorMatchTool

tool = TradeOddsFactorMatchTool()
result = tool.invoke({
    "conditions": {"vix_level": True, "regime": True, "rsi_zone": True},
    "filters": {"is_etf": False, "price_min": 10},
    "perf_filter": {"metric": "win_5d", "operator": "gt", "threshold": 0.6},
    "min_instances": 20,
})

Error handling

API errors are returned as a structured dict so the agent can read them:

{"ok": False, "error": {"code": "rate_limit_exceeded", "message": "...", "hint": "...", "request_id": "...", "status_code": 429}}

That way one bad call doesn't break an agent loop — the LLM sees the error envelope and can retry, narrow the query, or surface the issue to the user.

License

MIT.

Metadata

Release files for tradeodds-langchain 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradeodds-langchain 0.1.0
File Size Uploaded
tradeodds_langchain-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tradeodds-langchain 0.1.0
File Interpreter ABI Platform
tradeodds_langchain-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / tradeodds_langchain-0.1.0.tar.gz

Download URL tradeodds_langchain-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1becff566f2d7c4967f5b215c845652993835fdd0ea5013e35e933e9d76b1bb4
BLAKE2b-256 checksum
How to use checksums
a0b5767878bc2f38e3af727ae6b0c3aae4f89b9eef8e00f1cb4efd2b76e31be4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / tradeodds_langchain-0.1.0-py3-none-any.whl

Download URL tradeodds_langchain-0.1.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50082c0e691094fbc8bf38d256b2cb05c37f0d20e9e67d3ec76d018c290d1d34
BLAKE2b-256 checksum
How to use checksums
c387a1d0c7a1ffa6c1bd8afffb3dcd4672111737a1fb6929d1cf4669deedec0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page