Skip to content

fix: bind trade callback event loop - #10

Open
doskoi wants to merge 1 commit into
atompilot:mainfrom
doskoi:fix/trade-callback-event-loop
Open

fix: bind trade callback event loop#10
doskoi wants to merge 1 commit into
atompilot:mainfrom
doskoi:fix/trade-callback-event-loop

Conversation

@doskoi

@doskoi doskoi commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • bind BridgeTraderCallback to the running FastAPI asyncio loop after the trading manager connects
  • keep the change limited to trading startup
  • add a lifespan test that verifies callbacks receive the running loop

Why

BridgeTraderCallback dispatches xttrader background-thread events with asyncio.run_coroutine_threadsafe. Without setting the FastAPI loop during startup, trade websocket clients and notifiers may not receive order/trade/error callbacks.

Tests

  • uv run --with pytest --with fastapi python -m pytest tests/test_trade_callback_event_loop.py -q

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