Skip to content

Commit c3bcc8c

Browse files
committed
ib: explicit ib_insync import in prep for passing client to reset hacker
1 parent 393e782 commit c3bcc8c

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

Diff for: piker/brokers/binance/api.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,14 @@ async def submit_limit(
661661
signed=True,
662662
action='post'
663663
)
664-
reqid: str = resp['orderId']
664+
# import tractor
665+
# await tractor.breakpoint()
666+
667+
# ensure our id is tracked by them
665668
if oid:
666-
assert oid == reqid
669+
assert oid == resp['clientOrderId']
667670

671+
reqid: str = resp['orderId']
668672
return reqid
669673

670674
async def submit_cancel(

Diff for: piker/brokers/ib/_util.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@
2121
'''
2222
from __future__ import annotations
2323
from functools import partial
24-
from typing import Literal
24+
from typing import (
25+
Literal,
26+
TYPE_CHECKING,
27+
)
2528
import subprocess
2629

2730
import tractor
2831

2932
from .._util import get_logger
3033

34+
if TYPE_CHECKING:
35+
from .api import Client
36+
from ib_insync import IB
37+
3138
log = get_logger('piker.brokers.ib')
3239

3340
_reset_tech: Literal[
@@ -42,7 +49,8 @@
4249

4350

4451
async def data_reset_hack(
45-
vnc_host: str,
52+
# vnc_host: str,
53+
client: Client,
4654
reset_type: Literal['data', 'connection'],
4755

4856
) -> None:

Diff for: piker/brokers/ib/broker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ async def open_trade_event_stream(
512512
async with tractor.to_asyncio.open_channel_from(
513513
recv_trade_updates,
514514
client=client,
515-
) as (ibclient, trade_event_stream):
515+
) as (_, trade_event_stream):
516516

517-
assert ibclient is client.ib
517+
# assert ibclient is client.ib
518518
task_status.started(trade_event_stream)
519519
await trio.sleep_forever()
520520

Diff for: piker/brokers/ib/feed.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
from async_generator import aclosing
3939
from fuzzywuzzy import process as fuzzy
40+
import ib_insync as ibis
4041
import numpy as np
4142
import pendulum
4243
import tractor
@@ -50,10 +51,10 @@
5051
)
5152
from .api import (
5253
# _adhoc_futes_set,
54+
Client,
5355
con2fqme,
5456
log,
5557
load_aio_clients,
56-
ibis,
5758
MethodProxy,
5859
open_client_proxies,
5960
get_preferred_data_client,
@@ -276,7 +277,8 @@ async def wait_on_data_reset(
276277
# )
277278
# try to wait on the reset event(s) to arrive, a timeout
278279
# will trigger a retry up to 6 times (for now).
279-
client = proxy._aio_ns.ib.client
280+
client: Client = proxy._aio_ns
281+
ib_client: ibis.IB = client.ib
280282

281283
done = trio.Event()
282284
with trio.move_on_after(timeout) as cs:
@@ -285,10 +287,11 @@ async def wait_on_data_reset(
285287

286288
log.warning(
287289
'Sending DATA RESET request:\n'
288-
f'{client}'
290+
f'{ib_client.client}'
289291
)
290292
res = await data_reset_hack(
291-
vnc_host=client.host,
293+
# vnc_host=client.host,
294+
ib_client=ib_client,
292295
reset_type=reset_type,
293296
)
294297

0 commit comments

Comments
 (0)