# CFTC Commitments of Traders and Revisions (`vespa-zzz/cftc-cot`) Actor

Get weekly Legacy, Disaggregated and TFF positions from the CFTC and detect revisions to previously reported contracts.

- **URL**: https://apify.com/vespa-zzz/cftc-cot.md
- **Developed by:** [Vespa ZZZ](https://apify.com/vespa-zzz) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CFTC Commitments of Traders and Revisions

Get weekly open interest and positions by trader category from the U.S. Commodity Futures Trading Commission (CFTC). Use the Actor to update a positioning dashboard, compare market exposure across weeks or alert when the CFTC revises a value used in a report.

### Input

Run with `{}` to retrieve the latest Disaggregated Futures Only rows for corn (`002602`), WTI crude oil (`067651`) and gold (`088691`).

| Input | Behavior |
| --- | --- |
| `reports` | Select one or more of the six official report variants below. The default is `disaggregated_futures_only`. |
| `contractCodes` | Up to 10 exact CFTC contract market codes as strings. An empty list includes all codes. Omitting this field for Disaggregated Futures Only with no name or group filter selects the three default contracts. |
| `marketNameContains` | Case-insensitive literal substring of the market and exchange name. |
| `commodityGroups` | Case-insensitive names such as `AGRICULTURE`, `NATURAL RESOURCES` or `FINANCIAL INSTRUMENTS`. Any listed group matches. |
| `from`, `to` | Inclusive CFTC report dates in `YYYY-MM-DD` format. |
| `latestOnly` | Defaults to `true`. Selects the latest date in bounds for each report, then applies the market filters. A valid filter can produce zero rows. Set to `false` for history. |
| `onlyNew` | Defaults to `false`. Set to `true` to emit first observations and revisions. |
| `stateKey` | Defaults to `default`. Use 1–50 letters, digits, underscores or hyphens to select the persistent monitoring baseline. |

History queries cover up to 52 weeks. With no `to`, the latest available date anchors the interval. With no `from`, the interval starts 52 weeks before the end date, counting the end date inclusively. Market filters are combined with AND.

| Report value | CFTC view |
| --- | --- |
| `disaggregated_futures_only` | [Disaggregated Futures Only (`72hh-3qpy`)](https://publicreporting.cftc.gov/d/72hh-3qpy) |
| `disaggregated_combined` | [Disaggregated Combined (`kh3c-gbw2`)](https://publicreporting.cftc.gov/d/kh3c-gbw2) |
| `legacy_futures_only` | [Legacy Futures Only (`6dca-aqww`)](https://publicreporting.cftc.gov/d/6dca-aqww) |
| `legacy_combined` | [Legacy Combined (`jun7-fc8e`)](https://publicreporting.cftc.gov/d/jun7-fc8e) |
| `tff_futures_only` | [Traders in Financial Futures (TFF) Futures Only (`gpe5-46if`)](https://publicreporting.cftc.gov/d/gpe5-46if) |
| `tff_combined` | [TFF Combined (`yw9f-hn96`)](https://publicreporting.cftc.gov/d/yw9f-hn96) |

Compare two weeks of futures-only and futures-and-options reports for euro FX.

```json
{
  "reports": ["tff_futures_only", "tff_combined"],
  "contractCodes": ["099741"],
  "from": "2026-11-10",
  "to": "2026-11-17",
  "latestOnly": false
}
```

Track weekly corn positions and revisions using a persistent baseline.

```json
{
  "reports": ["disaggregated_futures_only"],
  "contractCodes": ["002602"],
  "onlyNew": true,
  "stateKey": "corn-weekly"
}
```

### Output

The default dataset contains one row per report variant, contract market code and CFTC report date. `openInterestChange` is the CFTC's change from the preceding report. Positions use the CFTC's total across maturities. Within each category, `long`, `short` and `spreading` each expose `position`, `change`, `percentOfOpenInterest` and `traders`. Missing and unpublished measures are `null`. `fetchedAt` is the UTC retrieval timestamp.

Example corn snapshot with one of the position categories shown.

```json
{
  "reportType": "disaggregated_futures_only",
  "reportDate": "2026-11-17",
  "contractCode": "002602",
  "marketName": "CORN - CHICAGO BOARD OF TRADE",
  "commodityGroup": "AGRICULTURE",
  "openInterest": 1954229,
  "positions": {
    "producerMerchant": {
      "long": { "position": 466484, "change": 2645, "percentOfOpenInterest": 23.9, "traders": 353 },
      "short": { "position": 838543, "change": -24424, "percentOfOpenInterest": 42.9, "traders": 346 },
      "spreading": { "position": null, "change": null, "percentOfOpenInterest": null, "traders": null }
    }
  },
  "fetchedAt": "2026-11-22T00:00:00.000Z",
  "source": "https://publicreporting.cftc.gov/resource/72hh-3qpy.json",
  "changeType": "snapshot"
}
```

### Monitoring

With `onlyNew`, first observations have `changeType: "new"`. Changes to previously emitted rows have `changeType: "revision"`, `rowHash`, `previousRowHash` and `changedFields`. Each changed field has a dotted path and its previous and current values, for example `{"field":"positions.managedMoney.long.position","previous":100,"current":110}`. Unchanged rows are skipped.

With `latestOnly`, each run also rechecks dates it already reported within `from` and `to`. Older dates become eligible for first observations in history mode. Revisions reflect values observed in matching CFTC rows, so intermediate versions between runs and withdrawn rows produce no event. Use the same `stateKey` across runs and distinct keys for independent monitors. In local testing, run a given key sequentially.

When the pay-per-event spending limit is reached, the run stops with a warning. Monitoring retries the remaining rows on the next run. In `latestOnly` mode, the interrupted report date stays eligible even if a newer report is published in the meantime.

The Actor commits the baseline after all pages and dataset writes succeed. If a run fails, the next run compares against the last committed baseline. Consumers should read datasets from successful runs.

### Source and terms

Data source is the U.S. Commodity Futures Trading Commission's Public Reporting Environment. The Actor selects and normalizes published aggregate figures. It is an independent implementation. CFTC requests acknowledgment when reusing its public-domain government information. [CFTC COT reports](https://publicreporting.cftc.gov/stories/s/r4w3-av2u) · [CFTC Web Policy](https://www.cftc.gov/WebPolicy/index.htm)

The Actor uses the anonymous Socrata API. It sends requests sequentially with at least 2.3 seconds after each response and honors `Retry-After` on retries. [Socrata rate limits](https://dev.socrata.com/docs/app-tokens.html) · [CFTC robots.txt](https://publicreporting.cftc.gov/robots.txt)

### Local development

Run `npm ci`, `npm test`, `apify validate-schema` and `apify run --purge` from this directory with Node.js 22. The unit tests run without network access using responses from five CFTC API calls.

### 日本語概要

米商品先物取引委員会（CFTC）が公表する週次の建玉を、レポート種別・契約コード・報告日で取得します。既定では Disaggregated Futures Only の最新週からトウモロコシ、WTI 原油、金を取得します。`onlyNew` を有効にして同じ `stateKey` で定期実行すると、新規行と報告済みの行に対する訂正が出力されます。

# Actor input Schema

## `reports` (type: `array`):

Select one or more report variants. Combined reports include futures and options.

## `contractCodes` (type: `array`):

Match up to 10 exact codes. Keep leading zeros. When omitted for Disaggregated Futures Only with no market or group filters, the Actor uses corn, WTI crude oil and gold. An explicit empty list includes all codes.

## `marketNameContains` (type: `string`):

Match a literal substring of the CFTC market and exchange name, ignoring letter case.

## `commodityGroups` (type: `array`):

Match any listed CFTC group name, ignoring letter case. Examples are AGRICULTURE, NATURAL RESOURCES and FINANCIAL INSTRUMENTS.

## `from` (type: `string`):

Inclusive first report date in YYYY-MM-DD format. A historical run with no start date covers up to 52 weeks through the end date.

## `to` (type: `string`):

Inclusive last report date in YYYY-MM-DD format. When omitted, the latest available CFTC date anchors the range for each report.

## `latestOnly` (type: `boolean`):

Select the most recent report date in bounds for each report before applying market filters. Monitoring also checks previously reported dates in bounds for revisions. Turn off to retrieve history.

## `onlyNew` (type: `boolean`):

Emit each tracked report, contract and date on first observation or when published values change. Use the same state key on subsequent runs.

## `stateKey` (type: `string`):

Name of the baseline to use in monitoring mode. Use 1 to 50 letters, digits, underscores or hyphens.

## Actor input object example

```json
{
  "reports": [
    "disaggregated_futures_only"
  ],
  "contractCodes": [
    "002602",
    "067651",
    "088691"
  ],
  "latestOnly": true,
  "onlyNew": false,
  "stateKey": "default"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "reports": [
        "disaggregated_futures_only"
    ],
    "contractCodes": [
        "002602",
        "067651",
        "088691"
    ],
    "latestOnly": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("vespa-zzz/cftc-cot").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "reports": ["disaggregated_futures_only"],
    "contractCodes": [
        "002602",
        "067651",
        "088691",
    ],
    "latestOnly": True,
}

# Run the Actor and wait for it to finish
run = client.actor("vespa-zzz/cftc-cot").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "reports": [
    "disaggregated_futures_only"
  ],
  "contractCodes": [
    "002602",
    "067651",
    "088691"
  ],
  "latestOnly": true
}' |
apify call vespa-zzz/cftc-cot --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vespa-zzz/cftc-cot"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/G1RGN32bnfBdidrYK/builds/ay3whvmNthTWogn1g/openapi.json
