Add futures_quote tool: CBOT price + change since open + on day

New futures_quote(commodity, delivery?) tool wraps the new /api/data/futures
endpoint: reports latest price, today's session open, prior settle, and both
moves (since open and on the day). With a delivery month it resolves the listed
contract; without it, the continuous nearby. Adds client.futures(), fmt_futures(),
tests, and a CHANGELOG entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-29 15:36:56 -04:00
parent 61c1736539
commit 0c9bc3b328
6 changed files with 159 additions and 0 deletions
+25
View File
@@ -64,6 +64,31 @@ def best_local_bid(
return fmt.fmt_best(commodity, payload)
@mcp.tool()
def futures_quote(
commodity: Annotated[
str, Field(description="Grain: 'corn', 'soy' (soybeans), or 'wheat'.")
],
delivery: Annotated[
str | None,
Field(description="Delivery month (e.g. 'Jul 2026') to resolve the listed "
"contract. Omit for the continuous nearby."),
] = None,
) -> str:
"""CBOT futures price and change for a commodity (optionally one delivery month).
Reports the latest price, today's session open, the prior day's close, and
both moves: change since the open and change on the day (vs the previous
settle). With `delivery` it resolves the listed contract that month prices
against; without it, the continuous nearby."""
cm = commodity.strip().lower()
with track("futures_quote", commodity=cm, delivery=delivery):
if cm not in VALID_GRAIN:
return f"`commodity` must be one of: {sorted(VALID_GRAIN)}"
payload = client.futures(commodity=cm, delivery=delivery)
return fmt.fmt_futures(payload)
@mcp.tool()
def current_lime_price() -> str:
"""Latest lime prices on file across all sources. Lime is rarely posted on