cotbias
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
Python SDK (Batteries-included with Pandas)
pip install cotbias
With Model Context Protocol (MCP) Server
For connecting into Claude Desktop, Cursor, or Cline:
pip install "cotbias[mcp]"
🤖 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 the MCP Documentation 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cotbias-0.2.2.tar.gz | 210.7 kB | With provenance | Details for cotbias-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cotbias-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for cotbias-0.2.2-py3-none-any.whl |
Total release size: 230.8 kB
Release files / cotbias-0.2.2.tar.gz
| Download URL | cotbias-0.2.2.tar.gz |
|---|---|
| Size | 210.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f6235a4835915f5c0e59dd8176d8eacc992f09dc5667dcd51f280a855abcc90
|
|
BLAKE2b-256 checksum How to use checksums |
ca96ac43db0078f6d3de27b4ef4deab7ac4873b95196606c90ba7f345f95fd41
|
| 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 logRelease files / cotbias-0.2.2-py3-none-any.whl
| Download URL | cotbias-0.2.2-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8063991fc8d1ede39a1f79830cf87e32bd9364aa9186726aa71a9f2e0d59d6a1
|
|
BLAKE2b-256 checksum How to use checksums |
2eaa2acc3d4b2195c7c0fda8136e17426ba172a0c809eedb6de146c76d218315
|
| 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 logSecurity for cotbias 0.2.2
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.
Attestation for cotbias-0.2.2.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 logA 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.