From 48cae3c1786ff3292f6bd996ac2f52ccd11ce83c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 11 Apr 2023 14:03:47 -0400 Subject: [PATCH] `ib`: rejects their own fractional size tick.. Frickin ib, they give you the `0.001` (or wtv) in the `ContractDetails.minSize: float` but won't accept fractional sizes through the API.. Either way, it's probably not sane to be supporting fractional order sizes for legacy instruments by default especially since it in theory affects a lot of the clearing outcomes by having ib do wtv magical junk behind the scenes to make it work.. --- piker/brokers/ib/feed.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index ead4b8e4..e06ae29c 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -619,7 +619,7 @@ async def _setup_quote_stream( async def open_aio_quote_stream( symbol: str, - contract: Optional[Contract] = None, + contract: Contract | None = None, ) -> trio.abc.ReceiveStream: @@ -741,9 +741,9 @@ async def stream_quotes( try: ( - con, - first_ticker, - details, + con, # Contract + first_ticker, # Ticker + details, # ContractDetails ) = await proxy.get_sym_details(symbol=sym) except ConnectionError: log.exception(f'Proxy is ded {proxy._aio_ns}') @@ -759,6 +759,7 @@ async def stream_quotes( ''' # pass back some symbol info like min_tick, trading_hours, etc. + con: Contract = details.contract syminfo = asdict(details) syminfo.update(syminfo['contract']) @@ -785,6 +786,11 @@ async def stream_quotes( price_tick: Decimal = Decimal(str(syminfo['minTick'])) size_tick: Decimal = Decimal(str(syminfo['minSize']).rstrip('0')) + # XXX: GRRRR they don't support fractional share sizes for + # stocks from the API?! + if con.secType == 'STK': + size_tick = Decimal('1') + syminfo['price_tick_size'] = price_tick # NOTE: as you'd expect for "legacy" assets, the "volume # precision" is normally discreet.