Skip to content

fix: drop unexpected market_type kwarg at LiveOrderPhaseAdapter call site - #228

Open
z20251130 wants to merge 1 commit into
OpenByteInc:mainfrom
z20251130:fix/live-order-adapter-market-type
Open

fix: drop unexpected market_type kwarg at LiveOrderPhaseAdapter call site#228
z20251130 wants to merge 1 commit into
OpenByteInc:mainfrom
z20251130:fix/live-order-adapter-market-type

Conversation

@z20251130

Copy link
Copy Markdown

Summary

Strategy-generated live orders crash at final placement with TypeError: LiveOrderPhaseAdapter.__init__() got an unexpected keyword argument 'market_type', so every live auto-order (all exchanges, spot and swap) has failed since d169c03 (2026-08-27). The commit added market_type= to the LiveOrderPhaseAdapter(...) call, but the class never accepted that parameter. This PR removes the stray kwarg.

Root cause

  • d169c03 ("refactor: unify exchange instrument rules") modified the call site in pending_order_worker.py but not the adapter class (live_trading/adapters.py, last changed 2026-07-22).
  • The adapter takes market_type from the OrderIntent in every method (place_market_order / place_limit_order / cancel_order / wait_for_fill), so the kwarg was not only unexpected but also unused — removing it from the call site is behavior-preserving.
  • No test covers this call site (test_live_exchange_fees.py constructs the adapter without the kwarg), and the failure path is only reachable through live auto-trading, which is why it went unnoticed.

Observed in production logs:

Unexpected order error (binance BNB/USDT open_long): LiveOrderPhaseAdapter.__init__() got an unexpected keyword argument 'market_type'

Changes

  • backend_api_python/app/services/pending_order_worker.py: remove the single unexpected market_type=market_type, line from the LiveOrderPhaseAdapter(...) call. 1 line, nothing else.

Test plan

  • python -m py_compile backend_api_python/app/services/pending_order_worker.py
  • Reproduced the TypeError on 21f1fb6 with the exact worker kwargs; confirmed the adapter constructs cleanly after removing the kwarg
  • Deployed locally (docker image rebuilt): the previously crashing BNB/USDT open_short (swap) + open_long (spot) strategy orders now pass the placement phase and reach the exchange

API documentation

  • No route/schema changes — no OpenAPI regeneration needed.

Backward compatibility

  • Fully backward compatible; restores pre-d169c03 behavior.

…site

d169c03 added market_type= to the LiveOrderPhaseAdapter(...) call in the
pending-order execution phase, but LiveOrderPhaseAdapter.__init__ never
accepted it. Every strategy-generated live auto-order (all exchanges,
spot and swap) therefore crashed with TypeError at final placement and
was marked failed:

  Unexpected order error (binance BNB/USDT open_long):
  LiveOrderPhaseAdapter.__init__() got an unexpected keyword argument
  'market_type'

The adapter takes market_type from the OrderIntent in every method
(place_market_order / place_limit_order / cancel_order / wait_for_fill);
the kwarg was unused. Remove it from the call site.

Reproduced on v5.0.1-beta (commit 21f1fb6) with the exact worker
kwargs; no test covered this call site (test_live_exchange_fees.py
constructs the adapter without the kwarg).
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