LangChain tools for Headless Oracle: signed market-state receipts for autonomous agents
Project description
langchain-headless-oracle
LangChain tools for Headless Oracle: signed market-state receipts for autonomous agents.
Note: SMA in this package denotes "Signed Market Attestation" — not Simple Moving Average.
Installation
pip install langchain-headless-oracle
Quickstart
from langchain_headless_oracle import (
MarketStatusTool,
MarketScheduleTool,
MarketStateVerifyTool,
)
# API key resolves from HEADLESS_ORACLE_API_KEY by default
# (or pass api_key=... to the constructor).
tools = [
MarketStatusTool(), # authenticated live receipt
MarketScheduleTool(), # keyless next open/close
MarketStateVerifyTool(), # keyless signature verification
]
Tools
MarketStatusTool
Returns a cryptographically signed Signed Market Attestation (SMA) receipt for one of 28 global exchanges.
- Status:
OPEN,CLOSED,HALTED, orUNKNOWN - Fail-closed:
UNKNOWNandHALTEDMUST be treated asCLOSED - Signed: Ed25519, 60-second TTL
- Authenticated: requires an API key (see API key resolution)
MarketScheduleTool
Returns upcoming open/close times for a global exchange. IANA timezone identifiers — DST is handled automatically. Keyless.
MarketStateVerifyTool
Cryptographically verifies an SMA receipt's Ed25519 signature against Headless Oracle's published public keys at /v5/keys. Keyless.
Returns {valid: bool, reason: str | null}. Fail reasons include INVALID_SIGNATURE, EXPIRED, MISSING_FIELDS, UNKNOWN_KEY, INVALID_JSON.
Verification example
The status → verify pattern: fetch a receipt, verify it before acting on it.
import json
from langchain_headless_oracle import MarketStatusTool, MarketStateVerifyTool
receipt_json = MarketStatusTool()._run("XNYS")
verify_json = MarketStateVerifyTool()._run(receipt_json)
verified = json.loads(verify_json)
if not verified["valid"]:
raise RuntimeError(f"Receipt rejected: {verified['reason']}")
receipt = json.loads(receipt_json)
if receipt["status"] != "OPEN":
raise RuntimeError(f"Market not open: {receipt['status']} — halting execution")
API key resolution
MarketStatusTool resolves an API key in this priority order:
HEADLESS_ORACLE_API_KEYenvironment variable.~/.headless_oracle/config.jsoncache.- (Opt-in only) auto-provision a free sandbox key from
https://headlessoracle.com/v5/sandbox.
Auto-provision is off by default — instantiate with auto_provision_sandbox=True to enable:
MarketStatusTool(auto_provision_sandbox=True)
When no key is available and auto-provision is off, the tool returns a fail-closed result instead of raising:
{"status": "UNKNOWN", "safe_to_execute": false, "error": "No API key found..."}
MarketScheduleTool and MarketStateVerifyTool do not require an API key.
Relationship to the Headless Oracle SDK
This package wraps the official headless_oracle Python SDK — all HTTP calls and Ed25519 verification are delegated to it.
This package supersedes the older headless-oracle-langchain package on PyPI, which will be deprecated.
Supported exchanges (28)
XNYS (NYSE), XNAS (NASDAQ), XLON (LSE), XJPX (Tokyo), XPAR (Paris), XHKG (Hong Kong), XSES (Singapore), XASX (Sydney), XBOM (BSE India), XNSE (NSE India), XSHG (Shanghai), XSHE (Shenzhen), XKRX (Seoul), XJSE (Johannesburg), XBSP (B3 Brazil), XSWX (Swiss), XMIL (Milan), XIST (Istanbul), XSAU (Riyadh), XDFM (Dubai), XNZE (Auckland), XHEL (Helsinki), XSTO (Stockholm), XCBT (CME), XNYM (NYMEX), XCBO (Cboe), XCOI (Coinbase 24/7), XBIN (Binance 24/7)
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_headless_oracle-0.1.0.tar.gz.
File metadata
- Download URL: langchain_headless_oracle-0.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef9d568c896a312c95a621d4f683e515765cf92d01cb7c3b959aad30b5d9b08
|
|
| MD5 |
1a04ce86b8ec04b2854e41a7977c4314
|
|
| BLAKE2b-256 |
fe280d62c0747e974f000dd83e7b6f8ade345f40d45baa7a324bc5e120b9d27d
|
File details
Details for the file langchain_headless_oracle-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_headless_oracle-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a611f28019f8424ba865ec9a31e0fd131b732d3f1a75408056ba3ebfee407d
|
|
| MD5 |
daeb0c92876e2aa851becbfafe47755e
|
|
| BLAKE2b-256 |
4c89d67d55ff7a5c7a8341768e9677cd22a3dd58bfeca8b96e68b389404c2222
|