Metadata-Version: 2.5
Name: langchain-tickerlayer
Version: 0.1.0
Summary: LangChain tools for the TickerLayer market data API: quotes, snapshots, historical bars, symbols, market hours and bond yields.
Project-URL: Homepage, https://tickerlayer.com
Project-URL: Documentation, https://tickerlayer.com/docs/agent-frameworks#langchain
Project-URL: API reference, https://tickerlayer.com/docs/rest
Project-URL: Pricing, https://tickerlayer.com/pricing
Author-email: TickerLayer <info@tickerlayer.com>
License-Expression: MIT
License-File: LICENSE
Keywords: agents,crypto,forex,langchain,market data,stocks,tickerlayer,tools
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: langchain-core<2,>=0.3.15
Requires-Dist: tickerlayer<0.2,>=0.1.0
Description-Content-Type: text/markdown

# langchain-tickerlayer

LangChain tools for the [TickerLayer](https://tickerlayer.com) market data API. They give an agent
quotes, trades, daily snapshots and historical bars for stocks, ETFs, indices, forex, crypto,
commodities and perpetual futures, plus government bond yields and market hours. Every tool only
reads data.

## Installation

```bash
pip install -U langchain-tickerlayer
```

Create a [TickerLayer account](https://tickerlayer.com/signup), copy your API key from the dashboard
and set it as an environment variable:

```bash
export TICKERLAYER_API_KEY="your-key"
```

The free plan covers crypto, forex and US stocks; other asset classes need a
[paid plan](https://tickerlayer.com/pricing).

## Use with an agent

The agent below also needs LangChain and a model package, here
`pip install -U langchain langchain-anthropic` with `ANTHROPIC_API_KEY` set.

```python
from langchain.agents import create_agent
from langchain_tickerlayer import TickerLayerToolkit

tools = TickerLayerToolkit().get_tools()
agent = create_agent("anthropic:claude-sonnet-5-5", tools)

result = agent.invoke({"messages": [{"role": "user", "content": "How is BTCUSD doing today?"}]})
print(result["messages"][-1].content)
```

Any chat model with tool calling works. Each tool can also be used on its own:

```python
from langchain_tickerlayer import TickerLayerSnapshotTool

snapshot = TickerLayerSnapshotTool()
print(snapshot.invoke({"asset_class": "stocks", "symbol": "US:KO"}))
```

Tools return the API's JSON as a string. Errors (an unknown symbol, a plan that does not include
the data, a rate limit) come back to the agent as text instead of raising.

## Tools

| Tool | Class | Returns |
| --- | --- | --- |
| `get_snapshot` | `TickerLayerSnapshotTool` | Last trade, quote, previous close and daily change |
| `get_quote` | `TickerLayerQuoteTool` | Latest bid and ask |
| `get_last_trade` | `TickerLayerLastTradeTool` | Most recent trade: price, size, timestamp |
| `get_previous_close` | `TickerLayerPreviousCloseTool` | Previous daily bar, or the last settled intraday bar |
| `get_history` | `TickerLayerHistoryTool` | OHLCV bars between two UTC dates (minute, hour, day) |
| `list_symbols` | `TickerLayerListSymbolsTool` | Symbols the key can read in an asset class, with a filter |
| `get_market_status` | `TickerLayerMarketStatusTool` | Open, closed, pre-market or post-market by region |
| `get_market_sessions` | `TickerLayerMarketSessionsTool` | Session windows for a market or symbol on a date |
| `get_market_holidays` | `TickerLayerMarketHolidaysTool` | Holiday closures and early closes |
| `get_bond_yield` | `TickerLayerBondYieldTool` | Latest government bond yield, such as `US:10Y` |

The names and arguments match the tools of the hosted
[TickerLayer MCP server](https://tickerlayer.com/docs/mcp), so an agent behaves the same with either.

## Symbols

Stocks use a country prefix (`US:KO`, `DE:SAP`), crypto and forex use joined pairs (`BTCUSD`,
`EURUSD`), commodities use codes such as `XAUUSD`, indices use region codes (`US500`), ETFs use the
fund ticker in the `etfs` asset class (`SPY`), and perpetual futures use USDT-quoted codes
(`BTCUSDT`). `list_symbols` returns what the key can read.

## Options

`TickerLayerToolkit` and every tool accept `api_key` (instead of the environment variable) and
`base_url`. Tools from one toolkit share a single HTTP client pair.

## Links

- [Agent framework examples](https://tickerlayer.com/docs/agent-frameworks)
- [REST API reference](https://tickerlayer.com/docs/rest)
- [Rate limits](https://tickerlayer.com/docs/limits)
- [Pricing](https://tickerlayer.com/pricing)

Market data from TickerLayer is derived data, not exchange data.

## License

MIT
