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
+23
View File
@@ -71,6 +71,29 @@ def test_get_drops_none_params(monkeypatch):
assert captured["params"] == {"commodity": "corn"}
def test_futures_endpoint_params(monkeypatch):
client = _reload_client(monkeypatch)
captured = {}
class FakeResp:
status_code = 200
text = ""
def json(self): return {"quote": None}
def fake_get(url, params=None, timeout=None, headers=None):
captured["url"] = url
captured["params"] = dict(params or {})
return FakeResp()
monkeypatch.setattr(client.httpx, "get", fake_get)
client.futures(commodity="corn", delivery="Jul 2026")
assert captured["url"].endswith("/api/data/futures")
assert captured["params"] == {"commodity": "corn", "delivery": "Jul 2026"}
# delivery omitted → dropped
client.futures(commodity="corn")
assert captured["params"] == {"commodity": "corn"}
def test_history_without_commodity_drops_param(monkeypatch):
client = _reload_client(monkeypatch)
captured = {}