Skip to content

fix: sqlite decimal precision + portfolio sync bug fixes#424

Merged
MDUYN merged 1 commit into
devfrom
feature/sqlite-decimal-precision
Apr 15, 2026
Merged

fix: sqlite decimal precision + portfolio sync bug fixes#424
MDUYN merged 1 commit into
devfrom
feature/sqlite-decimal-precision

Conversation

@MDUYN

@MDUYN MDUYN commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

SQLite Decimal Precision

  • Replace Float columns with SqliteDecimal (TEXT-backed TypeDecorator) across all 8 model files for correct precision with large exchange numbers (e.g. BTC prices)

Portfolio Sync Bug Fixes

  1. Slippage price captured: execute_order() now copies actual execution price from the exchange response
  2. BUY cancel/expire/reject/fail restores EUR: Previously restored asset units (e.g. BTC qty) instead of EUR-denominated size to the trading symbol position
  3. None guard in check_pending_orders: No longer crashes when exchange returns None for an order lookup
  4. Buy order amount-change reconciliation: Added missing balance reconciliation when exchange modifies buy order amount (already existed for sell orders)
  5. Deduplicated sync methods: Extracted _restore_buy_order_balance() and _restore_sell_order_position() shared helpers from 8 nearly-identical methods

Test & Stub Updates

  • Added order_price to OrderExecutorTest stub for slippage testing
  • Added return_none_for_order flag to PortfolioProviderTest stub
  • 16 numeric precision tests
  • 13 startup sync + order lifecycle sync tests (21 total in new test file)
  • Replaced deprecated window_size with warmup_window in test_eventloop.py

All tests pass

1186 passed, 42 skipped

@MDUYN MDUYN force-pushed the feature/sqlite-decimal-precision branch from 8ba5269 to 2a3e9b4 Compare April 15, 2026 13:27
- Replace Float columns with SqliteDecimal (TEXT-backed) across all models
  for correct precision with large exchange numbers
- Fix slippage: execute_order now copies actual execution price from exchange
- Fix BUY cancel/expire/reject/fail: restore EUR size (not asset units) to
  trading symbol position
- Fix check_pending_orders crash when exchange returns None for an order
- Fix missing buy order amount-change reconciliation during sync
- Deduplicate cancel/expire/reject/fail into shared helpers
- Add order_price to OrderExecutorTest stub, return_none_for_order to
  PortfolioProviderTest stub
- Add 21 tests: numeric precision, startup sync, and all 5 sync fixes
- Replace deprecated window_size with warmup_window in test_eventloop
@MDUYN MDUYN force-pushed the feature/sqlite-decimal-precision branch from 2a3e9b4 to ddd5b5e Compare April 15, 2026 13:32
@MDUYN MDUYN merged commit 117faeb into dev Apr 15, 2026
7 checks passed
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