feat(V2): IBKR streaming tools (tick/depth/subscribe)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,3 +26,22 @@ async def test_get_account_tool_calls_client():
|
||||
client.get_account = AsyncMock(return_value={"netliquidation": {"amount": 10000}})
|
||||
res = await t.get_account(client, t.GetAccountReq())
|
||||
assert res["netliquidation"]["amount"] == 10000
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_tick_uses_cache_or_subscribes():
|
||||
client = MagicMock()
|
||||
client.resolve_conid = AsyncMock(return_value=42)
|
||||
ws = MagicMock()
|
||||
ws.get_tick_snapshot = MagicMock(side_effect=[
|
||||
None,
|
||||
{"conid": 42, "last_price": 99.5, "bid": 99.4, "ask": 99.6,
|
||||
"bid_size": 1, "ask_size": 1, "timestamp_ms": 1700000000000},
|
||||
])
|
||||
ws.subscribe_tick = AsyncMock()
|
||||
|
||||
res = await t.get_tick(
|
||||
client, t.GetTickReq(symbol="AAPL"), ws=ws, timeout_s=0.05,
|
||||
)
|
||||
assert res["last_price"] == 99.5
|
||||
ws.subscribe_tick.assert_awaited_once_with(42)
|
||||
|
||||
Reference in New Issue
Block a user