nautechsystems/nautilus_trader · error · anyhow::Error
Failed to fetch CFM position '{product_id}': {e}
Error message
Failed to fetch CFM position '{product_id}': {e} What it means
This error wraps a failure from the single-position Coinbase `get_cfm_position(product_id)` call, made when resolving the position status for one CFM instrument; the message includes the product_id queried. It means the per-product futures position lookup failed — unknown product, missing futures entitlement, auth, network, or API error.
Source
Thrown at crates/adapters/coinbase/src/http/client.rs:1525
/// Fetches a single CFM futures position and returns a position status
/// report when the venue reports a non-flat position.
///
/// # Errors
///
/// Returns an error when the HTTP request fails or the position cannot be
/// parsed.
pub async fn request_position_status_report(
&self,
account_id: AccountId,
instrument_id: InstrumentId,
) -> anyhow::Result<Option<PositionStatusReport>> {
let product_id = instrument_id.symbol.as_str();
let response = self
.inner
.get_cfm_position(product_id)
.await
.map_err(|e| anyhow::anyhow!("Failed to fetch CFM position '{product_id}': {e}"))?;
let instrument = self
.get_or_fetch_instrument(response.position.product_id)
.await?;
let ts_init = self.ts_now();
let report =
parse_cfm_position_status_report(&response.position, &instrument, account_id, ts_init)?;
Ok(Some(report))
}
/// Modifies an existing GTC order's price, size, or stop price.
///
/// Coinbase's `/orders/edit` endpoint is documented to accept edits on
/// these fields for supported order configurations (primarily LIMIT
/// GTC). At least one of `price`, `quantity`, or `trigger_price` must
/// be supplied.
///
/// # ErrorsView on GitHub (pinned to 18893faf8b)
Solutions
- Verify the instrument_id symbol matches a valid Coinbase futures product id.
- Confirm you are not querying a spot instrument via the CFM endpoint.
- Check futures entitlement and API key scopes for the account.
- Retry transient errors with backoff.
- Log the product_id and inner error to distinguish not-found from auth/network failures.
Example fix
// before: any CFM lookup failure is fatal
let report = client.request_cfm_position_status_report(instrument_id, account_id).await?;
// after: tolerate missing position (flat)
let report = match client.request_cfm_position_status_report(instrument_id, account_id).await {
Ok(r) => r,
Err(e) if is_not_found(&e) => None,
Err(e) => return Err(e),
}; Defensive patterns
Strategy: validation
Validate before calling
let product_id = instrument_id.symbol.as_str();
if !is_cfm_product(product_id) {
anyhow::bail!("{product_id} is not a CFM futures product");
} Try / catch
match client.request_cfm_position_status_report(instrument_id, account_id).await {
Ok(report) => report,
Err(e) if is_retryable(&e) => retry_with_backoff(3, Duration::from_secs(1), || {
client.request_cfm_position_status_report(instrument_id, account_id)
}).await?,
Err(e) => { tracing::error!("CFM position '{product}' lookup failed: {e}"); return Err(e); }
} Prevention
- Map Nautilus instrument ids to CFM product ids via a validated registry.
- Only invoke CFM position lookups for known futures instruments.
- Check entitlements once at startup rather than per-call.
- Include the product_id in all CFM error logs.
When it happens
Trigger: Calling the single CFM position report method with an `instrument_id` whose symbol maps to a product_id not found on CFM (e.g. a spot symbol passed to the futures endpoint), or when the HTTP request fails due to auth/network/rate limits.
Common situations: Querying a spot instrument id through the CFM position API by mistake; instrument symbols not matching Coinbase futures product naming (e.g. BTC-PERP-INTX); account not enabled for futures; transient network failures.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- Failed to fetch CFM balance summary: {e}
- Failed to fetch CFM positions: {e}
- Failed to fetch products: {e}
- Failed to fetch order: {e}
- Failed to fetch fills: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1396f0b56bb25f23.
Report an issue: GitHub.