Resources Reference¶
Resource client modules mapping to COT Bias API endpoints.
AsyncInferenceResource ¶
Asynchronous resource for querying current week AI positioning regimes and attribution.
Initialize the async inference resource with an active async HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
Active asynchronous HTTP client session. |
required |
Source code in src/cotbias/resources/inference.py
get
async
¶
Fetch current week's AI positioning regime and macro attribution asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Asset ticker symbol (e.g., 'GC', 'ES', 'CL', '6E', 'ZB'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
InferenceSchema
|
class: |
InferenceSchema
|
institutional bias score, regime status, primary driver, momentum, |
|
InferenceSchema
|
crowdedness risk, and qualitative macro attribution rationale. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
NotFoundError
|
If the market symbol is not found (HTTP 404). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/inference.py
InferenceResource ¶
Synchronous resource for querying current week AI positioning regimes and attribution.
Initialize the inference resource with an active HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
Active synchronous HTTP client session. |
required |
Source code in src/cotbias/resources/inference.py
get ¶
Fetch current week's AI positioning regime and macro attribution for an asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Asset ticker symbol (e.g., 'GC', 'ES', 'CL', '6E', 'ZB'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
An |
InferenceSchema
|
class: |
InferenceSchema
|
institutional bias score, regime status, primary driver, momentum, |
|
InferenceSchema
|
crowdedness risk, and qualitative macro attribution rationale. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
NotFoundError
|
If the market symbol is not found (HTTP 404). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/inference.py
AsyncMarketsResource ¶
Asynchronous resource for querying the catalog of tracked futures contracts.
Initialize the async markets resource with an active async HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
Active asynchronous HTTP client session. |
required |
Source code in src/cotbias/resources/markets.py
list
async
¶
List tracked futures contracts asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sector
|
str | None
|
Optional sector filter: |
None
|
Returns:
| Type | Description |
|---|---|
list[MarketMetadata]
|
A list of :class: |
list[MarketMetadata]
|
symbol, descriptive name, CFTC commodity code, sector, and supported report types. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/markets.py
MarketsResource ¶
Synchronous resource for querying the catalog of tracked futures contracts.
Initialize the markets resource with an active HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
Active synchronous HTTP client session. |
required |
Source code in src/cotbias/resources/markets.py
list ¶
List tracked futures contracts with sector and CFTC report mappings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sector
|
str | None
|
Optional sector filter: |
None
|
Returns:
| Type | Description |
|---|---|
list[MarketMetadata]
|
A list of :class: |
list[MarketMetadata]
|
symbol, descriptive name, CFTC commodity code, sector, and supported report types. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/markets.py
AsyncScreenerResource ¶
Asynchronous resource for multi-market positioning scans.
Initialize the async screener resource with an active async HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
Active asynchronous HTTP client session. |
required |
Source code in src/cotbias/resources/screener.py
scan
async
¶
scan(ai_bias_score: str | None = ..., crowdedness_risk: str | None = ..., momentum: str | None = ..., cot_positioning: str | None = ..., as_dataframe: Literal[True] = ...) -> pd.DataFrame
scan(ai_bias_score: str | None = None, crowdedness_risk: str | None = None, momentum: str | None = None, cot_positioning: str | None = None, as_dataframe: bool = True) -> pd.DataFrame | ScreenerResponse
Filter across all tracked futures markets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ai_bias_score
|
str | None
|
Filter by directional bias ('Bullish', 'Bearish', 'Neutral'). |
None
|
crowdedness_risk
|
str | None
|
Filter by positioning risk ('High Liquidation Risk', 'Balanced'). |
None
|
momentum
|
str | None
|
Filter by open interest dynamics ('New Longs', 'Short Covering'). |
None
|
cot_positioning
|
str | None
|
Filter by smart vs dumb positioning ('Convergence', 'Divergence'). |
None
|
as_dataframe
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame | ScreenerResponse
|
A Pandas DataFrame if |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/screener.py
ScreenerResource ¶
Synchronous resource for multi-market positioning scans.
Initialize the screener resource with an active HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
Active synchronous HTTP client session. |
required |
Source code in src/cotbias/resources/screener.py
scan ¶
scan(ai_bias_score: str | None = ..., crowdedness_risk: str | None = ..., momentum: str | None = ..., cot_positioning: str | None = ..., as_dataframe: Literal[True] = ...) -> pd.DataFrame
scan(ai_bias_score: str | None = None, crowdedness_risk: str | None = None, momentum: str | None = None, cot_positioning: str | None = None, as_dataframe: bool = True) -> pd.DataFrame | ScreenerResponse
Filter across all tracked futures markets based on positioning classifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ai_bias_score
|
str | None
|
Filter by directional bias (e.g. |
None
|
crowdedness_risk
|
str | None
|
Filter by positioning risk (e.g. |
None
|
momentum
|
str | None
|
Filter by open interest dynamics (e.g. |
None
|
cot_positioning
|
str | None
|
Filter by smart vs dumb positioning ( |
None
|
as_dataframe
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame | ScreenerResponse
|
A Pandas DataFrame if |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/screener.py
AsyncTimeseriesResource ¶
Asynchronous resource for querying historical weekly COT positioning timeseries.
Initialize the async timeseries resource with an active async HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
AsyncClient
|
Active asynchronous HTTP client session. |
required |
Source code in src/cotbias/resources/timeseries.py
get
async
¶
get(symbol: str, contract_type: ContractType = ..., lookback_weeks: int = ..., report: ReportType = ..., as_dataframe: Literal[True] = ...) -> pd.DataFrame
get(symbol: str, contract_type: str = 'futopt', lookback_weeks: int = 156, report: str = 'legacy', as_dataframe: bool = True) -> pd.DataFrame | TimeseriesResponse
Fetch historical weekly positioning metrics for a market asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Asset ticker symbol (e.g., 'GC', 'ES', 'CL', '6E', 'ZB'). |
required |
contract_type
|
str
|
Position breakdown type:
- |
'futopt'
|
lookback_weeks
|
int
|
Number of weekly CFTC reports to retrieve (1 to 156, default 156). |
156
|
report
|
str
|
CFTC report family ('legacy', 'disaggregated', 'tff', 'supplemental'). |
'legacy'
|
as_dataframe
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame | TimeseriesResponse
|
A DatetimeIndex-sorted Pandas DataFrame if |
DataFrame | TimeseriesResponse
|
|
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
NotFoundError
|
If symbol is unrecognized or report data is missing (HTTP 404). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |
Example
Source code in src/cotbias/resources/timeseries.py
TimeseriesResource ¶
Synchronous resource for querying historical weekly COT positioning timeseries.
Initialize the timeseries resource with an active HTTP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
Active synchronous HTTP client session. |
required |
Source code in src/cotbias/resources/timeseries.py
get ¶
get(symbol: str, contract_type: ContractType = ..., lookback_weeks: int = ..., report: ReportType = ..., as_dataframe: Literal[True] = ...) -> pd.DataFrame
get(symbol: str, contract_type: str = 'futopt', lookback_weeks: int = 156, report: str = 'legacy', as_dataframe: bool = True) -> pd.DataFrame | TimeseriesResponse
Fetch historical weekly positioning metrics for a market.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Asset ticker symbol (e.g., 'GC', 'ES', 'CL', '6E', 'ZB'). |
required |
contract_type
|
str
|
Position breakdown type:
- |
'futopt'
|
lookback_weeks
|
int
|
Number of weekly CFTC reports to retrieve (1 to 156, default 156). |
156
|
report
|
str
|
CFTC report family:
- |
'legacy'
|
as_dataframe
|
bool
|
When |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame | TimeseriesResponse
|
A DatetimeIndex-sorted Pandas DataFrame if |
DataFrame | TimeseriesResponse
|
|
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If API key is missing or invalid (HTTP 401). |
PermissionDeniedError
|
If account tier lacks access (HTTP 403). |
NotFoundError
|
If symbol is unrecognized or report data is missing (HTTP 404). |
RateLimitExceededError
|
If daily request quota is exceeded (HTTP 429). |
ServerError
|
If upstream COT Bias servers return an error (HTTP 5xx). |
CotApiError
|
Base exception for any unexpected API errors. |