Skip to main content

cotbias

PyPI version Python versions License: MIT

Official Python SDK and Model Context Protocol (MCP) Server for the CFTC Commitment of Traders (COT) Bias Terminal Quant API.

Access institutional positioning metrics, 156-week historical timeseries across multiple CFTC report families, cross-market positioning screeners, and AI-driven market regime & attribution analysis directly in Python and in AI assistants (Claude Desktop, Cursor, Cline).


Installation

Core SDK (Lightweight, zero Pandas/NumPy overhead)

pip install cotbias

With Pandas support (DataFrames)

pip install "cotbias[pandas]"

With MCP Server (Claude Desktop, Cursor, AI agents)

pip install "cotbias[mcp]"

Or install all features:

pip install "cotbias[all]"

🤖 Model Context Protocol (MCP) Server

Connect your Quant API key directly into Claude Desktop or Cursor IDE:

{
  "mcpServers": {
    "cotbias": {
      "command": "uvx",
      "args": ["cotbias[mcp]", "cotbias-mcp"],
      "env": {
        "COT_API_KEY": "cot_live_YOUR_ACTUAL_API_KEY"
      }
    }
  }
}

See docs/mcp.md for full configuration details, available tools (get_market_snapshot, get_ai_inference, get_timeseries, scan_markets, list_markets), and quota preservation caching.


Quickstart

Get your API key at cot-bias-terminal.com. Set it as an environment variable:

export COT_API_KEY="cot_live_..."

1. Fetch Positioning Timeseries into Pandas

from cotbias import CotClient

with CotClient() as cot:
    # Pull 156 weeks of combined futures & options data for Gold (GC) as a Pandas DataFrame
    df = cot.timeseries.get("GC", contract_type="futopt", lookback_weeks=156, as_dataframe=True)
    print(df[["commercial_net", "cot_52w_commercial", "z_score_156w_commercial"]].tail())

2. AI Market Regime & Qualitative Attribution

from cotbias import CotClient

with CotClient() as cot:
    inf = cot.inference.get("GC")
    print(f"Asset: {inf.symbol}")
    print(f"Bias: {inf.ai_bias_score} | Regime: {inf.regime_status}")
    print(f"Primary Driver: {inf.primary_driver} ({inf.momentum})")
    print(f"Macro Rationale: {inf.qualitative_attribution.macro_rationale}")

3. Cross-Market Positioning Screener

from cotbias import CotClient

with CotClient() as cot:
    # Find all markets where AI bias is Bullish and smart money is entering new longs
    res = cot.screener.scan(ai_bias_score="Bullish", momentum="New Longs (OI Expanding)")
    for item in res.results:
        print(f"{item.symbol}: {item.ai_bias_score} ({item.regime_status})")

4. Automatic Retries & Network Resilience

The SDK automatically retries transient 5xx errors, network timeouts, and transient rate limits with exponential backoff and jitter:

from cotbias import CotClient

# Default max_retries=3. Set to 0 to disable or adjust for custom pipelines
with CotClient(max_retries=5, timeout=20.0) as cot:
    markets = cot.markets.list()

5. Asynchronous Client (FastAPI / Bots)

import asyncio
from cotbias import AsyncCotClient


async def main():
    async with AsyncCotClient() as cot:
        # Fetch multiple markets concurrently
        gold_task = cot.timeseries.get("GC")
        sp500_task = cot.timeseries.get("ES")
        gold_ts, sp500_ts = await asyncio.gather(gold_task, sp500_task)
        print("Gold rows:", gold_ts.count, "| S&P 500 rows:", sp500_ts.count)


asyncio.run(main())

Error Handling

All API errors inherit from CotApiError:

from cotbias import CotClient
from cotbias.exceptions import (
    AuthenticationError,
    NotFoundError,
    PermissionDeniedError,
    RateLimitExceededError,
)

try:
    with CotClient() as cot:
        cot.timeseries.get("INVALID_TICKER")
except NotFoundError as e:
    print(f"Asset not found: {e.message}")
except RateLimitExceededError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds.")
except AuthenticationError as e:
    print("Invalid or missing API key.")

License

MIT License. Developed for quantitative traders, portfolio managers, and market researchers.

Metadata

Release files for cotbias 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cotbias 0.2.0
File Size Uploaded Provenance Actions
cotbias-0.2.0.tar.gz 164.3 kB With provenance Details for cotbias-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cotbias 0.2.0
File Interpreter ABI Platform Actions
cotbias-0.2.0-py3-none-any.whl Python 3 none any Details for cotbias-0.2.0-py3-none-any.whl

Total release size: 184.6 kB

Release files / cotbias-0.2.0.tar.gz

Download URL cotbias-0.2.0.tar.gz
Size 164.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6143da03b9374ea9b741dbb6f6bf69542decb3c41f88de879e378f1e8ccfd97c
BLAKE2b-256 checksum
How to use checksums
a39e59cd9e427d1b22274f5a74bef363e62f81b6a74b05bd7065a93b954cd85c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / cotbias-0.2.0-py3-none-any.whl

Download URL cotbias-0.2.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97760e1cb7aa87de4aa36fa925acffa2824294858ef40d03f29d32af1f2ef579
BLAKE2b-256 checksum
How to use checksums
9227f9800e4e12f9f3b547248d6b267f9828f6bbbf95e5196ad9a55ed507140a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for cotbias 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cotbias-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page