`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..
pre_overruns_ctxcancelled
Tyler Goodlet 2023-04-11 14:03:47 -04:00
parent 65e42b79ac
commit 1bd4fd80f8
1 changed files with 10 additions and 4 deletions

View File

@ -619,7 +619,7 @@ async def _setup_quote_stream(
async def open_aio_quote_stream( async def open_aio_quote_stream(
symbol: str, symbol: str,
contract: Optional[Contract] = None, contract: Contract | None = None,
) -> trio.abc.ReceiveStream: ) -> trio.abc.ReceiveStream:
@ -741,9 +741,9 @@ async def stream_quotes(
try: try:
( (
con, con, # Contract
first_ticker, first_ticker, # Ticker
details, details, # ContractDetails
) = await proxy.get_sym_details(symbol=sym) ) = await proxy.get_sym_details(symbol=sym)
except ConnectionError: except ConnectionError:
log.exception(f'Proxy is ded {proxy._aio_ns}') 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. # pass back some symbol info like min_tick, trading_hours, etc.
con: Contract = details.contract
syminfo = asdict(details) syminfo = asdict(details)
syminfo.update(syminfo['contract']) syminfo.update(syminfo['contract'])
@ -785,6 +786,11 @@ async def stream_quotes(
price_tick: Decimal = Decimal(str(syminfo['minTick'])) price_tick: Decimal = Decimal(str(syminfo['minTick']))
size_tick: Decimal = Decimal(str(syminfo['minSize']).rstrip('0')) 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 syminfo['price_tick_size'] = price_tick
# NOTE: as you'd expect for "legacy" assets, the "volume # NOTE: as you'd expect for "legacy" assets, the "volume
# precision" is normally discreet. # precision" is normally discreet.