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.1.tar.gz (17.7 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.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openbb_cftc-1.4.1.tar.gz
  • Upload date:
  • Size: 17.7 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.1.tar.gz
Algorithm Hash digest
SHA256 f575666cff83a3308558de16dd52fc24b339c9b2c8de9913fac57b5648a44e5d
MD5 442e0f1f60bbd20472fe2dfc8e924da3
BLAKE2b-256 e59aee99830947be3ccc8c9047771b0a3e76ea0aa24c0ae1768f8fd1def7fc6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openbb_cftc-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fb4b7146940d3b05ce30a3e9b5f455fc6448950652a0c3bbe1d3261c1993845d
MD5 840d610ddf3cc2cacf531ceac9f2fb8f
BLAKE2b-256 d5fd033ce80b91dce6e34ec3dac3fff40b7157dc87e2f1f6a38fc91a1617fce4

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