Skip to content

Conversation

@rickyking
Copy link
Contributor

@rickyking rickyking commented Jan 9, 2026

Problem

When using get_account_balances, get_activities, or other methods that internally call security_id_to_symbol, certain securities cause the API to fail (as they are delisted) with:

WSApiException: GraphQL query failed: FetchSecurityMarketData; 
Response: {'errors': [{'message': 'UNPROCESSABLE_ENTITY'}]}

This is noticeable with self-directed RRSP/TFSA accounts, certain ETFs, and some crypto positions.

Solution

Wrap the get_security_market_data call in a try/except to catch WSApiException and gracefully fall back to the bracketed security ID.

Changes

  • Added try/except around get_security_market_data call (+4 lines)
  • Changed market_data['stock'] to market_data.get('stock') for safer access

Some securities (e.g., delisted, private, or certain ETFs) fail when
the FetchSecurityMarketData GraphQL query returns UNPROCESSABLE_ENTITY.

This change wraps the get_security_market_data call in a try/except
block to catch WSApiException and gracefully fall back to returning
the bracketed security ID instead of crashing.
@gboudreau gboudreau merged commit 8a85011 into gboudreau:main Jan 9, 2026
gboudreau added a commit to gboudreau/ws-api-php that referenced this pull request Jan 9, 2026
@gboudreau
Copy link
Owner

This is integrated in 0.28.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants