Skip to content

fix(models): normalize empty-string trade and position icons to None#97

Merged
cesarenaldi merged 1 commit into
mainfrom
fix/dev-264-empty-string-icons
Jun 11, 2026
Merged

fix(models): normalize empty-string trade and position icons to None#97
cesarenaldi merged 1 commit into
mainfrom
fix/dev-264-empty-string-icons

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Sparse historical rows serialize missing market icons as "". The activity models already normalize this to None (PR #94); the loose Trade model and the Position/ClosedPosition models still passed "" through to the public icon fields.

This adds an icon before-validator using the existing empty_string_to_none helper on those three models, so missing icons consistently surface as None across the data surface.

Live evidence: 48/500 trades and 2/143 positions with icon: "" for a wallet with sparse historical rows.

Linear: DEV-264. Counterpart of ts-sdk PR #124 (DEV-263).

Verification

  • New unit tests: empty icon parses to None on Trade, Position, and ClosedPosition; populated icons unchanged.
  • uv run pytest tests/unit -q: 1701 passed.
  • uv run ruff check ., uv run ruff format --check .: clean.
  • uv run pyright: 0 errors.
  • Live smoke: 500 trades (48 sparse) and 143 positions (2 sparse) parse with sparse icons as None.

Note

Low Risk
Parsing-only normalization on optional display fields; behavior change is limited to ""None with tests covering regressions.

Overview
Aligns missing market icon handling on the loose Trade model and Position / ClosedPosition with activity parsing: API rows that send icon: "" now surface as None instead of empty strings.

Each model gets a before validator on icon that delegates to the shared empty_string_to_none helper (same pattern as activity models after PR #94). Non-empty icon URLs are unchanged.

Unit tests cover empty vs populated icon on Trade, Position, and ClosedPosition.

Reviewed by Cursor Bugbot for commit 5949925. Bugbot is set up for automated code reviews on this repo. Configure here.

@cesarenaldi cesarenaldi merged commit 233cb2d into main Jun 11, 2026
7 checks passed
@cesarenaldi cesarenaldi deleted the fix/dev-264-empty-string-icons branch June 11, 2026 14:12
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.

1 participant