Skip to main content

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, or UNKNOWN
  • Fail-closed: UNKNOWN and HALTED MUST be treated as CLOSED
  • 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:

  1. HEADLESS_ORACLE_API_KEY environment variable.
  2. ~/.headless_oracle/config.json cache.
  3. (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_headless_oracle-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_headless_oracle-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_headless_oracle-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langchain_headless_oracle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ef9d568c896a312c95a621d4f683e515765cf92d01cb7c3b959aad30b5d9b08
MD5 1a04ce86b8ec04b2854e41a7977c4314
BLAKE2b-256 fe280d62c0747e974f000dd83e7b6f8ade345f40d45baa7a324bc5e120b9d27d

See more details on using hashes here.

File details

Details for the file langchain_headless_oracle-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_headless_oracle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54a611f28019f8424ba865ec9a31e0fd131b732d3f1a75408056ba3ebfee407d
MD5 daeb0c92876e2aa851becbfafe47755e
BLAKE2b-256 4c89d67d55ff7a5c7a8341768e9677cd22a3dd58bfeca8b96e68b389404c2222

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