Skip to content

Remove backward-compatibility layer#10

Merged
arshka merged 3 commits into
mainfrom
refactor/remove-compat-layer
Mar 18, 2026
Merged

Remove backward-compatibility layer#10
arshka merged 3 commits into
mainfrom
refactor/remove-compat-layer

Conversation

@arshka
Copy link
Copy Markdown
Owner

@arshka arshka commented Mar 18, 2026

Summary

  • Delete _compat.py and all legacy field accessors, deprecated integer params, and conversion boilerplate across 14 files
  • Fix FillModel field naming (yes_price_fixedyes_price_dollars with AliasChoices for API compat)
  • Fix Orderbook quantity type (str | intstr), SettlementModel.pnl (floatDecimal)
  • Net: +80 / -935 = -855 lines

What was removed

Component Lines Description
_compat.py -148 CompatModel, convert_legacy_kwargs, conversion functions, legacy param dicts
test_compat.py -400 All compat-specific tests
_legacy_fields dicts -170 From 26 model classes across models.py and feed.py
convert_legacy_kwargs calls -80 From 14 call sites in portfolio.py and communications.py
Deprecated params -50 count, yes_price, no_price, reduce_by, contracts_limit, amount from all method signatures

What was fixed

  • FillModel.yes_price_fixedyes_price_dollars (consistent with every other model); API sends yes_price_fixed, handled by AliasChoices
  • Orderbook.yes_dollars type str | intstr (API always sends strings now)
  • SettlementModel.pnl uses Decimal instead of float() for currency math
  • async_usage.py example updated to use current field names
  • Web backend inlines cents_to_dollars with Decimal

Test plan

  • All 274 unit tests pass (0 warnings, down from 39 deprecation warnings)
  • All 100 integration tests pass against live demo API
  • Live API verification: BalanceModel, FillModel, MarketModel, OrderbookResponse all parse correctly
  • FillModel accepts both yes_price_fixed (from API) and yes_price_dollars (canonical) via AliasChoices

🤖 Generated with Claude Code

@arshka arshka changed the title Remove backward-compatibility layer (-855 lines) Remove backward-compatibility layer Mar 18, 2026
arshka and others added 3 commits March 18, 2026 16:01
…ines)

Drop the entire _compat.py module and all legacy field accessors, deprecated
integer params, and conversion boilerplate. The fixed-point migration is
complete — no need to maintain two parallel interfaces.

Key changes:
- Delete _compat.py (CompatModel, convert_legacy_kwargs, legacy param dicts)
- Strip _legacy_fields from all 26 model classes in models.py and feed.py
- Remove deprecated integer params from all method signatures (sync + async)
- Rename FillModel.yes_price_fixed → yes_price_dollars with AliasChoices
- Fix Orderbook quantity type: str|int → str (remove transition hack)
- Fix SettlementModel.pnl: float() → Decimal() for correct financial math
- Update async_usage.py example to use current field names
- Inline cents_to_dollars in web backend and _repr.py

All unit tests (274), integration tests (100), and live API tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- _repr.py / basic_usage.py: yes_price_fixed → yes_price_dollars
- async_usage.py: use float() for numeric max on volume_fp strings
- test_mve.py: use Decimal() for int conversion of fixed-point strings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arshka arshka force-pushed the refactor/remove-compat-layer branch from 07d3d91 to a87750a Compare March 18, 2026 23:01
@arshka arshka merged commit a609fa2 into main Mar 18, 2026
@arshka arshka deleted the refactor/remove-compat-layer branch March 18, 2026 23:01
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