Skip to main content

The mission of the Commodity Futures Trading Commission (CFTC) is to promote the integrity, resilience, and vibrancy of the U.S. derivatives markets through sound regulation.

Project description

CFTC Provider Extension

This package provides full access to the CFTC Commitment of Traders database. Reports are fetched by CFTC Code (e.g. 13874+) and returns the full history of the contract.

Installation

Install into a Python environment (3.10 - 3.14) from PyPI with:

pip install openbb-cftc

Then build the Python static assets:

openbb-build

Credentials

Credentials are not required, but your IP address may be subject to throttling limits.

API requests made using an application token are not throttled.

Create a free account here: https://evergreen.data.socrata.com/signup

Then, generate the app_token by signing in with the credentials here: https://publicreporting.cftc.gov/profile/edit/developer_settings.

Credentials Key

If adding a token, use cftc_app_token as the key in the user_settings.json file. The value expected value is the app_token and not the secret or api_key.

The token can be set as an environment variable:

CFTC_APP_TOKEN

Coverage

This extension provides a dedicated router module with two endpoints, and one OpenBB Workspace application.

  • obb.cftc.cot
  • obb.cftc.cot_search

Usage

The package can be used as a Python module, or a REST API.

REST API

Start the server over localhost with:

openbb-api

Python

from openbb import obb

search_results = obb.cftc.cot_search(query="gold")

print(search_results.to_df())
code name category subcategory commodity_name contract_units
CFTC_088691 GOLD NATURAL RESOURCES PRECIOUS METALS GOLD (CONTRACTS OF 100 TROY OUNCES)
CFTC_088LM1 GOLD -1 TROY OUNCE NATURAL RESOURCES PRECIOUS METALS GOLD (1 troy ounce x $2,300)
CFTC_088695 MICRO GOLD NATURAL RESOURCES PRECIOUS METALS GOLD (CONTRACTS OF 10 TROY OUNCES)
report = obb.cftc.cot(code="CFTC_088695", measure="percent_of_oi", limit=4)
print(report.to_df().T)
2026-03-03 2026-03-10 2026-03-17 2026-03-24
open_interest_all 60933 58119 64124 71998
open_interest_pct_all 1 1 1 1
open_interest_pct_non_commercial_long_all 0.186 0.18 0.168 0.285
open_interest_pct_non_commercial_short_all 0.527 0.546 0.555 0.515
open_interest_pct_non_commercial_spread 0.058 0.06 0.078 0.124
open_interest_pct_commercial_long_all 0.088 0.095 0.091 0.083
open_interest_pct_commercial_short_all 0 0 0 0
open_interest_pct_total_reportable_long_all 0.333 0.335 0.336 0.492
open_interest_pct_total_reportable_short 0.585 0.606 0.632 0.64
open_interest_pct_non_reportable_long_all 0.667 0.665 0.664 0.508
open_interest_pct_non_reportable_short_all 0.415 0.394 0.368 0.36

Report Types

Reports can be filtered by measure, or include all reported fields. Report types come as 'Futures Only', or 'Combined' (futures and options combined positions), selectable by setting the futures_only boolean parameter.

Legacy

The Legacy report is broken down by exchange with reported open interest further broken down into three trader classifications: commercial, non-commercial and non-reportable.

Disaggregated

The Disaggregated reports are broken down by Agriculture and Natural Resource contracts. The Disaggregated reports break down reportable open interest positions into four classifications: Producer/Merchant, Swap Dealers, Managed Money and Other Reportables.

Financial

The Traders in Financial Futures (TFF) report includes financial contracts. The TFF report breaks down the reported open interest into five classifications: Dealer, Asset Manager, Leveraged Money, Other Reportables and Non-Reportables.

Supplemental

The Supplemental report includes 13 select agricultural commodity contracts for combined futures and options positions. Supplemental reports break down the reportable open interest positions into three trader classifications: non-commercial, commercial, and index traders.

Visit the CFTC website for detailed descriptions of reports and classification methodology.

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

openbb_cftc-1.4.2.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

openbb_cftc-1.4.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file openbb_cftc-1.4.2.tar.gz.

File metadata

  • Download URL: openbb_cftc-1.4.2.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.11 Darwin/25.5.0

File hashes

Hashes for openbb_cftc-1.4.2.tar.gz
Algorithm Hash digest
SHA256 86c363d39b4b84b3fbf933dc33b491423154e3cf997ed8abd27d435dc4a7fc3e
MD5 cf87d00b5b6223dfec6231bd0a6db0e0
BLAKE2b-256 526c082d92dd18f043cf7559fc8b5d554ec5abb20ffa351bf362f7d17ea73880

See more details on using hashes here.

File details

Details for the file openbb_cftc-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: openbb_cftc-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.13.11 Darwin/25.5.0

File hashes

Hashes for openbb_cftc-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6942da9f2cec714befde85e1f7bc65f4ee6fc8f22a17cc1e0ddd278d522df79
MD5 2ca7ed69e9e76785ff142cb7ea6c51f9
BLAKE2b-256 766640152524b60c4dee83919a0a11d077275a1e753745bc153d9e272ba653aa

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