Skip to content

COTClient

Victor Kaiuki edited this page Jun 20, 2026 · 2 revisions

COTClient

The COTClient is the main entry point for the SDK.

from cftc_cot import COTClient

# Initialize (unauthenticated, rate-limited)
client = COTClient()

# Initialize with API token (recommended for higher limits)
client = COTClient(app_token="YOUR_TOKEN")

# With caching (see the Caching guide)
client = COTClient(cache="memory")
client = COTClient(cache="disk", cache_dir="./cot_cache", cache_ttl=86400)

Constructor Parameters

Parameter Default Description
app_token None Socrata API app token for higher rate limits.
cache None "memory", "disk", a COTCache instance, or None. See Caching.
cache_dir "./cot_cache" Directory for the disk cache backend.
cache_ttl 86400 Cache time-to-live in seconds (24h).

The configured token and cache are automatically applied to every query the client creates.

Factory Methods (returns COTQuery instances)

  • client.legacy(): Legacy Combined
  • client.legacy_futures(): Legacy Futures Only
  • client.disaggregated(): Disaggregated Combined
  • client.disaggregated_futures(): Disaggregated Futures Only
  • client.tff(): TFF Combined
  • client.tff_futures(): TFF Futures Only

Convenience Methods

  • client.latest(dataset, market): Fetch latest row.
  • client.history(dataset, market, weeks=52): Fetch historical data.
  • client.list_markets(dataset): Return unique list of all available markets.

Clone this wiki locally